Reasoner不返回owl的实例:Thing,但Abox包含实例

时间:2013-07-30 16:43:37

标签: ontology owl owl-api fact++

我有两个本体,photo1和索引。 Photo1包含ABox断言,索引包含Tbox断言。

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology photo1 = manager.loadOntologyFromOntologyDocument(new File("files/ontologies/OBMA2/photo1.owl"));
OWLDataFactory factory = manager.getOWLDataFactory();
reasoner = new FaCTPlusPlusReasonerFactory().createReasoner(photo1);
reasoner = (FaCTPlusPlusReasoner) reasoner;
System.out.println(reasoner.getInstances(factory.getOWLThing(), false));

以上版画:

Nodeset[
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1> ),
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1-tiger2> ),
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1-tiger1> )
]

但是,现在,我正在加载Tbox并从photo1添加所有ABox公理,然后获取owl:Thing的实例,如下所示:

OWLOntologyManager managerTbox = OWLManager.createOWLOntologyManager();
OWLOntology Tbox = manager.loadOntologyFromOntologyDocument(new File("files/ontologies/index.owl"));
OWLDataFactory factoryTbox = manager.getOWLDataFactory();
OWLReasoner reasonerTbox = new FaCTPlusPlusReasonerFactory().createReasoner(Tbox);

//adding the axioms from the photo1 abox to Tbox's abox
managerTbox.addAxioms(Tbox, photo1.getABoxAxioms(true));
reasonerTbox = (FaCTPlusPlusReasoner) reasonerTbox;
System.out.println(reasonerTbox.getInstances(factoryTbox.getOWLThing(), false));

现在,即使我已经将Photo1的ABox中的所有公理添加到TBox的ABox中,但我没有输出:

Nodeset[]

2 个答案:

答案 0 :(得分:1)

我不是一个OWL API用户,但我怀疑发生的事情是你在第二个案例中包含的ABox公理不包括公理所谈论的个人的个别声明,结果,ABox公理被忽略了。

从OWLAPI来源,ABoxAxiomTypes定义为:

public static final Set<AxiomType<?>> ABoxAxiomTypes = new HashSet<AxiomType<?>>(
        Arrays.asList(CLASS_ASSERTION, SAME_INDIVIDUAL,
                DIFFERENT_INDIVIDUALS, OBJECT_PROPERTY_ASSERTION,
                NEGATIVE_OBJECT_PROPERTY_ASSERTION,
                DATA_PROPERTY_ASSERTION, NEGATIVE_DATA_PROPERTY_ASSERTION,
                DATATYPE_DEFINITION));

我希望如果您首先添加photo1的OWLDeclarationAxiom(看起来您使用getAxioms(AxiomType<Declaration>)检索它,然后添加其ABoxAxioms,您可能会得到您期望的结果。

答案 1 :(得分:1)

您正在创建一个缓冲推理器,第一次调用推理器工厂;然后你正确地将公理添加到本体,但是在你致电reasoner.flush()之前,推理者将看不到更新。

您可以使用同一工厂创建非缓冲推理器(请参阅OWLReasonerFactory.createNonBufferingReasoner()),但这可能会产生性能影响,因为每次更改都可能会重新分类。