Jon*_*onB 1 java rdf screen-scraping jena rdfa
我有一个本体论,我和Jena一起阅读,帮助我从网站上删除一些RDFa三元组.我目前没有将这些三元组存储在耶拿模型中,但这是相当直接的,它在我的下一个列表中.
不过,我正在努力的领域是让Jena为我所拥有的本体输出正确的RDF.本体使用Owl和RDFS定义,但是当我将一些示例三元组传递给模型时,它们没有正确显示.几乎就好像它对本体论一无所知.然而,输出仍然是有效的RDF,只是它没有以我希望的形式出现.
我是否认为Jena应该能够根据本体生成关于我收集的三元组的良好书写的RDF(不仅仅是有效的),还是能够实现它的能力?
非常感谢任何意见.
更新1
例子:
这就是我们目前拥有的:
<rdf:Description rdf:about='http://theinternet.com/%3fq=Club/325'>
<j.0:hasName>Manchester United</j.0:hasName>
<j.0:hasPlayer>
<rdf:Description rdf:about='http://theinternet.com/%3fq=player/291/'>
</rdf:Description>
</j.0:hasPlayer>
<j.0:hasEmblem>http://theinternet.com/images/manutd.jpg</j.0:hasEmblem>
<j.0:hasWebsite>http://www.manutd.com/</j.0:hasWebsite>
</rdf:Description>
</rdf:RDF>
Run Code Online (Sandbox Code Playgroud)
这是我们理想的要求:
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:ontology="http://theinternet.com/ontology.rdf#">
<rdf:Description rdf:about='http://theinternet.com/%3fq=Club/325'>
<rdf:type rdf:resource='ontology:Club' />
<ontology:hasName>Manchester United</ontology:hasName>
<ontology:hasPlayer>
<rdf:Description rdf:about='http://theinternet.com/%3fq=player/291/'>
<rdf:type rdf:resource='ontology:Player' />
</rdf:Description>
</ontology:hasPlayer>
<ontology:hasEmblem>http://theinternet.com/images/manutd.jpg</ontology:hasEmblem>
<ontology:hasWebsite>http://www.manutd.com/</ontology:hasWebsite>
</rdf:Description>
</rdf:RDF>
Run Code Online (Sandbox Code Playgroud)
对我而言,看起来Jena缺少与本体有关的事情,例如资源类型等.我有这种感觉我错误地使用了Jena.
如果你想写得好的 rdf(xml我假设)使用编写器RDF/XML-ABBREV.默认通常很好,但是你会在这里找到调整说明.
没有问题输出的例子,很难知道你的问题是什么.你看到的东西是<j.0:SomeClass>什么样的?这是一个前缀问题.如果它们是在原始的RDFa文档中定义的那么你就会以某种方式丢失它们,但它应该很容易修复.否则,您可以使用PrefixMapping(Model扩展)中的方法在模型上手动设置它们.
更新的答案
谢谢你的例子.前缀是这里的主要问题.
model.setNsPrefix("ontology", "http://theinternet.com/ontology.rdf#");
model.setNsPrefix("dc", DC_11.NS);
model.setNsPrefix("owl", OWL.NS);
model.setNsPrefix("rdfs", RDFS.NS);
model.setNsPrefix("xsd", XSD.NS);
Run Code Online (Sandbox Code Playgroud)
(DC_11.NS 等人在jena词汇包中定义)
请注意,rdf:resource(like rdf:about)采用完整的URI,所以
<rdf:type rdf:resource='ontology:Club' />
Run Code Online (Sandbox Code Playgroud)
不起作用.使用该showDoctypeDeclaration 选项将使用XML实体缩写.
顺便说一下,你使用了哪个RDFa解析器?前缀定义应该通过.
| 归档时间: |
|
| 查看次数: |
3514 次 |
| 最近记录: |