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 List<DBpediaResource> 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.");
        }

        LinkedList<DBpediaResource> resources = new
LinkedList<DBpediaResource>();
        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 List<String> getResults(String x) {
        System.out.println(x);
        List<String> resultList = new ArrayList<String>();
        Text text = new Text(x);
        System.out.println(text.toString());


            try {
                List<DBpediaResource> 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());

        List<DBpediaResource> 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.com>wrote:
>
>> 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=60134791&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Dbpedia-discussion mailing list
>>>> Dbpedia-discussion@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>>>>
>>>>
>>
>
>
> --
>
> Pablo N. Mendes
> http://pablomendes.com
>
------------------------------------------------------------------------------
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=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

Reply via email to