public boolean hasNext() { if (AnnotationComboIterator.this.nextLowerChecked) { return AnnotationComboIterator.this.nextLowerAvailable; } AnnotationComboIterator.this.nextLowerChecked = true; AnnotationComboIterator.this.nextLowerAvailable = false; if (AnnotationComboIterator.this.lowerIt.isValid()) { AnnotationFS lowerFS = AnnotationComboIterator.this.lowerIt.get(); int lowerBegin = lowerFS.getBegin(); while (lowerBegin < AnnotationComboIterator.this.upperBegin) { AnnotationComboIterator.this.lowerIt.moveToNext(); if (AnnotationComboIterator.this.lowerIt.isValid()) { lowerFS = AnnotationComboIterator.this.lowerIt.get(); lowerBegin = lowerFS.getBegin(); } else { return false; } } if (AnnotationComboIterator.this.upperEnd >= lowerFS.getEnd()) { AnnotationComboIterator.this.nextLowerAvailable = true; } } return AnnotationComboIterator.this.nextLowerAvailable; }
/** * @see ListIterator#hasPrevious() */ public boolean hasPrevious() { return this.back.isValid(); }
/** * @see ListIterator#hasNext() */ public boolean hasNext() { return this.forward.isValid(); }
@Override public boolean isValid() { return currentIt.isValid(); }
/** * Create a new combo iterator. * * @param cas * The CAS we're operating on. * @param upper * The type of the upper iterator, e.g., sentence. * @param lower * The type of the lower iterator, e.g., token. */ public AnnotationComboIterator(CAS cas, Type upper, Type lower) { this.upperIt = cas.getAnnotationIndex(upper).iterator(); this.lowerIt = cas.getAnnotationIndex(lower).iterator(); this.upperIt.moveToFirst(); this.lowerIt.moveToFirst(); if (this.upperIt.isValid()) { final AnnotationFS upperFS = this.upperIt.get(); this.upperBegin = upperFS.getBegin(); this.upperEnd = upperFS.getEnd(); } else { this.nextLowerChecked = true; } }
public void moveToLast() { // See comments on moveToFirst() this.iteratorIndex = this.iterators.size() - 1; while (this.iteratorIndex >= 0) { FSIterator<T> it = this.iterators.get(this.iteratorIndex); it.moveToLast(); if (it.isValid()) { return; } --this.iteratorIndex; } }
/** * @see org.apache.uima.cas.FSIterator#isValid() */ public boolean isValid() { if (nonFlatIterator.isValid() != flatIterator.isValid()) { error(String.format("IndexIsUpdateFree=%s, %s, valid for reg iter is %s, valid for flat it2 is %s%n it1 = %s%nit2 = %s%n", flatIterator.isUpdateFreeSinceLastCounterReset(), flatIterator.idInfo(), nonFlatIterator.isValid(), flatIterator.isValid(), nonFlatIterator, flatIterator)); } return this.nonFlatIterator.isValid(); }
public RutaBasic getFirstBasicInWindow(AnnotationFS windowAnnotation, FSIterator<AnnotationFS> it) { if (windowAnnotation instanceof RutaBasic) { return (RutaBasic) windowAnnotation; } it.moveTo(windowAnnotation); if (it.isValid()) { return (RutaBasic) it.get(); } return null; }
public TextMarkerBasic getFirstBasicInWindow(AnnotationFS windowAnnotation, FSIterator<AnnotationFS> it) { if (windowAnnotation instanceof TextMarkerBasic) { return (TextMarkerBasic) windowAnnotation; } it.moveTo(windowAnnotation); if (it.isValid()) { return (TextMarkerBasic) it.get(); } return null; }
public static <FST extends FeatureStructure> void fill(FSIterator<FST> srcIter, Collection<FST> destCol) { srcIter.moveToFirst(); while (srcIter.isValid()) { destCol.add(srcIter.get()); srcIter.moveToNext(); } }
public List<AnnotationFS> getAllofType(Type type) { List<AnnotationFS> result = new ArrayList<AnnotationFS>(); FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(type).iterator(); while (iterator.isValid()) { FeatureStructure featureStructure = iterator.get(); result.add((AnnotationFS) featureStructure); iterator.moveToNext(); } return result; }
public List<AnnotationFS> getAllofType(Type type) { List<AnnotationFS> result = new ArrayList<AnnotationFS>(); FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(type).iterator(); while (iterator.isValid()) { FeatureStructure featureStructure = iterator.get(); result.add((AnnotationFS) featureStructure); iterator.moveToNext(); } return result; }
private void adjustForConstraintForward() { // If the iterator is valid, but doesn't match the constraint, advance. while (this.it.isValid() && !this.cons.match(this.it.get())) { this.it.moveToNext(); } }
private void adjustForConstraintBackward() { // If the iterator is valid, but doesn't match the constraint, advance. while (this.it.isValid() && !this.cons.match(this.it.get())) { this.it.moveToPrevious(); } }
public TextMarkerBasic getNextBasic2(AnnotationFS previous) { AnnotationFS pointer = cas .createAnnotation(basicType, previous.getEnd() - 1, previous.getEnd()); currentIt.moveTo(pointer); if (currentIt.isValid()) { TextMarkerBasic basic = (TextMarkerBasic) currentIt.get(); return basic; } return null; }
public RutaBasic getNextBasic2(AnnotationFS previous) { AnnotationFS pointer = cas.createAnnotation(basicType, previous.getEnd() - 1, previous.getEnd()); currentIt.moveTo(pointer); if (currentIt.isValid()) { RutaBasic basic = (RutaBasic) currentIt.get(); return basic; } return null; }
public static FeatureStructure getTcasFS(CAS aCasView, String aTypeS) { org.apache.uima.cas.FeatureStructure idFS = null; Type type = aCasView.getTypeSystem().getType(aTypeS); if (type != null) { FSIterator<AnnotationFS> idIter = aCasView.getAnnotationIndex(type).iterator(); while (idIter.isValid()) { idFS = idIter.get(); idIter.moveToNext(); } } return idFS; }
private void addChildren(AnnotationTreeNodeImpl<T> node, FSIterator<T> it) { AnnotationTreeNodeImpl<T> dtr; T annot; while (it.isValid()) { annot = it.get(); it.moveToNext(); dtr = new AnnotationTreeNodeImpl<T>(); dtr.set(annot); node.addChild(dtr); addChildren(dtr, subiterator(annot, false, true)); } }
private boolean check(AnnotationFS annotation, RutaStream stream, Type t) { boolean result = false; FSIterator<AnnotationFS> it = stream.getCas().getAnnotationIndex(t).iterator(annotation); while (it.isValid()) { AnnotationFS a = it.get(); if (a.getEnd() >= annotation.getBegin()) { result = true; break; } it.moveToNext(); } return result; }
public static boolean areAdjoining(Token t1, Token t2) { JCas jCas = getJCas(t1); FSIterator<Annotation> tokenIter = jCas.getAnnotationIndex(Token.typeIndexID).iterator(); tokenIter.moveTo(t1); assert (t1.equals(tokenIter.get())); tokenIter.moveToNext(); return tokenIter.isValid() && tokenIter.get().equals(t2); }