public DBpediaResource dereference(String eid) throws AnnotationException {
JSONObject entity = requestDereference(eid);
List<String> sameAs = new ArrayList<String>();
// This will be the result if we can't get anything better
DBpediaResource dbpediaSameAs = new DBpediaResource(eid);
try {
String label = entity.getString("label");
// This will be the result if there is no proper link to DBpedia
if (label!=null)
dbpediaSameAs = new DBpediaResource(label);
// Now we try to get the proper link
JSONObject props = entity.getJSONObject("props");
JSONArray sameAsIds = props.getJSONArray(ONTOS_COMMON_ENGLISH_SAMEAS);
for (int i = 0; i < sameAsIds.length(); i++) {
String uri = sameAsIds.getString(i);
sameAs.add(uri);
// If there is a proper link, then we add it.
if (uri.startsWith(SpotlightConfiguration.DEFAULT_NAMESPACE))
dbpediaSameAs = new DBpediaResource(uri.replace(SpotlightConfiguration.DEFAULT_NAMESPACE, ""));
}
} catch (JSONException e) {
LOG.error(e.getMessage());
}