如何在python中加载Alignment格式?
有没有办法将对齐文件加载到 python 中。如果我有这样的文件:
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<rdf:RDF xmlns='http://knowledgeweb.semanticweb.org/heterogeneity/alignment#'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:xsd='http://www.w3.org/2001/XMLSchema#'
xmlns:align='http://knowledgeweb.semanticweb.org/heterogeneity/alignment#'>
<Alignment>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Catie+Curtis"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/catie-curtis"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">1.0</measure>
</Cell>
</map>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Bigelf"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/bigelf"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</measure>
</Cell>
</map>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/%C3%81kos"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/%C3%81kos"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.9</measure>
</Cell>
</map>
</Alignment>
</rdf:RDF>
我想保留置信值以及三倍: 主题:http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Catie+Curtis 谓词:owl:SameAs 对象:http://discogs.dataincubator.org/artist/catie-curtis Confidence:1.0
我试图用 RDFlib 来做到这一点,但没有成功。 任何建议都会有所帮助,谢谢!
Is there a way to load alignment file to python. If I have file like this:
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<rdf:RDF xmlns='http://knowledgeweb.semanticweb.org/heterogeneity/alignment#'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:xsd='http://www.w3.org/2001/XMLSchema#'
xmlns:align='http://knowledgeweb.semanticweb.org/heterogeneity/alignment#'>
<Alignment>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Catie+Curtis"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/catie-curtis"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">1.0</measure>
</Cell>
</map>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Bigelf"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/bigelf"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.8</measure>
</Cell>
</map>
<map>
<Cell>
<entity1 rdf:resource="http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/%C3%81kos"></entity1>
<entity2 rdf:resource="http://discogs.dataincubator.org/artist/%C3%81kos"></entity2>
<relation>=</relation>
<measure rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.9</measure>
</Cell>
</map>
</Alignment>
</rdf:RDF>
I want to keep confidence value as well as triple:
Subject:http://linkeddata.uriburner.com/about/id/entity//www.last.fm/music/Catie+Curtis
Predicate:owl:SameAs
Object:http://discogs.dataincubator.org/artist/catie-curtis
Confidence:1.0
I was trying to do it with RDFlib, but did not managed to.
Any suggestions will help, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 Redland 库:
http://librdf.org/docs/python.html
然后查询模型变量。例如,为了检索所有对齐并返回它们的度量,查询如下:
结果将包含字典对象(变量名称,结果)的迭代器,并将按如下方式打印:
Python中用于检索的API可以在此处检索节点内容:http://librdf.org/docs/python.html
有关 SPARQL 查询语言的概述,您可以阅读以下内容:http://www.w3 .org/TR/rdf-sparql-query/
Try with Redland libraries:
http://librdf.org/docs/python.html
And then query the model variable. For example, in order to retrieve all the alignments and return their measure, the query is the following:
The result will contain an iterator of dictionary objects (variable name , result) and it will be printed out as follows:
APIs in python for retrieving Nodes content can be retrieved here: http://librdf.org/docs/python.html
For an overview of the SPARQL query language you can read this: http://www.w3.org/TR/rdf-sparql-query/