freme-project / e-Link

Apache License 2.0
0 stars 0 forks source link

Error when the response from the endpoint contains the character '-' #72

Closed borriellom closed 7 years ago

borriellom commented 7 years ago

It seems that the e-Link service fails when the response from the endpoint contains the character -.

In order to reproduce the bug, invoke the service by submitting the NIF file and the SPARQL template below (the SPARQL template already exists on the current live version with id 4534).

NIF file

@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .
@prefix nif:   <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> .

<http://freme-project.eu/#char=0,19>
        a                  nif:RFC5147String , nif:Context , nif:String ;
        nif:beginIndex     "0"^^xsd:nonNegativeInteger ;
        nif:endIndex       "19"^^xsd:nonNegativeInteger ;
        nif:isString       "Republic of Ireland"^^xsd:string ;
        itsrdf:taIdentRef  <http://dbpedia.org/resource/Republic_of_Ireland> .

SPARQL template

PREFIX dbo: <http://dbpedia.org/ontology/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT {
    <@@@entity_uri@@@> ?p ?o .

} 
WHERE 
{  
  OPTIONAL {<@@@entity_uri@@@> ?p ?o } . 

  FILTER  
 (?p in (dbo:largestCity, dbo:politicalLeader, dbo:country, rdfs:seeAlso, dbo:governmentType, dbo:leader, dbo:capital, dbo:birthPlace, dbo:deathPlace, dbo:team, dbo:genre, dbo:party, dbo:spouse))  .
}

Response from the service

{
  "exception": "eu.freme.common.exception.BadRequestException",
  "path": "/e-link/documents/",
  "message": "Could not process the enrichment result from the endpoint=http://dbpedia.org/sparql executing the query=PREFIX dbo: <http://dbpedia.org/ontology/> \nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nCONSTRUCT {\n    <http://dbpedia.org/resource/Republic_of_Ireland> ?p ?o .\n\n} \nWHERE \n{  \n  OPTIONAL {<http://dbpedia.org/resource/Republic_of_Ireland> ?p ?o } . \n\n  FILTER  \n (?p in (dbo:largestCity, dbo:politicalLeader, dbo:country, rdfs:seeAlso, dbo:governmentType, dbo:leader, dbo:capital, dbo:birthPlace, dbo:deathPlace, dbo:team, dbo:genre, dbo:party, dbo:spouse))  .\n}. Error message: [line: 8, col: 14] Unknown char: –(8211;0x2013)",
  "error": "Bad Request",
  "status": 400,
  "timestamp": 1478169636888
}

When running the SPARQL query for the http://dbpedia.org/resource/Republic_of_Ireland resource in the DBpedia SPARQL endpoint, the following response is returned.

@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dbr:    <http://dbpedia.org/resource/> .
dbr:Republic_of_Ireland rdfs:seeAlso    dbr:Irish_population_analysis ,
        dbr:The_Republic_of_Ireland_by_population ,
        dbr:Republic_of_Ireland ,
        dbr:Abortion ,
        dbr:List_of_urban_areas ,
        dbr:Ireland–NATO_relations .
@prefix dbo:    <http://dbpedia.org/ontology/> .
dbr:Republic_of_Ireland dbo:capital dbr:Dublin ;
    dbo:governmentType  dbr:Unitary_state ,
        dbr:Parliamentary_republic ;
    dbo:leader  <http://dbpedia.org/resource/Michael_D._Higgins> ,
        dbr:Joan_Burton ,
        dbr:Enda_Kenny .

The problem might originate from the dbr:Ireland–NATO_relations string containing the - symbol.

borriellom commented 7 years ago

Sorry, I've just realized that this is the same as the #69 .