gpt4 book ai didi

testing - 如何解决 SPARQL 警告?

转载 作者:行者123 更新时间:2023-11-28 21:01:31 26 4
gpt4 key购买 nike

我正在尝试检索漫画书上墨者的姓名。我正在尝试构建本体。 Inkers 有 dbpprop,我在出现以下错误时导入了 rdlib 和 sparqlWrapper。有没有人明白这个问题?

  Abcde-MacBook-Pro:example Abcde$ python basicTest.py 
WARNING:rdflib.term: does not look like a valid URI, trying to serialize this will break.
Abcde-MacBook-Pro:example Abcde$ python basicTest.py
Traceback (most recent call last):
File "basicTest.py", line 78, in <module>
g = sparql.query().convert()
File "build/bdist.macosx-10.10-intel/egg/SPARQLWrapper/Wrapper.py", line 535, in query
File "build/bdist.macosx-10.10-intel/egg/SPARQLWrapper/Wrapper.py", line 513, in _query
SPARQLWrapper.SPARQLExceptions.EndPointInternalError: EndPointInternalError: endpoint returned code 500 and response.

Response:
Virtuoso RDF01 Error Bad variable value in CONSTRUCT: "Malcolm Jones III" (tag 246 box flags 0) is not a valid subject, only object of a triple can be a literal

SPARQL query:
define sql:big-data-const 0
#output-format:application/rdf+xml

我的代码看起来像

CONSTRUCT {
?comics ma:inked_by ?inker .
?inker rdf:type ma:Inker .
}
WHERE{
?comics rdf:type dbpedia-owl:Comics .
?comics foaf:name ?name .
OPTIONAL {?comics dbpprop:inkers ?inker}
FILTER regex(str(?name), "Batman")
}"""

最佳答案

我认为当您取出 ?inker 时就会出现问题。有时它是一个 URI,有时它是一个字符串。例如,以下是前两个输出:

"Malcolm Jones III"
http://dbpedia.org/resource/Vince_Colletta

我认为您需要更改代码,使您的着墨器是 URI 或字符串。以下将把 URI 保存在您的本体中(如果存在)。如果您需要字符串,请改用 ?inkername

CONSTRUCT {
?comics ma:inked_by ?inker.
?inker a ma:Inker.
}
where {
?comics a dbpedia-owl:Comics.
?comics foaf:name ?name .
optional{
?comics dbpprop:inkers ?inker.
?inker foaf:name ?inkername.
}
FILTER regex(str(?name), "Batman")

}

关于testing - 如何解决 SPARQL 警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29192378/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com