Hi Luciane,
Several things are going on here.
First, I don't know why the URIs that you get from the response are
malformed. I don't see the mistake in your code, but when I try the DBp
Spotlight demo <http://dbpedia-spotlight.github.io/demo/index.html>, the
correct URIs are returned.
Second, the Portugese DBpedia server actually seems to be in trouble. If
this is of concern to you, you could try the DBpedia mailinglist to
check what is going on.
Depending on what you are aiming to do, you could just use the
well-formed part of the URIs: http://pt.dbpedia.org/resource/<entity>.
If you are still experimenting, and want to check if the responses make
sense for your purpose, I would suggest to just use the entity
identifier and append it to the Wikipedia URL, as such:
http://pt.wikipedia.org/wiki/<entity>
Hope this helps!
Cheers,
Alex
On 25-11-2013 13:51, Luciane Monteiro wrote:
*Hi!
*
*I'm using Spotlight with this URL (to query for Portuguese Results) : *
private final static String API_URL = "http://spotlight.sztaki.hu:2228/";
*And the extraction method is like this:
*
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"));
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;
}
*
*
*The URIs returned are like this:*
http://dbpedia.org/resource/Http://pt.dbpedia.org/resource/Ator
http://dbpedia.org/resource/Http://pt.dbpedia.org/resource/Cruzeiro_Esporte_Clube
http://dbpedia.org/resource/Http://pt.dbpedia.org/resource/Teatro
http://dbpedia.org/resource/Http://pt.dbpedia.org/resource/Wolf_Maya
*When I test the complete URI on the browser, like this:*
http://dbpedia.org/resource/Http://pt.dbpedia.org/resource/Ator
*I get the message: "The requested entity is unknown"
*
*And when I test the second part, like this:*
Http://pt.dbpedia.org/resource/Ator
*I get the message: "Service Temporarily Unavailable"
*
*What's the problem?*
*Thank you!*
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Dbp-spotlight-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbp-spotlight-users
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Dbp-spotlight-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbp-spotlight-users