问题标签 [rdflib]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
462 浏览

python - Canopy UnicodeEncodeError:“ascii”编解码器无法对位置 31-32 中的字符进行编码:序数不在范围内(128)

我看到其他具有相同标题的问题,但他们没有回答我正在寻找的内容。我的macbook OS X(山狮)中有本机python 2.7.2,并且使用包RDFlib没有问题。几天前,我安装了 Canopy,这是一个不错的套件,并尝试运行相同的代码来解析http://dbpedia.org中的 RDF 数据并仅从中提取文字。由于相同的代码在纯 python 中工作,我推断它可能与 Canopy 相关。有谁知道如何解决这个问题?

这是代码:

0 投票
1 回答
1406 浏览

python - 在 Python 中使用 RDFlib 从 RDF 文件中提取标签和注释

我有以下本体:

我正在尝试从类、属性定义中提取标签、评论和关于。我正在使用 RDFlib 来解析文件。我想要输出:

我的初始代码:

我真的不知道怎么继续!有人可以帮助我吗?

0 投票
1 回答
1558 浏览

python - 为什么我的查询不能使用 RDFlib

我一直在尝试使用 RDFlib (SPARQL) 查询 OWL 数据,但我不明白为什么它不起作用。我在 Protege(SPARQL 查询)中测试了相同的查询,它运行良好!这是我的代码:

我的结果是什么都没有。没有错误,但是结果文件的长度为0。我做错了什么?有人可以帮助我吗?

0 投票
2 回答
56 浏览

enthought - 最新版本的 rdflib (4.0...) 不适用于 canopy enthought

我必须使用 rdflib 4.0.1(它的最新版本)才能使用 sparql,但是这个包在 Canopy 的包管理器(Enthought)中不可用。

在这种情况下,我该如何安装它?

0 投票
1 回答
130 浏览

python - 相同的 sparql 不返回相同的结果

我使用两个不同的客户端使用相同的 sparql 语句,但两者都没有返回相同的结果。owl 文件采用 rdf 语法,可在此处访问。这是 sparql 语句:

我正在使用顶部编织和以下 python 程序来使用它:

哪个返回 0

0 投票
1 回答
158 浏览

python - Python Rdflib。查询错误

我真的很生气!我需要使用 rdf lib 为图形创建查询。这是查询:

其中 elem 是一个 URI。我收到错误:“ParseException: Expected "}" (at char 129), (line:2, col:51)",对应于查询中 elem URI 的开头。谁能帮我?

0 投票
0 回答
1210 浏览

python - 使用 Python 和 RDFLib 将三元组添加到 Virtuoso Triplestore

我需要编写一个程序来将三元组添加到 Virtuoso Triplestore,我正在使用 Python 和 RDFLib。我已经安装了 Virtuoso 插件并尝试了http://pythonhosted.org/virtuoso/rdflib.html#virtuoso-storage中的连接。我有:

似乎没有问题,问题是:现在呢?如何添加新的三元组?我试过了:

产生以下错误:

问题是这有什么问题?以及如何正确添加三元组?谢谢。

0 投票
1 回答
916 浏览

python - The same query on Sparql gives different results

I read some questions related to my question, like Same sparql not returning same results, but I think is a little different.

Consider this query which I submit into http://live.dbpedia.org/sparql (Virtuoso endpoint) and get 34 triples as a result. Result Sparql

Then, I used the same query in a code in python:

This time, I get only 27 triples! https://dl.dropboxusercontent.com/u/22943656/result.txt

I thought it could be related to the dbpedia site. I repeated these queries several time and always got the same difference. Therefore, I downloaded the RDF file to test it locally, and used the software Protége to simulate the Virtuoso endpoint. Even though, I still have different results from the sparql submitted into Protége and Python, 31 and 27. Is there any explanation for this difference? And how can I get the same result in both?

0 投票
2 回答
2275 浏览

python - 使用 SPARQL 进行有限的 RDFS 和 OWL 推理

我目前使用 rdflib 在 Python 中创建和管理 RDF 图。不过,RDFlib 不执行任何 RDFS 或 OWL 推理。这会导致如下结果:

  1. 如果我有

    我问

    然后我什么也得不到,但我想得到A(通过 RDFS 语义)。

  2. 同样的事情发生在owl:equivalentClass. 如果我有

    我问

    我想得到A,但我什么也得不到。

有没有办法得到这些结果?

0 投票
1 回答
947 浏览

graph - RDFLib:从 URIRef 资源中删除命名空间

我有以下资源: http ://test.com/domainOnt/email#plans@plan.com

与在 RDFLib 中一样,当您在图中搜索 this 时,它会返回一个 URIRef 对象。我想从对象中删除命名空间,使其变为plans@plan.com

任何帮助表示赞赏