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") 
   }"""
Sandesh Rana
  • 81
  • 4
  • 13
  • What are the three quote marks for? Also, why are you retrieving items with the `construct` keyword rather than `select`? – Artemis Mar 22 '15 at 08:44
  • @Artemis, The """ is the ending point of code. I am constructing an ontology therefore I am using Construct code. – Sandesh Rana Mar 22 '15 at 08:58
  • Do you need the name of the inker to be saved in your ontology? I mean a "String" that represents a name? – Artemis Mar 22 '15 at 09:12
  • @Artemis, Yes you are write. – Sandesh Rana Mar 22 '15 at 09:19
  • @Artemis, The ranges for Inker in Data Property are defined as String. I am using Protege to create an ontology. The main error is ->>>> 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. – Sandesh Rana Mar 22 '15 at 09:20

1 Answers1

5

I think the problem arises when you get the ?inker out. Sometime it is a URI and sometime it is a string. For example, the following are the top two outputs:

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

I think you need to change your code in a way that your inker is either a URI or a string. The following will save the URI in your ontology, if it exists. If you need a string use the ?inkername instead.

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

}

Artemis
  • 3,271
  • 2
  • 20
  • 33
  • Yes it works, I just added ?inker foaf:name ?inkername . which made it work. Thank you very much – Sandesh Rana Mar 22 '15 at 09:26
  • Thank you for letting me know. Do you have any idea of this error, Response: Virtuoso 42000 Error The estimated execution time 253 (sec) exceeds the limit of 240 (sec).. Is it because of over limit? is there limit as well in sparql? – Sandesh Rana Mar 22 '15 at 09:58
  • Yes, it means you are exceeding the time and the dataset is very big. Either put a limit on the amount of items you want to take out, or set another filter. – Artemis Mar 22 '15 at 10:24