有效地存储三元组

时间:2013-10-30 13:38:27

标签: java python linux semantics semantic-web

我有一个Tera Byte大文件。我想将它从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一起工作的工具,那会很棒吗? 我手动完成了上述操作,如果转换可以自动完成,那就太棒了。

1 个答案:

答案 0 :(得分:1)

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

如果您确实想要使用turtle语法进行某些压缩,那么请使用sesame RIO中的预先存在的代码,jena RIOT或来自librdf的说唱歌手

问题是你为什么要把文件作为nt开始?

您实际考虑使用的文件格式称为turtle。 N3是乌龟加规则,此规则部分实际上并未在UniProt数据集中使用,并且不属于RDF /三元组。

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

忘掉N3读取乌龟了。