N-triples IRI 前缀 jena

N-triples IRI prefix jena

我想用前缀来表示这个nt文件:

<www.test.com/a/yan-dang-shan> <www.test.com/a/zhongwenming> <www.test.com/a/yan-dang-shan> .
<www.test.com/a/yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "a" .
<www.test.com/a/zhongwenming> <http://www.w3.org/2000/01/rdf-schema#label> "b" .
<www.test.com/a/yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "c" .

我写入一个新的nt文件是:

@prefix sp: <www.test.com/a/> .
<sp:yan-dang-shan> <sp:zhongwenming> <sp:yan-dang-shan> .
<sp:yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "a" .
<sp:zhongwenming> <http://www.w3.org/2000/01/rdf-schema#label> "b" .
<sp:yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "c" .

但是当我在 cmd 中使用它来 sparql 时:

SELECT ?x ?y ?z
WHERE
{ ?x ?y ?z . }  

cmd 显示错误:

D:\>sparql --data=ceshi.nt --query=ceshi.rq
11:01:42 ERROR riot                 :: [line: 1, col: 1 ] Expected BNode or IRI:
 Got: [DIRECTIVE:prefix]
Failed to load data

我也试过这个:

@prefix sp: <www.test.com/a/> .
sp:yan-dang-shan sp:zhongwenming sp:yan-dang-shan .
sp:yan-dang-shan <http://www.w3.org/2000/01/rdf-schema#label> "a" .
sp:zhongwenming <http://www.w3.org/2000/01/rdf-schema#label> "b" .
sp:yan-dang-shan <http://www.w3.org/2000/01/rdf-schema#label> "c" .

但它报告相同的错误,我不知道如何修复它。

我应该怎么修改才可以?

如有任何帮助,我们将不胜感激。 谢谢!

N 元组没有前缀。

乌龟有前缀。尝试将您的数据放入扩展名为“.ttl”的文件中。

您可以使用命令行工具测试您的数据riot