2013-04-09 63 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