protege - create or load ontology in eclipse using owlapi -
hello write ontology in protege , add owlapi eclipse project. want add own ontology eclipse project these codes :
import static org.junit.assert.*; import static org.semanticweb.owlapi.search.searcher.annotations; import java.io.bytearrayoutputstream; import java.io.file; import java.util.arraylist; import java.util.collection; import java.util.collections; import java.util.hashset; import java.util.list; import java.util.set; import javax.annotation.nonnull; import org.junit.*; import org.junit.rule; import org.junit.test; import org.junit.rules.temporaryfolder; import org.semanticweb.owlapi.apibinding.owlmanager; import org.semanticweb.owlapi.formats.owlxmldocumentformat; import org.semanticweb.owlapi.io.streamdocumenttarget; import org.semanticweb.owlapi.io.stringdocumentsource; import org.semanticweb.owlapi.io.stringdocumenttarget; import org.semanticweb.owlapi.model.addaxiom; import org.semanticweb.owlapi.model.addontologyannotation; import org.semanticweb.owlapi.model.iri; import org.semanticweb.owlapi.model.owlannotation; import org.semanticweb.owlapi.model.owlannotationproperty; import org.semanticweb.owlapi.model.owlaxiom; import org.semanticweb.owlapi.model.owlclass; import org.semanticweb.owlapi.model.owlclassassertionaxiom; import org.semanticweb.owlapi.model.owlclassexpression; import org.semanticweb.owlapi.model.owldatafactory; import org.semanticweb.owlapi.model.owldataproperty; import org.semanticweb.owlapi.model.owldatapropertyassertionaxiom; import org.semanticweb.owlapi.model.owldatapropertyrangeaxiom; import org.semanticweb.owlapi.model.owldatarange; import org.semanticweb.owlapi.model.owldatatype; import org.semanticweb.owlapi.model.owldatatypedefinitionaxiom; import org.semanticweb.owlapi.model.owldatatyperestriction; import org.semanticweb.owlapi.model.owlentity; import org.semanticweb.owlapi.model.owlexception; import org.semanticweb.owlapi.model.owlindividual; import org.semanticweb.owlapi.model.owlliteral; import org.semanticweb.owlapi.model.owlnamedindividual; import org.semanticweb.owlapi.model.owlobjectproperty; import org.semanticweb.owlapi.model.owlobjectpropertyassertionaxiom; import org.semanticweb.owlapi.model.owlobjectpropertyexpression; import org.semanticweb.owlapi.model.owlobjectsomevaluesfrom; import org.semanticweb.owlapi.model.owlontology; import org.semanticweb.owlapi.model.owlontologycreationexception; import org.semanticweb.owlapi.model.owlontologyirimapper; import org.semanticweb.owlapi.model.owlontologymanager; import org.semanticweb.owlapi.model.owlsubclassofaxiom; import org.semanticweb.owlapi.model.prefixmanager; import org.semanticweb.owlapi.model.removeaxiom; import org.semanticweb.owlapi.model.swrlatom; import org.semanticweb.owlapi.model.swrlclassatom; import org.semanticweb.owlapi.model.swrlobjectpropertyatom; import org.semanticweb.owlapi.model.swrlrule; import org.semanticweb.owlapi.model.swrlvariable; import org.semanticweb.owlapi.profiles.owl2dlprofile; import org.semanticweb.owlapi.profiles.owlprofilereport; import org.semanticweb.owlapi.profiles.owlprofileviolation; import org.semanticweb.owlapi.reasoner.inferencetype; import org.semanticweb.owlapi.reasoner.node; import org.semanticweb.owlapi.reasoner.nodeset; import org.semanticweb.owlapi.reasoner.owlreasoner; import org.semanticweb.owlapi.reasoner.owlreasonerconfiguration; import org.semanticweb.owlapi.reasoner.owlreasonerfactory; import org.semanticweb.owlapi.reasoner.reasonerprogressmonitor; import org.semanticweb.owlapi.reasoner.simpleconfiguration; import org.semanticweb.owlapi.reasoner.structural.structuralreasonerfactory; import org.semanticweb.owlapi.util.autoirimapper; import org.semanticweb.owlapi.util.defaultprefixmanager; import org.semanticweb.owlapi.util.inferredaxiomgenerator; import org.semanticweb.owlapi.util.inferredontologygenerator; import org.semanticweb.owlapi.util.inferredsubclassaxiomgenerator; import org.semanticweb.owlapi.util.owlclassexpressionvisitoradapter; import org.semanticweb.owlapi.util.owlentityremover; import org.semanticweb.owlapi.util.owlontologymerger; import org.semanticweb.owlapi.util.owlontologywalker; import org.semanticweb.owlapi.util.owlontologywalkervisitorex; import org.semanticweb.owlapi.util.prioritycollection; import org.semanticweb.owlapi.util.simpleirimapper; import org.semanticweb.owlapi.vocab.owl2datatype; import org.semanticweb.owlapi.vocab.owlfacet; import org.semanticweb.owlapi.vocab.owlrdfvocabulary; import org.slf4j.logger; import org.slf4j.loggerfactory; import uk.ac.manchester.cs.owlapi.modularity.moduletype; import uk.ac.manchester.cs.owlapi.modularity.syntacticlocalitymoduleextractor; @suppresswarnings({ "javadoc", "null" }) public class test { public static void main(string[] args) { owlontologymanager m = owlmanager.createowlontologymanager(); prioritycollection<owlontologyirimapper> irimappers = m.getirimappers(); irimappers.add(new autoirimapper(new file("materializedontologies"), true)); owlontology o = m.loadontologyfromontologydocument(food); assertnotnull(o); } }
i don't know what's wrong here, try create ontology if have sample codes share it. new in protege , owlapi. please
loading ontology owl-api:
// load file file file = new file("ontology.owl); // loading ontology try { owlontologymanager manager = owlmanager.createowlontologymanager(); owlontology localontology = manager.loadontologyfromontologydocument(file); //getting axioms set<owlaxiom> axset= localontology.getaxioms(); } catch (owlontologycreationexception e) { e.printstacktrace(); }