高效存储三元组

2024-10-04 09:31:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个太大的文件。我想把它从nt转换成n3。这样做的原因是,我有一个大文件,由于附加了名称空间,它占用了大量空间:

# <1>
<file:///home//uniprot/uniprot.rdf>    <http://www.w3.org/2002/07/owl#imports> <http://purl.uniprot.org/core/> .
# <2>
<http://purl.uniprot.org/uniprot/Q6GZX4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.uniprot.org/core/Protein> .
# <3>
<http://purl.uniprot.org/uniprot/Q6GZX4> <http://purl.uniprot.org/core/reviewed> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .

现在我想以压缩形式高效地存储此文件,如下所示:

@fileuniprot: <file:///home//uniprot/>.
@owl: <http://www.w3.org/2002/07/owl#>.
@purlUniprot: <http://purl.uniprot.org/>.
@rdfs: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@xsd: <http://www.w3.org/2001/XMLSchema#>.
@xsd: 
# <1>
fileuniprot:uniprot.rdf    owl:imports purlUniprot:core .
# <2>
purlUniprot:uniprot/Q6GZX4 rdfs:type purlUniprot:core/Protein .
# <3>
purlUniprot:Q6GZX4 purlUniprot:core/reviewed "true"^^ xsd:boolean .

也就是说,我不希望名称空间附加相应的三元组。尽管我想保留评论。有可能吗。如果是的话,那么请有人建议一个有效的工具来做同样的事情。你知道吗

如果我能在python或java中找到一些与linux一起工作的工具,那就太好了? 我已经做了上述手动,这将是伟大的,如果转换可以自动完成。你知道吗


Tags: 文件orgcore名称httpwww空间rdf
1条回答
网友
1楼 · 发布于 2024-10-04 09:31:58

您可能需要考虑使用hdt进行非常好的压缩。 您可以将uniprot文件更改回使用gzip压缩的rdf/xml,并将大小至少减少25倍。(bzip2将给出30)我建议使用pbzip2获得最佳效果。你知道吗

如果您确实想使用turtle语法进行一些压缩,那么可以使用sesame RIOjena RIOT中预先存在的代码或librdf中的rapper

问题是你为什么要把文件作为nt开头?你知道吗

您实际考虑使用的文件格式称为turtle。N3是turtle plus规则,这个规则部分实际上没有在UniProt数据集中使用,只是在RDF/triples之外。你知道吗

rapper -i ntriples -o turtle ~/uniprot.nt  > ~/uniprot.ttl

忘了N3,读一下海龟吧。你知道吗

相关问题 更多 >