Package org.apache.uima.alchemy.ts.entity

Examples of org.apache.uima.alchemy.ts.entity.BaseEntity


  public void process(JCas cas, Results results) throws Exception {
    for (Entity entity : ((EntitiesResults) results).getEntities().getEntities()) {

      // get feature structure for the entity
      BaseEntity fs = getFeatureStructure(entity.getType(), cas);

      if (fs != null) {

        Type type = fs.getType();

        /* set each FS feature value */
        fs.setFeatureValueFromString(type.getFeatureByBaseName("count"), entity.getCount()); // count
        fs.setFeatureValueFromString(type.getFeatureByBaseName("text"), entity.getText()); // text
        fs.setFeatureValueFromString(type.getFeatureByBaseName("relevance"), entity.getRelevance()); // relevance
        if (entity.getDisambiguated() != null) {
          fs.setFeatureValueFromString(type.getFeatureByBaseName("disambiguation"), entity
                  .getDisambiguated().getName()); // disambiguation name
          fs.setFeatureValueFromString(type.getFeatureByBaseName("dbpedia"), entity
                  .getDisambiguated().getDbpedia()); // dbpedia
          fs.setFeatureValueFromString(type.getFeatureByBaseName("website"), entity
                  .getDisambiguated().getWebsite()); // website
          fs.setFeatureValueFromString(type.getFeatureByBaseName("subType"), entity
                  .getDisambiguated().getSubType()); // subtype
          fs.setFeatureValueFromString(type.getFeatureByBaseName("geo"), entity.getDisambiguated()
                  .getGeo()); // geo
          fs.setFeatureValueFromString(type.getFeatureByBaseName("opencyc"), entity
                  .getDisambiguated().getOpencyc()); // opencyc
          fs.setFeatureValueFromString(type.getFeatureByBaseName("yago"), entity.getDisambiguated()
                  .getYago()); // yago
          fs.setFeatureValueFromString(type.getFeatureByBaseName("umbel"), entity
                  .getDisambiguated().getUmbel()); // umbel
          fs.setFeatureValueFromString(type.getFeatureByBaseName("freebase"), entity
                  .getDisambiguated().getFreebase()); // freebase
          fs.setFeatureValueFromString(type.getFeatureByBaseName("ciaFactbook"), entity
                  .getDisambiguated().getCiaFactbook()); // ciaFactbook
          fs.setFeatureValueFromString(type.getFeatureByBaseName("census"), entity
                  .getDisambiguated().getCensus()); // census
          fs.setFeatureValueFromString(type.getFeatureByBaseName("geonames"), entity
                  .getDisambiguated().getGeonames()); // geonames
          fs.setFeatureValueFromString(type.getFeatureByBaseName("musicBrainz"), entity
                  .getDisambiguated().getMusicBrainz()); // musicBrainz
        }
        if (entity.getQuotations() != null && entity.getQuotations().getQuotations() != null
                && entity.getQuotations().getQuotations().size() > 0) {
          StringArray quotationsFeatureStructure = new StringArray(cas, entity.getQuotations()
                  .getQuotations().size());
          int i = 0;
          for (String quotation : entity.getQuotations().getQuotations()) {
            quotationsFeatureStructure.set(i, quotation);
            i++;
          }
          fs.setFeatureValue(type.getFeatureByBaseName("quotations"), quotationsFeatureStructure);
        }
        if (entity.getSentiment() != null) {
          SentimentFS sentimentFS = new SentimentFS(cas);
          sentimentFS.setScore(entity.getSentiment().getScore());
          sentimentFS.setSentimentType(entity.getSentiment().getType());
          sentimentFS.addToIndexes();
          fs.setFeatureValue(type.getFeatureByBaseName("sentiment"), sentimentFS);
        }
        cas.addFsToIndexes(fs);
        /* build annotations on this fs */
        buildAnnotations(cas, fs);
      }
View Full Code Here


    }

  }

  private BaseEntity getFeatureStructure(String type, JCas aJCas) {
    BaseEntity fsObject = null;
    String typeName = new StringBuilder(ENTITY_PACKAGE_NAME).append(type).toString();
    Class<?> typeClass = getClassFromName(typeName);
    if (typeClass != null) {
      try {
        /* use reflection to build a BaseEntity object */
 
View Full Code Here

TOP

Related Classes of org.apache.uima.alchemy.ts.entity.BaseEntity

Copyright © 2018 www.massapicom. 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.