Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1.  public String extractEntities(String type) {
  2.         AnnotationSet all = document.getAnnotations();
  3.         AnnotationSet Entity = all.get(type);
  4.         OffsetComparator comp = new OffsetComparator();
  5.  
  6.         ArrayList<Annotation> ListEn = new ArrayList(Entity);
  7.         Collections.sort(ListEn, comp);
  8.  
  9.         Annotation Ent;
  10.         String StringEntity = "\n-------" + type + "---------\n";
  11.         String WordEntity = "";
  12.         Long start, end;
  13.  
  14.         String docContent = document.getContent().toString();
  15.  
  16.         ArrayList<String> ListStrings = new ArrayList(); //Array de Strings que usaremos para no vovler a imprimir un premio que ya haya sido imprimido.
  17.  
  18.         for (int i = 0; i < ListEn.size(); i++) {
  19.             Ent = ListEn.get(i);
  20.  
  21.             start = Ent.getStartNode().getOffset();
  22.             end = Ent.getEndNode().getOffset();
  23.             WordEntity = docContent.substring(start.intValue(), end.intValue());
  24.  
  25.             if (!ListStrings.contains(WordEntity)) {//Si no esta en la lista lo imprimimos
  26.                 //StringEntity = StringEntity + WordEntity + "\n";
  27.                 ListStrings.add(WordEntity);
  28.             }
  29.  
  30.         }
  31.  
  32.         Collections.sort(ListStrings);
  33.         for (int j = 0; j < ListStrings.size(); j++) {
  34.             StringEntity = StringEntity + ListStrings.get(j) + "\n";
  35.         }
  36.  
  37.         return StringEntity;
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement