0

I am trying to retrieve the name of inkers of Comic books. I am trying to build an ontology. Inkers has dbpprop and I have imported rdlib and sparqlWrapper whilst I am having following error. Is there any one who understand this problem?

  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

My code looks like

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") 
   }"""
4

1 回答 1

5

我认为当你?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") 

}

于 2015-03-22T09:23:45.573 回答