我试图使用Parse large RDF in Python中的代码解析一个相当大的NTriples文件
我为python安装了raptor和redland绑定。在
import RDF
parser=RDF.Parser(name="ntriples") #as name for parser you can use ntriples, turtle, rdfxml, ...
model=RDF.Model()
stream=parser.parse_into_model(model,"file:./mybigfile.nt")
for triple in model:
print triple.subject, triple.predicate, triple.object
但是程序挂起了,我怀疑它试图将整个文件加载到内存中或其他原因,因为它不能立即启动。在
有人知道怎么解决这个问题吗?在
它的速度很慢,因为你正在向内存存储区中读取数据(RDF.型号()默认值)没有索引。所以它变得越来越慢。对N-Triples的解析确实是从文件中流出来的,它从不把它全部吸收到内存中。在
有关存储模型的概述,请参见Redland storage modules documentation。在这里,您可能需要存储
type
“哈希”和hash-type
内存。在(未测试)
相关问题 更多 >
编程相关推荐