Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String extractEntities(String type) {
- AnnotationSet all = document.getAnnotations();
- AnnotationSet Entity = all.get(type);
- OffsetComparator comp = new OffsetComparator();
- ArrayList<Annotation> ListEn = new ArrayList(Entity);
- Collections.sort(ListEn, comp);
- Annotation Ent;
- String StringEntity = "\n-------" + type + "---------\n";
- String WordEntity = "";
- Long start, end;
- String docContent = document.getContent().toString();
- ArrayList<String> ListStrings = new ArrayList(); //Array de Strings que usaremos para no vovler a imprimir un premio que ya haya sido imprimido.
- for (int i = 0; i < ListEn.size(); i++) {
- Ent = ListEn.get(i);
- start = Ent.getStartNode().getOffset();
- end = Ent.getEndNode().getOffset();
- WordEntity = docContent.substring(start.intValue(), end.intValue());
- if (!ListStrings.contains(WordEntity)) {//Si no esta en la lista lo imprimimos
- //StringEntity = StringEntity + WordEntity + "\n";
- ListStrings.add(WordEntity);
- }
- }
- Collections.sort(ListStrings);
- for (int j = 0; j < ListStrings.size(); j++) {
- StringEntity = StringEntity + ListStrings.get(j) + "\n";
- }
- return StringEntity;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement