[英]Extracting data from OWL file
<!-- http://www.semanticweb.org/vaio/ontologies/2013/0/untitled-ontology-113#hasDegree -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/vaio/ontologies/2013/0/untitled-ontology-113#hasDegree">
<rdfs:range rdf:resource="http://www.semanticweb.org/vaio/ontologies/2013/0/untitled-ontology-113#degree"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/vaio/ontologies/2013/0/untitled-ontology-113#student"/>
</owl:ObjectProperty>
使用java api我需要检查<owl:ObjectProperty
,如果rdf:about
那么我在#
之后如何使用hasDegree
而且..同样如果rdfs:range
然后在#
之后的degree
#
在6号线?
或者我如何使用java api提取这些值?
由于您的输入是OWL,请考虑使用OWL-API或任何其他OWL API,而不是使用较少OWL的工具,如XPath,XSLT,RDF库等。
我假设您正在使用OWL-API并且您的问题是:“如何在我的本体中获取对象属性的范围或域?” 在这种情况下:
/*Load the ontology from a local file and do the initialisations*/
File inputfile = new File("ontologyPath");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); ;
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLOntology yourOntology = manager.loadOntologyFromOntologyDocument(inputfile);
IRI ontologyIRI = yourOntology.getOntologyID().getOntologyIRI();
/*Get an object property and its ranges*/
OWLObjectProperty o_p_about = dataFactory.getOWLObjectProperty(IRI.create(ontologyIRI + "#"+"about"));
Set<OWLClassExpression> ranges_of_about = about.getRanges(LUCADAOntology);
要从这里获取它,您可以查看OWL-API网页上的文档和示例代码,它们非常有用。
使用Jena API调用OWL文件,然后使用Turtle来编写/输出它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.