2013-04-09 76 views
0

我想在OWL本體對象上編寫OWLObjectPropertyExpression。如果我有一個OWL類我使用類似以下內容:使用OWL API在OWL本體上編寫OWLObjectPropertyExpression

OWLOntologyManager managerWriter = OWLManager.createOWLOntologyManager(); 
OWLOntology ontoWrite=managerWriter.createOntology(); 
OWLDataFactory factory = manager.getOWLDataFactory(); 
managerWriter.addAxiom(ontoWrite,factory.getOWLDeclarationAxiom(factory.getOWLClass((cl.getIRI())))); 

但我應該怎麼寫,如果我想要寫一個OWLObjectPropertyExpression? 在此先感謝!

回答

0

下面的代碼片段演示使用OWL API(從there採取和改編)的OWL表達的使用和創造的一個例子:

//OWL Expression we would like to create: 
//in OWL Functional syntax: ObjectIntersectionOf(A ObjectSomeValuesFrom(R B)) 
//in Manchester syntax: A and R some B 
PrefixManager pm = new DefaultPrefixManager("http://example.org/"); 
OWLClass A = factory.getOWLClass(":A", pm); 
OWLObjectProperty R = factory.getOWLObjectProperty(":R", pm); 
OWLClass B = factory.getOWLClass(":B", pm); 

//The expression 
OWLClassExpression expression = 
    factory.getOWLObjectIntersectionOf(A, factory.getOWLObjectSomeValuesFrom(R, B)); 

//Create a class in order to use the expression 
OWLClass C = factory.getOWLClass(":C", pm); 

// Declare an equivalentClass axiom 
//Just there to show how an example on how to use the expression 
OWLAxiom definition = factory.getOWLEquivalentClassesAxiom(C, expression); 
manager.addAxiom(ontology, definition); 
+0

謝謝您的回答。在我的情況下,我從外部對象收到一個OWLClassExpression對象,我不知道要在OWLAxiom定義中放置什麼。有什麼建議麼 ? – Discipulos 2013-04-10 08:11:29

+0

你想用OWLClassExpression對象做什麼?通常人們將這些表達式與公理結合使用,如圖所示。 – loopasam 2013-04-10 09:07:14

+0

好吧,讓我進一步解釋。我以實驗性的方式使用了Hermit Reasoner。在推理器中存在一個類org.semanticweb.Hermit.structural.OWLAxioms。我試圖在本體的一些字段中寫入(例如m_complexObjectPropertyExpressions)。 – Discipulos 2013-04-10 09:37:30