简体   繁体   English

猫头鹰 从rdf提取ObjectProperty

[英]OwlApi. Extract ObjectProperty from rdf

I'm trying to extract all the classes and the ObjectProperties from a .rdf file that cointains some rdf triple. 我正在尝试从包含一些rdf三元组的.rdf文件中提取所有类和ObjectProperty。 I'm loading this file LUBM 我正在加载此文件LUBM

OWLOntologyManager manager  = OWLManager.createOWLOntologyManager();
File ontFile = new File("C:\\Ontology\\University0_0.owl");
OWLOntology ont = manager.loadOntologyFromOntologyDocument(ontFile);
StructuralReasonerFactory factory = new StructuralReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(ont);

Now I extract all the class: 现在,我提取所有类:

 System.out.println("Class");
 for (OWLClass cls : ont.getClassesInSignature(Imports.EXCLUDED)){
     System.out.println(cls.toString());
 }

And now I extract all the ObjectProperty: 现在,我提取所有ObjectProperty:

System.out.println("Role");
for (OWLObjectProperty obp : ont.getObjectPropertiesInSignature()){
    System.out.println(obp.toString());
}

I don't need all the classes and the properties of the ontology( LUBM Ontology ), but only the classes and the property that are used in the .rdf file. 我不需要本体( LUBM Ontology )的所有类和属性,而只需要.rdf文件中使用的类和属性。 But ont.getObjectPropertiesInSignature() return a empty set. 但是ont.getObjectPropertiesInSignature()返回一个空集。 (I have the same problem with .rdf file from DBPedia.) (我对DBPedia的.rdf文件有同样的问题。)

I know that I can use ont.getObjectPropertiesInSignature(Imports.INCLUDED) but I'm not interested to the properties of the ontology. 我知道我可以使用ont.getObjectPropertiesInSignature(Imports.INCLUDED),但是我对本体的属性不感兴趣。

After this I need to do some query with SPARQL-DL and if I do the following query I haven't result. 此后,我需要对SPARQL-DL进行一些查询,如果执行以下查询,则不会得到结果。

SELECT DISTINCT ?x ?y WHERE { 
    PropertyValue(?x, <http://swat.cse.lehigh.edu/onto/univ-bench.owl#takesCourse>, ?y)
}

(I take http://swat.cse.lehigh.edu/onto/univ-bench.owl#takesCourse exploring the dataset manually) (我采取http://swat.cse.lehigh.edu/onto/univ-bench.owl#takesCourse手动探索数据集的过程)

But if I use Jena and do the above query with a SPARQL query all work and I have results. 但是,如果我使用Jena并使用SPARQL查询执行上述查询,那么所有工作都将有效,并且我会得到结果。

SELECT DISTINCT ?x ?y 
WHERE{
?x <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#takesCourse> ?y.
}

I cannot see any object property declaration in the file you have linked - this would likely stop them being listed. 在您链接的文件中看不到任何对象属性声明-这很可能会阻止它们被列出。

Note that the SPARQL queries you have shown have different namespaces for the properties, so it's not surprising that they bring back different results. 请注意,您显示的SPARQL查询具有不同的属性名称空间,因此它们带来不同的结果也就不足为奇了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM