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; }
/** * If there are attribute constraints, filter the set. */ protected Collection<Annotation> filterMatches(AnnotationSet containedSet) { if (containedSet == null) return Collections.emptySet(); if (valueConstraint == null || containedSet.isEmpty()) { return containedSet; } else { return valueConstraint.matches(containedSet, null, containedSet); } }
/** Process a single document. */ public void transduce(Document doc, AnnotationSet inputAS, AnnotationSet outputAS) throws JapeException, ExecutionException { // no need to transduce empty document if(inputAS == null || inputAS.isEmpty()) return; transducer.setActionContext(actionContext); transducer.transduce(doc, inputAS, outputAS); } // transduce(doc)
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
if (this.defaultAnnotations == null || this.defaultAnnotations.isEmpty()) { Err.prln("Coref Warning: No annotations found for processing!"); return;
if((allAnnots == null) || allAnnots.isEmpty()) { Out.prln("Gazetteer Lists Collector Warning: No annotations found for processing"); return; if(annots == null || annots.isEmpty()) continue; statsPerType.put(annotationTypes.get(i), new HashMap<String, Integer>()); collectLists(annots, annotationTypes.get(i));
@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
nameAllAnnots.get(null, fNames); if (allMatchesAnnots == null || allMatchesAnnots.isEmpty()) return;
if ((allAnnots == null) || allAnnots.isEmpty()) { Out.prln("DumpingPR Warning: No annotations found for export. " + "Including only those from the Original markups set.");
queryFM.put("majorType", "title"); 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());
if(bodyAnnotations == null || bodyAnnotations.isEmpty()) {
Phase: Verb Input: Token Options: control = appelt Macro:VERB ( ({Token.category==VBD}|{Token.category==VBG}|{Token.category==VBN}|{Token.category==VBP}|{Token.category==VB}|{Token.category==VBZ}) ) Rule:Verb ( (VERB) ):verb --> { AnnotationSet set = (AnnotationSet) bindings.get("verb"); Node startNode = set.firstNode(); Node stopNode = set.lastNode(); AnnotationSet innerAnnotations = outputAS.get(startNode.getOffset(), stopNode.getOffset()).get("Inner_Pred"); if (innerAnnotations == null || innerAnnotations.isEmpty()) { outputAS.add(startNode, stopNode, "Outer_Pred", Factory.newFeatureMap()); } }
List<Annotation> newAnnots = new ArrayList<Annotation>(); AnnotationSet addedSet = doc.getAnnotations(ADDEDSET); if (addedSet != null && !addedSet.isEmpty()) { Iterator<Annotation> addedIter = addedSet.iterator(); while (addedIter.hasNext()) { if (removedSet != null && ! removedSet.isEmpty()) { targetAS.removeAll(removedSet); removedSet.clear();
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
if((nameAnnots == null) || nameAnnots.isEmpty()) return cdg; Iterator<Annotation> iter = nameAnnots.iterator(); while(iter.hasNext()) {