if (this.defaultAnnotations == null || this.defaultAnnotations.isEmpty()) { Err.prln("Coref Warning: No annotations found for processing!"); return; AnnotationSet qtSet = this.defaultAnnotations.get(QUOTED_TEXT_TYPE); if (qtSet != null && !qtSet.isEmpty()) { this.defaultAnnotations.removeAll(qtSet); AnnotationSet pleonSet = this.defaultAnnotations.get(PLEONASTIC_TYPE); if (pleonSet != null && !pleonSet.isEmpty()) { this.defaultAnnotations.removeAll(pleonSet); AnnotationSet sentenceAnnotations = this.defaultAnnotations.get(SENTENCE_ANNOTATION_TYPE); this.textSentences = new Sentence[sentenceAnnotations.size()]; Annotation[] sentenceArray = sentenceAnnotations.toArray(new Annotation[sentenceAnnotations.size()]); Arrays.sort(sentenceArray,ANNOTATION_OFFSET_COMPARATOR); AnnotationSet tempASOffsets = this.defaultAnnotations.getContained( sentStartOffset,sentEndOffset); AnnotationSet sentPersons = tempASOffsets.get(PERSON_ANNOTATION_TYPE); AnnotationSet sentInans = tempASOffsets.get(this.inanimatedSet); Iterator<Annotation> itPersons = sentPersons.iterator(); while (itPersons.hasNext()) { Annotation currPerson = itPersons.next();
/** Store the annotation in the deleted list so it can retrieved later */ public void removeAnnotation(Document doc) { if (this.annot == null || doc == null) return; doc.getAnnotations(REMOVEDSET).add(this.annot); this.annot = null; }// public void removeAnnotation(Document doc)
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
private boolean coveredByInput(long tempStart, long tempEnd, AnnotationSet tempInputAS) { if (tempInputAS.getCovering(wrappedInputASName, tempStart, tempStart).isEmpty()) { return false; } // implied else if (tempInputAS.getCovering(wrappedInputASName, tempEnd, tempEnd).isEmpty()) { return false; } // implied else return true; }
private void removeSubSet(AnnotationSet theSet, Map<String,List<List<Integer>>> matchMap) { AnnotationSet toRemove = theSet.get(new HashSet<String>(annotationTypes)); if (toRemove == null || toRemove.isEmpty()) return; theSet.removeAll(toRemove); removeAnnotationsFromCorefData(toRemove, theSet.getName(), matchMap); }//removeSubSet
Rule:PojemId ( {PojemD} ):pojem --> { AnnotationSet matchedAnns = bindings.get("pojem"); Annotation ann = matchedAnns.get("PojemD").iterator().next(); FeatureMap pojemFeatures = ann.getFeatures(); gate.FeatureMap features = Factory.newFeatureMap(); features.putAll(pojemFeatures); features.put("annId", ann.getId()); inputAS.remove(ann); Integer id = outputAS.add(matchedAnns.firstNode(), matchedAnns.lastNode(), "PojemD", features); features.put("id", id); }
@SuppressWarnings("unchecked") private JButton processChildrenAnnots(Annotation annot, Map<Integer, JButton> processed) { selection.clear(); Vector<JButton> childrenButtons = new Vector<JButton>(); java.util.List<Integer> children = (java.util.List<Integer>) annot.getFeatures().get(NODE_CONSISTS_FEATURE_NAME); for (Iterator<Integer> i = children.iterator(); i.hasNext(); ) { Integer childId = i.next(); Annotation child = treeAnnotations.get(childId); JButton childButton; if (processed.containsKey(child.getId())) childButton = processed.get(child.getId()); else childButton = processChildrenAnnots(child, processed); childrenButtons.add(childButton); } selection = (Vector<JButton>) childrenButtons.clone(); STreeNode parent = createParentNode( (String) annot.getFeatures().get(NODE_CAT_FEATURE_NAME), annot); nonTerminals.put(parent.getID(), parent); JButton parentButton = createCentralButton(parent); addLines(parent); processed.put(annot.getId(), parentButton); selection.clear(); return parentButton; }// private JButton processChildrenAnnots
List<Annotation> newAnnots = new ArrayList<Annotation>(); AnnotationSet addedSet = doc.getAnnotations(ADDEDSET); if (addedSet != null && !addedSet.isEmpty()) { Iterator<Annotation> addedIter = addedSet.iterator(); while (addedIter.hasNext()) { Annotation annot = addedIter.next(); try { Integer permId = targetAS.add(annot.getStartNode().getOffset(), annot.getEndNode().getOffset(), annot.getType(), annot.getFeatures()); tempId2permId.put(annot.getId(), permId); newAnnots.add(targetAS.get(permId)); } catch (InvalidOffsetException ex) { Out.println("Invalid annotation offsets: " addedSet.clear(); if (removedSet != null && ! removedSet.isEmpty()) { targetAS.removeAll(removedSet); removedSet.clear();
protected void matchUnknown(ArrayList<Annotation> sortedAnnotationsForAType) throws ExecutionException { AnnotationSet unknownAnnots = nameAllAnnots.get(unknownType); annots2Remove.clear(); if (unknownAnnots.isEmpty()) return; AnnotationSet nameAllTokens = nameAllAnnots.get(TOKEN_ANNOTATION_TYPE); if (nameAllTokens.isEmpty()) return; Iterator<Annotation> iter = unknownAnnots.iterator(); List<Annotation> tokens = new ArrayList<Annotation>(nameAllTokens.getContained( unknown.getStartNode().getOffset(), unknown.getEndNode().getOffset() while (unknownIter.hasNext()) { Integer unknId = unknownIter.next(); Annotation unknown = nameAllAnnots.get(unknId); Integer newID = nameAllAnnots.add( unknown.getStartNode(), unknown.getEndNode(), unknown.getFeatures() ); nameAllAnnots.remove(unknown);
document.getAnnotations() : document.getAnnotations(outputASName); AnnotationSet annotations = outputAS.get(outputAnnotationType); if(annotations == null || annotations.size() == 0) { outputAS.add(start, end, outputAnnotationType, features); } catch(Exception e) { throw new GateRuntimeException("Invalid Offsets"); List<Annotation> tempList = new ArrayList<Annotation>(annotations.get()); boolean found = false; for(int i=0;i<tempList.size();i++) { features.put(featureName, featureValue); try { outputAS.add(start, end, outputAnnotationType, features); } catch(Exception e) { throw new GateRuntimeException("Invalid Offsets");
AnnotationSet existing = outputSet.get(antecedent.getType(), anaphor .getStartNode().getOffset(), anaphor.getEndNode().getOffset()); if(existing.size() > 0) { Annotation annot = existing.iterator().next(); annot.getFeatures().putAll(features); matches.add(annot.getId()); matches.add(outputSet.add(anaphor.getStartNode(), anaphor.getEndNode(), antecedent.getType(), features));
outputAS.addAll(inputAS.get(SENTENCE_ANNOTATION_TYPE)); AnnotationSet sentences = outputAS.get(SENTENCE_ANNOTATION_TYPE); if(sentences == null || sentences.isEmpty()){ outputAS.add(0L, document.getContent().size(), SENTENCE_ANNOTATION_TYPE, Factory.newFeatureMap()); }catch(InvalidOffsetException ioe){ Long endSentences = sentences.lastNode().getOffset(); AnnotationSet remainingTokens = inputAS.get(TOKEN_ANNOTATION_TYPE, endSentences, inputAS.lastNode().getOffset()); if(remainingTokens != null && !remainingTokens.isEmpty()){ try{ outputAS.add(remainingTokens.firstNode().getOffset(), remainingTokens.lastNode().getOffset(), SENTENCE_ANNOTATION_TYPE, Factory.newFeatureMap());
if((allAnnots == null) || allAnnots.isEmpty()) { Out.prln("Gazetteer Lists Collector Warning: No annotations found for processing"); return; AnnotationSet annots = allAnnots.get(annotationTypes.get(i)); if(annots == null || annots.isEmpty()) continue; statsPerType.put(annotationTypes.get(i), new HashMap<String, Integer>()); collectLists(annots, annotationTypes.get(i));
@Override protected Annotation[] getAnnotsToProcess(GATEDocument gateDocument) throws IndexException { Document document = gateDocument.getDocument(); Annotation[] semanticAnnots; AnnotationSet semAnnSet = (indexConfig.getSemanticAnnotationSetName() == null || indexConfig.getSemanticAnnotationSetName().length() == 0) ? document.getAnnotations() : document.getAnnotations(indexConfig.getSemanticAnnotationSetName()); if(semAnnSet.size() > 0){ AnnotationSet semAnns = null; synchronized(semAnnSet) { semAnns = semAnnSet.get(annotationHelpers.keySet()); } semanticAnnots = semAnns.toArray(new Annotation[semAnns.size()]); Arrays.sort(semanticAnnots, offsetComparator); } else { semanticAnnots = new Annotation[0]; } return semanticAnnots; }
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(); Long offsetEndAnnot = annot.getEndNode().getOffset(); try { gate.Document doc = nameAllAnnots.getDocument(); String annotString = doc.getContent().getContent(offsetStartAnnot, offsetEndAnnot)
@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 as1 = nameAllAnnots.getContained(startAnnot, endAnnot); if(as1 == null || as1.isEmpty()) return annotString; AnnotationSet as = as1.get("Lookup", queryFM); if(as != null && !as.isEmpty()) { List<Annotation> titles = new ArrayList<Annotation>(as); Collections.sort(titles, new gate.util.OffsetComparator());