/** 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)
outputAS.add(0L, document.getContent().size(), SENTENCE_ANNOTATION_TYPE, Factory.newFeatureMap()); }catch(InvalidOffsetException ioe){ if(remainingTokens != null && !remainingTokens.isEmpty()){ try{ outputAS.add(remainingTokens.firstNode().getOffset(), remainingTokens.lastNode().getOffset(), SENTENCE_ANNOTATION_TYPE,
Imports: { import static gate.Utils.*; } Phase: SetPerPage Input: Age X Y // and whatever other annotation types you want to copy Options: control = all Rule: MoveToPageSet ({Age}|{X}|{Y}):entity --> :entity { try { for(Annotation e : entityAnnots) { // find the (only) Page annotation that covers this entity Annotation thePage = getOnlyAnn(getCoveringAnnotations(inputAS, e, "Page")); // get the corresponding annotation set AnnotationSet pageSet = doc.getAnnotations( (String)thePage.getFeatures().get("id")); // and copy the annotation into it pageSet.add(start(e), end(e), e.getType(), e.getFeatures()); } } catch(InvalidOffsetException e) { throw new JapeException("Invalid offset from existing annotation", e); } // optionally remove from input set // inputAS.removeAll(entityAnnots); }
private void addToOriginal(AnnotationSet original, long originalStart, long originalEnd, long tempStart, long tempEnd, Annotation tempLookup, Document tempDoc) throws ExecutionException { try { original.add(originalStart, originalEnd, tempLookup.getType(), tempLookup.getFeatures()); } catch(InvalidOffsetException ioe) { String errorDetails = String.format("temp %d, %d [%s]-> original %d, %d ", tempStart, tempEnd, Utils.stringFor(tempDoc, tempLookup), originalStart, originalEnd); throw new ExecutionException(errorDetails, ioe); } }
annotationSet.add(Long.valueOf(i), Long.valueOf(documentPosition), "Lookup", featuremap); } catch(InvalidOffsetException invalidoffsetexception) {
outputAS.add(Long.valueOf(nextMatch.start()), Long.valueOf(nextMatch.end()), "Split", features); outputAS.add(Long.valueOf(lastSentenceEnd), Long.valueOf(endOffset), ANNIEConstants.SENTENCE_ANNOTATION_TYPE, Factory.newFeatureMap()); outputAS.add(Long.valueOf(nextMatch.start()), Long.valueOf(nextMatch.end()), "Split", features); outputAS.add(Long.valueOf(lastSentenceEnd), Long.valueOf(endOffset), ANNIEConstants.SENTENCE_ANNOTATION_TYPE, Factory.newFeatureMap());
newID = nameAllAnnots.add( unknown.getStartNode().getOffset(), unknown.getStartNode().getOffset() + stringEnd,
Integer unknId = unknownIter.next(); Annotation unknown = nameAllAnnots.get(unknId); Integer newID = nameAllAnnots.add( unknown.getStartNode(), unknown.getEndNode(),
Integer Id = theSet.add(lStart, lEnd, type, attribs); this.annot = theSet.get(Id); created = true;
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
try { Integer permId = targetAS.add(annot.getStartNode().getOffset(), annot.getEndNode().getOffset(), annot.getType(),
annotationSet.add(matchedRegionStart, matchedRegionEnd + 1,
antecedent.getStartNode().getOffset()); Integer annID = outputSet.add(anaphor.getStartNode(), anaphor.getEndNode(), antecedent.getType(),
annotationSet.add(new Long(tokenStart), new Long(charIdx), "DEFAULT_TOKEN", newTokenFm); annotationSet.add(new Long(tokenStart), new Long(charIdx), lastMatchingState.getTokenDesc()[0][0], newTokenFm); annotationSet.add(new Long(tokenStart), new Long(charIdx), lastMatchingState.getTokenDesc()[0][0], newTokenFm);
private void transferAnnotations(List<Annotation> toTransfer, AnnotationSet to, boolean newID) throws ExecutionException { for(Annotation annot : toTransfer) { Mapping m = mappings.get(annot.getType()); String name = (m == null || m.newName == null ? annot.getType() : m.newName); try { FeatureMap params = Factory.newFeatureMap(); params.putAll(annot.getFeatures()); if(newID) { to.add(annot.getStartNode().getOffset(), annot.getEndNode() .getOffset(), name, params); } else { to.add(annot.getId(), annot.getStartNode().getOffset(), annot .getEndNode().getOffset(), name, params); } } catch(InvalidOffsetException e) { throw new ExecutionException(e); } } }
features.put(featureName, featureValue); try { outputAS.add(start, end, outputAnnotationType, features); } catch(Exception e) { throw new GateRuntimeException("Invalid Offsets"); features.put(featureName, featureValue); try { outputAS.add(start, end, outputAnnotationType, features); } catch(Exception e) { throw new GateRuntimeException("Invalid Offsets");
outputAS.add(annot.getStart(), annot.getEnd(), annot.getType(), features);
matches.add(outputSet.add(anaphor.getStartNode(), anaphor.getEndNode(), antecedent.getType(), features));
inputAS.add(a.getStartNode().getOffset(), a.getEndNode() .getOffset(), "CannotBeAMeasurement", empty); } catch(Exception e) {
tempDoc.getAnnotations(wrappedInputASName).add(mapping.getTempStartOffset(), mapping.getTempEndOffset(), "Input", Factory.newFeatureMap());