Examples of DBpediaResource


Examples of org.dbpedia.spotlight.model.DBpediaResource

   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());
       }
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

                surfaceForm="";
                wikiUrl=linkElement.getAttributeValue("href");
                if (wikiUrl!=null)
                    if (wikiUrl.startsWith(wikiPrefix)) {
                        surfaceForm = linkElement.getContent().getTextExtractor().toString();
                        entities.add(new DBpediaResource(wikiUrl.replaceAll(wikiPrefix,"")));
                        //System.out.println(surfaceForm+" "+wikiUrl);
                    }
            }
        }
        LOG.trace(entities);
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

    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);
            }
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

                if (n.getNodeType()!=Node.TEXT_NODE) {
                    value = n.getFirstChild().getNodeValue();
                    //LOG.trace(String.format("Name:%s, Value: %s", name, value));
                }
                if (name.equals("title")) {
                    entities.add(new DBpediaResource(value)); //TODO could have actually gotten DBpediaResourceOccurrences and set the relevance from weight param
                }
            }
        }
        LOG.debug(String.format("Extracted: %s",entities));
        return entities;
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

        if (dbpediaType == null || dbpediaType.equals("NO_MATCH")) {
          continue;
        }

        dBpediaTypes.add(new DBpediaType(dbpediaType));
        DBpediaResource dBpediaResource = new DBpediaResource(dbpediaLink, 0);

        if (!dbpediaType.equals("http://www.w3.org/2002/07/owl#Thing")) {
          dBpediaResource.setTypes(dBpediaTypes);
        }

        extractedResources.add(dBpediaResource);
      } catch (JSONException e) {
       
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

    if(requestData.length() == 0)
      return dbpediaResources;

    for(int i = 0; i < requestData.length(); i++) {
      try {
        DBpediaResource dBpediaResource
            = new DBpediaResource(requestData.getJSONObject(i).getString("uri").replace("dbpedia:", ""));
        dbpediaResources.add(dBpediaResource);
      } catch (JSONException e) {
        LOG.error("Error parsing JSON.");
                e.printStackTrace();
      }
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

        String[] fields = {LuceneManager.DBpediaResourceField.URI.toString()};
        // search index for surface form, iterate through the results
        for (ScoreDoc hit : getHits(q,100)) {  //TODO Attention: study impact of topResultsLimit
            int docNo = hit.doc;
            //DBpediaResource resource = getDBpediaResource(docNo, fields);
            DBpediaResource resource = getCachedDBpediaResource(docNo);
            candidates.add(resource);
        }

        LOG.debug("Candidates for "+sf+"("+candidates.size()+"): "+candidates);
        if (candidates.size()==0) LOG.debug(String.format("Used index:"+mLucene.mContextIndexDir));
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

            return o1.getValue().compareTo(o2.getValue());
        }
    }

    public DBpediaResource maxCount(Map<DBpediaResource,Integer> countForResource) {
        DBpediaResource chosen = Collections.max((Collection<Map.Entry<DBpediaResource,Integer>>) countForResource.entrySet(),
                                                  new IntValueComparator())
                                     .getKey();
        return chosen;
    }
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

                                     .getKey();
        return chosen;
    }

    public DBpediaResource maxAvg(Map<DBpediaResource,Double> avgForResource) {
        DBpediaResource chosen = Collections.max((Collection<Map.Entry<DBpediaResource,Double>>) avgForResource.entrySet(),
                                                  new DoubleValueComparator())
                                     .getKey();
        return chosen;
    }
View Full Code Here

Examples of org.dbpedia.spotlight.model.DBpediaResource

        public DBpediaResource choose(ScoreDoc[] hits) throws SearchException {
            Map<DBpediaResource,Integer> countForResource = new HashMap<DBpediaResource,Integer>();
            // Iterate through the results:
            for (ScoreDoc hit : hits) {
                DBpediaResource r = this.searcher.getDBpediaResource(hit.doc);
                if (countForResource.containsKey(r)) {
                    countForResource.put(r, countForResource.get(r)+1);
                } else {
                    countForResource.put(r, 1);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.