freme-project / e-Entity

Apache License 2.0
1 stars 1 forks source link

P3: NullPointerException in dbpedia spotlight #26

Closed jnehring closed 8 years ago

jnehring commented 9 years ago

This API call produces a NullPointerException:

POST http://localhost:8080/e-entity/dbpedia-spotlight/documents?informat=text&outformat=json-ld&language=en&confidence=0.3

Post data:
Welcome To Berlin

In class eu.freme.broker.eservices.DBPediaSpotlight I see in line 75 that only inputs submitted via query string are used as input. When the input is submitted via post body then the text passed to e-Entity is null which causes the NullPointerException.

nilesh-c commented 8 years ago

Fixed.

jnehring commented 8 years ago

I send this request:

POST http://api-dev.freme-project.eu/current/e-entity/dbpedia-spotlight/documents?confidence=0.3&informat=turtle

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

<http://example.org/document/1#char=0,21>
  a nif:String, nif:Context, nif:RFC5147String ;
  nif:isString "Welcome to Berlin"^^xsd:string;
  nif:beginIndex "0"^^xsd:nonNegativeInteger;
  nif:endIndex "21"^^xsd:nonNegativeInteger;
  nif:sourceUrl <http://differentday.blogspot.com/2007_01_01_archive.html>. 

I get a very long and wrong response. For example this bit:

undefined<http://freme-project.eu/char=0,497>
        a               nif:RFC5147String , nif:Context ;
        nif:beginIndex  "0" ;
        nif:endIndex    "497" ;
        nif:isString    "@prefix nif: undefined<http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#> . \n@prefix itsrdf: undefined<http://www.w3.org/2005/11/its/rdf#> . \n@prefix xsd: undefined<http://www.w3.org/2001/XMLSchema#> .\n\nundefined<http://example.org/document/1#char=0,21>\n  a nif:String, nif:Context, nif:RFC5147String ;\n  nif:isString \"Welcome to Berlin\"^^xsd:string;\n  nif:beginIndex \"0\"^^xsd:nonNegativeInteger;\n  nif:endIndex \"21\"^^xsd:nonNegativeInteger;\n  nif:sourceUrl undefined<http://differentday.blogspot.com/2007_01_01_archive.html>. \n" .

It seems the NIF is interpreted as plaintext. Further it says "undefined" in the beginning of the URI. There is a lot of "undefined" in the output, e.g.

undefined<http://freme-project.eu/char=314,315>
        a                     nif:RFC5147String , nif:Word ;
        nif:anchorOf          "\"" ;
        nif:beginIndex        "314" ;
        nif:endIndex          "315" ;
        nif:nextWord          undefined<http://freme-project.eu/char=315,316> ;
        nif:previousWord      undefined<http://freme-project.eu/char=308,314> ;
        nif:referenceContext  undefined<http://freme-project.eu/char=0,497> ;
        nif:sentence          undefined<http://freme-project.eu/char=190,495> .

I am going to turn off dbpedia-spotlight for the re-release. This bug should be fixed within FREME 0.3.

nilesh-c commented 8 years ago

@jnehring I think this happens only for NIF input and not if you POST free text. You could simply remove the NIF input feature for the re-release and keep the rest?

jnehring commented 8 years ago

I removed the NIF input from the documentation. So people can still use dbpedia spotlight with plaintext in the current release.

nilesh-c commented 8 years ago

@m1ci any idea what the problem is here?

m1ci commented 8 years ago

Hi Jan, back to your initial question:

The API call produces a NullPointerException:

POST http://localhost:8080/e-entity/dbpedia-spotlight/documents?informat=text&outformat=json-ld&language=en&confidence=0.3

Post data:
Welcome To Berlin

IMO this request is wrong. Didn't we say that if we specify informat=text, then actual content is sent as value of the input parameter? Sorry if missed something here and thanks!

m1ci commented 8 years ago

Oh, I see in the documentation description of the input param: "If set, it will be preferred over the body content." So its clear now, will fix it.

m1ci commented 8 years ago

It works for the following request:

curl -v -X POST -d @eentity-test.ttl "http://api-dev.freme-project.eu/current/e-entity/dbpedia-spotlight/documents?confidence=0.3&informat=turtle" -H "Content-Type:"

Can you please check whether the problem still occur.

jnehring commented 8 years ago

Tested again and it works.