/** * This method specifies whether a given annotation overlaps any of a * set of annotations. For instance, JobTitles occasionally are * part of Person annotations. * */ private boolean overlapsAnnotations(Annotation a, AnnotationSet annotations) { Iterator<Annotation> iter = annotations.iterator(); while (iter.hasNext()) { Annotation current = iter.next(); if (a.overlaps(current)) { return true; } } return false; }
FeatureMap features = gateDoc.getFeatures(); String originalContent = (String) features.get(GateConstants.ORIGINAL_DOCUMENT_CONTENT_FEATURE_NAME); int length = originalContent.length(); TextualDocumentFormat tdf = new TextualDocumentFormat(); try { tdf.annotateParagraphs(gateDoc,0, length,null); } catch (DocumentFormatException e) { e.printStackTrace(); } AnnotationSet paragraphs = gateDoc.getAnnotations().get("paragraph"); Iterator it = paragraphs.iterator(); Annotation currAnnot; SortedAnnotationList sortedParagraphs = new SortedAnnotationList(); while (it.hasNext()) { currAnnot = (Annotation) it.next(); sortedParagraphs.addSortedExclusive(currAnnot); } // while StringBuffer editableContent = new StringBuffer(originalContent); System.out.println("Number of Paragraphs - "+paragraphs.size()); for(Annotation paragraph:paragraphs){ long start = paragraph.getStartNode().getOffset().longValue(); long end = paragraph.getEndNode().getOffset().longValue(); String paraText=editableContent.substring((int) start, (int) end); System.out.println(paraText); }
@SuppressWarnings("unchecked") protected void docCleanup() { Object matchesValue = document.getFeatures().get(DOCUMENT_COREF_FEATURE_NAME); if (matchesValue != null && (matchesValue instanceof Map)) ((Map<String,List<List<Integer>>>)matchesValue).remove(nameAllAnnots.getName()); else if (matchesValue != null) { document.getFeatures().put(DOCUMENT_COREF_FEATURE_NAME, new HashMap<String,List<List<Integer>>>()); } //get all annotations that have a matches feature HashSet<String> fNames = new HashSet<String>(); fNames.add(ANNOTATION_COREF_FEATURE_NAME); AnnotationSet annots = nameAllAnnots.get(null, fNames); // Out.prln("Annots to cleanup" + annots); if (annots == null || annots.isEmpty()) return; Iterator<Annotation> iter = annots.iterator(); while (iter.hasNext()) { while (iter.hasNext()) iter.next().getFeatures().remove(ANNOTATION_COREF_FEATURE_NAME); } //while }//cleanup
AnnotationSet persons = currSentence.getPersons(); Iterator<Annotation> it = persons.iterator(); while (it.hasNext()) { Annotation currPerson = it.next();
AnnotationSet persons = currSentence.getPersons(); Iterator<Annotation> it = persons.iterator(); while (it.hasNext()) { Annotation currPerson = it.next();
protected void collectLists(AnnotationSet annots, String annotType) { Iterator<Annotation> iter = annots.iterator(); String listName = ""; GazetteerList theList = null;
Annotation ann=null; Iterator<Annotation> iter = nameAllAnnots.iterator();
Iterator<Annotation> bodyIter = bodyAnnotations.iterator(); while(bodyIter.hasNext()) { Annotation bodyAnn = bodyIter.next();
if (nameAllTokens.isEmpty()) return; Iterator<Annotation> iter = unknownAnnots.iterator();
Iterator<Annotation> it = pronouns.iterator(); while (it.hasNext()) { Annotation currPronoun = it.next();
protected AnnotationSet renameAnnotations(AnnotationSet annots2Export, Map<String,String> renameMap){ Iterator<Annotation> iter = annots2Export.iterator(); AnnotationSet as = document.getAnnotations(DUMPING_PR_SET); if (!as.isEmpty()) as.clear(); while(iter.hasNext()) { Annotation annot = iter.next(); //first check whether this type needs to be renamed //if not, continue if (!renameMap.containsKey(annot.getType())) renameMap.put(annot.getType(), annot.getType()); try{ as.add(annot.getId(), annot.getStartNode().getOffset(), annot.getEndNode().getOffset(), renameMap.get(annot.getType()), annot.getFeatures()); } catch (InvalidOffsetException ex) { throw new GateRuntimeException("DumpingPR: " + ex.getMessage()); } }//while return as; }//renameAnnotations
AnnotationSet addedSet = doc.getAnnotations(ADDEDSET); if (addedSet != null && !addedSet.isEmpty()) { Iterator<Annotation> addedIter = addedSet.iterator(); while (addedIter.hasNext()) { Annotation annot = addedIter.next();
if(defaultAnnotSet==null) return null; it = defaultAnnotSet.iterator(); while(it.hasNext()){ curAnnotation=(Annotation)it.next();
nameAllAnnots.get(OrthoMatcher.LOOKUP_ANNOTATION_TYPE, tempMap); if((nameAnnots == null) || nameAnnots.isEmpty()) return cdg; Iterator<Annotation> iter = nameAnnots.iterator(); while(iter.hasNext()) { Annotation annot = iter.next();
it = defaultAnnotSet.iterator(); if(it==null) return null;
Annotation annot = existing.iterator().next(); annot.getFeatures().putAll(features); matches.add(annot.getId());
Iterator<Annotation> itPersons = sentPersons.iterator(); while (itPersons.hasNext()) { Annotation currPerson = itPersons.next();
Iterator<Annotation> tokensIter = tokens.iterator();