Closed ali3assi closed 6 years ago
Dear @TamouzeAssi ,
You can use whatever client that supports REST. I have created to you a small example using httpcomponents https://github.com/dbpedia-spotlight/examples
Best,
Dear @sandroacoelho ,
Thank you for help. I think the the resourceItem miss two important functions: getUri and getTypes. I was not able to run the code in eclipse without these two function. By the way, can i know please how can for example fixe the confidence parameter and support. In addition i want to get the result including the surfaceForm, etc...
Thank you again and waintin for helpful ideas
Hi @TamouzeAssi ,
I used lombok (http://www.baeldung.com/intro-to-project-lombok) that provide getters and setters for all private variables in ResourceItem.
For confidence parameter, just add here, something like
params.add(new BasicNameValuePair("confidence", "0.5"));
For more info, check https://hc.apache.org/httpcomponents-client-ga/
Best
Hi Sir @sandroacoelho,
I have a file to annotate. i tried to parse this file, take a line at time and pass it to
annotationUnit = spotlight.get(line);
For some lines, it is ok, we get perfectly the results, but for some other lines we get the following error (these lines are good,):
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:892)
at com.google.gson.Gson.fromJson(Gson.java:841)
at com.google.gson.Gson.fromJson(Gson.java:813)
at org.dbpedia.spotlight.rest.Spotlight.get(Spotlight.java:53)
at org.dbpedia.spotlight.rest.Spotlight.get(Spotlight.java:121)
at org.dbpedia.spotlight.Example.replace(Example.java:76)
at org.dbpedia.spotlight.Example.main(Example.java:198)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
... 14 more
Does exists another way to do the job safely (i.e., like for example retry annotation tentative, or may be limit the requests per second )?
Thank you
Are you running it using our endpoint or localhost? If you are using our endpoint, try to run it locally
@sandroacoelho ,
I just run the code you sent, so it uses your endpoint. Can you please sepcify the step to take and how can i execute it locally? what i need?
Just run our Docker and modify this line to http://localhost:2222/rest/annotate
Best,
@sandroacoelho Sorry, you mean changing the url in the code to http://localhost:2222/rest/annotate and then execute docker by typing (only) the following: docker run -i -p 2222:80 dbpedia/spotlight-english spotlight.sh
Yes. You got it ;)
@sandroacoelho Im so sorry for disturbing. Im working on a server which does not accept DOCKER for security. It accept only singularity.
The problem i dont have experience with both. So by chance do you have any documentaion on how we can run dbpedia-spotlight using singularity, please
Maybe the section Run your own server at https://github.com/dbpedia-spotlight/dbpedia-spotlight-model can help you
@sandroacoelho you are the best~ thank you you save my time :)
I do the following:
1- I download the .jar from: https://downloads.dbpedia-spotlight.org/spotlight/dbpedia-spotlight-1.0.0.jar 2- I donlwoad the model from https://downloads.dbpedia-spotlight.org/2016-10/en/model/en.tar.gz 3- run the nohup java -jar dbpedia-spotlight-1.0.jar en http://localhost:2222/rest &
In the nohuup.out i have the following log:
When i execute my code i get the following exception:
my code is :
Noting that if i execute the following:
We get the following:
Any help please to identify the problem?