Re: [Dbpedia-discussion] Dbpedia lookup results in diferent languages.
The URL path to the service is /rest/candidates/ (observe the s in the end) On Sat, Oct 5, 2013 at 12:11 PM, Luciane Monteiro luciane@gmail.comwrote: Thank you very much for the answer, but I'm trying to test it here and I do'nt get any answer. The code is the one authored by you (Pablo Mendes), from Github. That's the class that I made some changes ( The part not in bold is the original and the blue one is the part I changed, trying to get some answer) *.* What's the problem here? (Thank you). * public class DBpediaSpotlightClient extends AnnotationClient {* * private final static String API_URL = http://spotlight.dbpedia.org/ ; private static final double CONFIDENCE = 0.0; private static final int SUPPORT = 0; * * @Override public ListDBpediaResource extract(Text text) throws AnnotationException { LOG.info(Querying API.); String spotlightResponse;* * try {* /*GetMethod getMethod = new GetMethod(API_URL + rest/annotate/? + confidence= + CONFIDENCE + support= + SUPPORT + text= + URLEncoder.encode(text.text(), utf-8)); getMethod.addRequestHeader(new Header(Accept, application/json));*/ * GetMethod getMethod = new GetMethod(API_URL + rest/candidate/? + text= + URLEncoder.encode(text.text(), utf-8) + confidence= + CONFIDENCE + support= + SUPPORT); * * getMethod.addRequestHeader(new Header(Accept, application/json)); spotlightResponse = request(getMethod); } catch (UnsupportedEncodingException e) { throw new AnnotationException(Could not encode text., e); } * * assert spotlightResponse != null; JSONObject resultJSON = null; JSONArray entities = null; try { resultJSON = new JSONObject(spotlightResponse); entities = resultJSON.getJSONArray(Resources); } catch (JSONException e) { throw new AnnotationException(Received invalid response from DBpedia Spotlight API.); } LinkedListDBpediaResource resources = new LinkedListDBpediaResource(); for(int i = 0; i entities.length(); i++) { try { JSONObject entity = entities.getJSONObject(i); resources.add( new DBpediaResource(entity.getString(@URI), Integer.parseInt(entity.getString(@support; } catch (JSONException e) { LOG.error(JSON exception +e); } } return resources; } public ListString getResults(String x) { System.out.println(x); ListString resultList = new ArrayListString(); Text text = new Text(x); System.out.println(text.toString()); try { ListDBpediaResource response = this.extract(text); for( DBpediaResource dbResource : response ) { resultList.add(dbResource.uri().toString()); } } catch (AnnotationException e) { e.printStackTrace(); } return resultList; } public static void main(String[] args) throws Exception { DBpediaSpotlightClient c = new DBpediaSpotlightClient (); * *Text text = new Text(Berlin.);* *System.out.println(text.toString()); ListDBpediaResource response = c.extract(text);* * PrintWriter out = new PrintWriter(AnnotationText-Spotlight.txt.set);* * for( DBpediaResource dbResource : response ) { System.out.println( dbResource.getFullUri()); } } }* 2013/10/5 Pablo N. Mendes pablomen...@gmail.com DBpedia lookup takes as input an entity name and returns a set of candidate entity URIs for that name. This can be accomplished via the /candidates interface of DBpedia Spotlight. See: http://spotlight.dbpedia.org/rest/candidates/?text=Berlin It does not return all of the fields (e.g. categories) and the XML format is different. But it basically does the job. Answering your question, as far as I know there is no deployed lookup for Portuguese. But you can download the source could and build it yourself in your own machine. Or you can try to convince someone from dbpedia-portugu...@lists.sourceforge.net to deploy it under pt.dbpedia.org Cheers, Pablo On Fri, Oct 4, 2013 at 8:01 AM, Luciane Monteiro luciane@gmail.comwrote: Thank you so much! , now spotlight works perfectly with Portuguese! Authough my question was in fact about how to use Dbpedia Lookup Service with Portuguese, that was such a valuable information, since I need to use Spotlight in Portuguese too. But do you have any idea on how to you the Dbpedia Lookup Service in Portuguese? Thank you so
Re: [Dbpedia-discussion] Dbpedia lookup results in diferent languages.
Thank you very much for the answer, but I'm trying to test it here and I do'nt get any answer. The code is the one authored by you (Pablo Mendes), from Github. That's the class that I made some changes ( The part not in bold is the original and the blue one is the part I changed, trying to get some answer)* .* What's the problem here? (Thank you). * public class DBpediaSpotlightClient extends AnnotationClient {* * private final static String API_URL = http://spotlight.dbpedia.org/;; private static final double CONFIDENCE = 0.0; private static final int SUPPORT = 0; * * @Override public ListDBpediaResource extract(Text text) throws AnnotationException { LOG.info(Querying API.); String spotlightResponse;* * try {* /*GetMethod getMethod = new GetMethod(API_URL + rest/annotate/? + confidence= + CONFIDENCE + support= + SUPPORT + text= + URLEncoder.encode(text.text(), utf-8)); getMethod.addRequestHeader(new Header(Accept, application/json));*/ * GetMethod getMethod = new GetMethod(API_URL + rest/candidate/? + text= + URLEncoder.encode(text.text(), utf-8) + confidence= + CONFIDENCE + support= + SUPPORT); * * getMethod.addRequestHeader(new Header(Accept, application/json)); spotlightResponse = request(getMethod); } catch (UnsupportedEncodingException e) { throw new AnnotationException(Could not encode text., e); } * * assert spotlightResponse != null; JSONObject resultJSON = null; JSONArray entities = null; try { resultJSON = new JSONObject(spotlightResponse); entities = resultJSON.getJSONArray(Resources); } catch (JSONException e) { throw new AnnotationException(Received invalid response from DBpedia Spotlight API.); } LinkedListDBpediaResource resources = new LinkedListDBpediaResource(); for(int i = 0; i entities.length(); i++) { try { JSONObject entity = entities.getJSONObject(i); resources.add( new DBpediaResource(entity.getString(@URI), Integer.parseInt(entity.getString(@support; } catch (JSONException e) { LOG.error(JSON exception +e); } } return resources; } public ListString getResults(String x) { System.out.println(x); ListString resultList = new ArrayListString(); Text text = new Text(x); System.out.println(text.toString()); try { ListDBpediaResource response = this.extract(text); for( DBpediaResource dbResource : response ) { resultList.add(dbResource.uri().toString()); } } catch (AnnotationException e) { e.printStackTrace(); } return resultList; } public static void main(String[] args) throws Exception { DBpediaSpotlightClient c = new DBpediaSpotlightClient (); * *Text text = new Text(Berlin.);* *System.out.println(text.toString()); ListDBpediaResource response = c.extract(text);* * PrintWriter out = new PrintWriter(AnnotationText-Spotlight.txt.set);* * for( DBpediaResource dbResource : response ) { System.out.println( dbResource.getFullUri()); } } }* 2013/10/5 Pablo N. Mendes pablomen...@gmail.com DBpedia lookup takes as input an entity name and returns a set of candidate entity URIs for that name. This can be accomplished via the /candidates interface of DBpedia Spotlight. See: http://spotlight.dbpedia.org/rest/candidates/?text=Berlin It does not return all of the fields (e.g. categories) and the XML format is different. But it basically does the job. Answering your question, as far as I know there is no deployed lookup for Portuguese. But you can download the source could and build it yourself in your own machine. Or you can try to convince someone from dbpedia-portugu...@lists.sourceforge.net to deploy it under pt.dbpedia.org Cheers, Pablo On Fri, Oct 4, 2013 at 8:01 AM, Luciane Monteiro luciane@gmail.comwrote: Thank you so much! , now spotlight works perfectly with Portuguese! Authough my question was in fact about how to use Dbpedia Lookup Service with Portuguese, that was such a valuable information, since I need to use Spotlight in Portuguese too. But do you have any idea on how to you the Dbpedia Lookup Service in Portuguese? Thank you so much!!! 2013/10/4 Pablo N. Mendes pablomen...@gmail.com Luciane, You can try to use the /candidates/ interface from DBpedia Spotlight Portuguese. Try http://spotlight.dbpedia.org/demo/ and then web search for dbpedia spotlight web service.
Re: [Dbpedia-discussion] Dbpedia lookup results in diferent languages.
Luciane, You can try to use the /candidates/ interface from DBpedia Spotlight Portuguese. Try http://spotlight.dbpedia.org/demo/ and then web search for dbpedia spotlight web service. (From my phone with a small screen) Cheers Pablo On Oct 3, 2013 9:45 PM, Luciane Monteiro luciane@gmail.com wrote: Hi! I'm using The Dbpedia Lookup Service but whatever is the language of the string I send in the query, it always returns me information in English. I'd like it to be in Portuguese. Is there a way to configure a language for the Dbpedia Lookup results? Thank you! -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60134791iu=/4140/ostg.clktrk ___ Dbpedia-discussion mailing list Dbpedia-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60134791iu=/4140/ostg.clktrk___ Dbpedia-discussion mailing list Dbpedia-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
Re: [Dbpedia-discussion] Dbpedia lookup results in diferent languages.
Thank you so much! , now spotlight works perfectly with Portuguese! Authough my question was in fact about how to use Dbpedia Lookup Service with Portuguese, that was such a valuable information, since I need to use Spotlight in Portuguese too. But do you have any idea on how to you the Dbpedia Lookup Service in Portuguese? Thank you so much!!! 2013/10/4 Pablo N. Mendes pablomen...@gmail.com Luciane, You can try to use the /candidates/ interface from DBpedia Spotlight Portuguese. Try http://spotlight.dbpedia.org/demo/ and then web search for dbpedia spotlight web service. (From my phone with a small screen) Cheers Pablo On Oct 3, 2013 9:45 PM, Luciane Monteiro luciane@gmail.com wrote: Hi! I'm using The Dbpedia Lookup Service but whatever is the language of the string I send in the query, it always returns me information in English. I'd like it to be in Portuguese. Is there a way to configure a language for the Dbpedia Lookup results? Thank you! -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60134791iu=/4140/ostg.clktrk ___ Dbpedia-discussion mailing list Dbpedia-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60134791iu=/4140/ostg.clktrk___ Dbpedia-discussion mailing list Dbpedia-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion