我正在寻找一种方法来查询以Turtle语法格式化的RDF文件。RDF文件实际上是维基数据提供的整个Wikipedia类别层次结构。
下面是从文件enwiki categories.ttl的内容中提取的内容,显示了数据的全局结构:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix mediawiki: <https://www.mediawiki.org/ontology#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix schema: <http://schema.org/> .
@prefix cc: <http://creativecommons.org/ns#> .
<https://en.wikipedia.org/wiki/Category:1148_establishments_in_France> a mediawiki:Category ;
rdfs:label "1148 establishments in France" ;
mediawiki:pages "2"^^xsd:integer ;
mediawiki:subcategories "0"^^xsd:integer .
<https://en.wikipedia.org/wiki/Category:1148_establishments_in_France> mediawiki:isInCategory <https://en.wikipedia.org/wiki/Category:1140s_establishments_in_France>,
<https://en.wikipedia.org/wiki/Category:1148_establishments_by_country>,
<https://en.wikipedia.org/wiki/Category:1148_establishments_in_Europe>,
<https://en.wikipedia.org/wiki/Category:1148_in_France>,
<https://en.wikipedia.org/wiki/Category:Establishments_in_France_by_year> .我的最终目标是能够通过查询retrieve文件来检索Wikipedia类别的所有父类别。下面是一个非常简短的Java代码示例,展示了我的问题:
LogCtl.setCmdLogging();
Model model = ModelFactory.createDefaultModel();
model.read("enwiki-categories.ttl");RDF文件超过850 MB,使用前面显示的代码加载模型会导致内存不足错误。我需要一种方法来查询RDF文件,而不必在内存中加载完整的RDF数据库。
--
是否有一种使用Apache或其他库进行此操作的方法?
如果没有,是否有更快的方法从Wikipedia中的给定类别中检索所有父类别,使用本地数据?
发布于 2018-05-16 13:13:49
你打算做的是所谓的“更广泛的概念”。
它是在SKOS (skos:范围更广)正式化的。下面是指向文档的链接:SKOS
SKOS的定义是:
简单知识组织系统( Simple,SKOS)是一种通过Web共享和连接知识组织系统的通用数据模型。
例如,树的更广泛的概念是植物。树木是松树或橡树的广义概念.它是在SKOS (skos:范围更广)正式化的。
发布于 2018-05-16 12:23:47
是的,你可以用耶拿做查询。这正是耶拿设计的目的。不过,我建议您将文件导入RDF数据存储,然后使用Jena对RDF数据存储执行SPARQL查询。
您可能希望看到我对相关问题的回答,在这里我提供了一些对RDF数据存储的引用。
https://stackoverflow.com/questions/50370001
复制相似问题