2

I'm facing a problem with dbpedia spotlight. I can't seem to connect to the local docker image found here.

I used the command docker pull dbpedia/spotlight-english with docker run -i -p 2222:80 dbpedia/spotlight-english and then checked that the container is running with docker ps. Everything works fine.

After that, I try to query the server by running the curl given in the spotlight documentation:

curl http://0.0.0.0:2222/en/annotate  \
  --data-urlencode "text=President Obama called Wednesday on Congress to extend a tax break
  for students included in last year's economic stimulus package, arguing
  that the policy provides more generous assistance." \
  --data "confidence=0.35"

And the same with the following URLs:

All I get is curl: (52) Empty reply from server.

What am I not getting here? All help appreciated.

3 Answers3

0

The correct is

curl -X POST \
  http://localhost:2222/rest/annotate \
  -H 'accept: application/json' \
  -H 'content-type: application/x-www-form-urlencoded' \
  --data-urlencode "text=President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance" \
  --data-urlencode "confidence=0.35"
0

To run the docker image of English version:

  1. docker run -i -p 2222: 80 dbpedia / spotlight-english spotlight.sh

  2. Open the localhost and give the text in the below format: localhost: 2222 / rest / annotate? Text = TextYouWantToAnnotate & confidence = 0.2 & support = 20

Example:

localhost:2222/rest/annotate?text=When I was growing up, my zealously frugal parents refused to buy anything from a bookstore, insisting that the local library had whatever it was we could possibly want to read. Faced with a small child’s intensive lobbying for repeated storytelling sessions with a lavishly illustrated picture book, my father would borrow one from the library and photocopy it. I still remember how anything colorful on the page (i.e. everything) would get transformed into dark blobs, the toner blurring the text and smudging my fingers.&confidence=0.2&support=20

ChrisF
  • 134,786
  • 31
  • 255
  • 325
-1

The empty reply error indicates that nothing was listening on your local port 2222. This is caused by the docker command docker run -i -p 2222:80 dbpedia/spotlight-english, in which the Spotlight container's port 2222 is mapped to port 80 on the host machine.

With the correct request syntax, as @Sandro has shared, the example should work on a locally running docker container with the url http://localhost:80/rest/annotate (or by omitting the port number altogether, given that 80 is the default).

AliOli
  • 561
  • 7
  • 16
  • as per the documentation(docs.docker.com/engine/reference/run/), the syntax is hostPort:containerPort, so 2222 is the right target port. – Lucas Azevedo Apr 23 '20 at 22:39
  • The "empty reply from server" error indicates that a zero-length response was received - if no one was listening to the port, you would receive something like "Failed to connect to ... ", and 2222 is the right port, Docker maps 2222 of the host to 80 of the container, so you address Spotlight over 2222, not 80! – AHH Jul 03 '23 at 01:42