繁体   English   中英

从OWL文件中提取数据

[英]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,特别是你所展示的RDF / XML格式的OWL,你应该看看使用JenaSesame,因为它们是用于处理RDF的事实标准Java API。 我会推荐Sesame API,因为它更简单,更容易掌握,但两者都是非常好的库。

每个网站都有关于如何使用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.

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