public boolean hasNext() { return this.upperIt.hasNext(); }
public void process(CAS cas) { FSIterator<AnnotationFS> tokenAnnotations = cas.getAnnotationIndex(mTokenType).iterator(); List<String> tokensList = new ArrayList<>(); while (tokenAnnotations.hasNext()) { tokensList.add(tokenAnnotations.next().getCoveredText()); } double[] result = mCategorizer.categorize(tokensList.toArray(new String[tokensList.size()])); String bestCategory = mCategorizer.getBestCategory(result); setBestCategory(cas, bestCategory); } }
public AnnotationIteratorPair next() { if (!this.upperIt.hasNext()) { throw new NoSuchElementException(); } final AnnotationFS upperFS = this.upperIt.next(); this.upperBegin = upperFS.getBegin(); this.upperEnd = upperFS.getEnd(); this.nextLowerChecked = false; return new AnnotationIteratorPair(upperFS, new AnnotationIterator()); }
@Override public boolean hasNext() { if (testInitView) { return true; } return sofaIter.hasNext(); }
public BaseToken getNextNonEOLToken( FSIterator<Annotation> tokensInSentenceIterator) { while (tokensInSentenceIterator.hasNext()) { BaseToken bt = (BaseToken) tokensInSentenceIterator.next(); if (!(bt instanceof NewlineToken)) { return bt; } } return null; }
private List<Annotation> getAnnotationsInSpan(JCas jcas, int type, int begin, int end) { List<Annotation> list = new ArrayList<Annotation>(); FSIterator annItr = FSUtil.getAnnotationsIteratorInSpan(jcas, type, begin, end); while (annItr.hasNext()) { Annotation ann = (Annotation) annItr.next(); list.add(ann); } return list; }
public static ArrayList<BaseToken> selectBaseToken (JCas jcas) { ArrayList<BaseToken> ret = new ArrayList<BaseToken>(); FSIterator<?> iter = jcas.getJFSIndexRepository().getAnnotationIndex(BaseToken.type).iterator(); while (iter.hasNext()) ret.add((BaseToken)iter.next()); java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; }
public static ArrayList<Sentence> selectSentence (JCas jcas) { ArrayList<Sentence> ret = new ArrayList<Sentence>(); FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(Sentence.type).iterator(); while (iter.hasNext()) ret.add((Sentence)iter.next()); java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; }
public AttributeCalculator (JCas jcas) { this.jcas = jcas; // index the base tokens and NEs by their offsets hbs = new Hashtable<Integer, BaseToken>(); hbe = new Hashtable<Integer, BaseToken>(); FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(BaseToken.type).iterator(); while (iter.hasNext()) { BaseToken t = (BaseToken) iter.next(); hbs.put(t.getBegin(), t); hbe.put(t.getEnd(), t); } }
public void process(CAS cas) { FSIterator<AnnotationFS> tokenAnnotations = cas.getAnnotationIndex(mTokenType).iterator(); List<String> tokensList = new ArrayList<>(); while (tokenAnnotations.hasNext()) { tokensList.add(tokenAnnotations.next().getCoveredText()); } double[] result = mCategorizer.categorize(tokensList.toArray(new String[tokensList.size()])); String bestCategory = mCategorizer.getBestCategory(result); setBestCategory(cas, bestCategory); } }
/** * @param jcas ye olde jay-cas * @return the Metadata for the given jcas or null if one is not found */ static private Metadata getMetadata( final JCas jcas ) { // TODO I really dislike this index-everything-to-java1 paradigm final FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS( Metadata.type ); if ( itr == null || !itr.hasNext() ) { return null; } return (Metadata)itr.next(); }
public static Annotation getFirst(JCas jcas, Type type) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(type); FSIterator<Annotation> iterator = index.iterator(); if (iterator.hasNext()) return (Annotation) iterator.next(); return null; }
public static Annotation getFirst(JCas jcas, Type type) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(type); FSIterator<Annotation> iterator = index.iterator(); if (iterator.hasNext()) return (Annotation) iterator.next(); return null; }
private void extractAndSaveDocKey(JCas jcas, Document doc) { AnnotationIndex<Annotation> idx = jcas .getAnnotationIndex(DocKey.typeIndexID); FSIterator<Annotation> annoIterator = idx.iterator(); if (annoIterator.hasNext()) this.saveDocKey(doc, (DocKey) annoIterator.next()); }
/** Find the sentence in which an Annotation lives **/ public static Sentence getSentence( JCas jCas, Annotation annot ) { FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator(); while (sentences.hasNext()) { Sentence sentence = (Sentence) sentences.next(); if (doesSubsume(sentence,annot)) { return sentence; } } return null; }
/** Returns the first ConllDependencyNode in the CAS w/ same begin and end as the given Annotation **/ public static ConllDependencyNode getDependencyNode(JCas jCas, Annotation annot) { AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type); FSIterator nodeIterator = nodeIndex.iterator(); while (nodeIterator.hasNext()) { ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next(); if (equalCoverage(annot,node)) { return node; } } return null; }
public AnnotationIteratorPair next() { if (!this.upperIt.hasNext()) { throw new NoSuchElementException(); } final AnnotationFS upperFS = this.upperIt.next(); this.upperBegin = upperFS.getBegin(); this.upperEnd = upperFS.getEnd(); this.nextLowerChecked = false; return new AnnotationIteratorPair(upperFS, new AnnotationIterator()); }
/** * Returns {@code true} if {@code jCas} contains {@link WebArgumentMetadata} * * @param jCas jCas * @return boolean */ public static boolean hasWebArgumentMetadata(final JCas jCas) { FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS( CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class)); return iterator.hasNext(); }
public static IntervalST<Annotation> indexAnnotation(JCas jcas, int typeId) { FSIndex annoIndex = jcas.getAnnotationIndex(typeId); FSIterator annoIter = annoIndex.iterator(); IntervalST<Annotation> index = new IntervalST<>(); while (annoIter.hasNext()) { Annotation annotation = (Annotation) annoIter.next(); // assume there is no overlapping annotations index.put(new Interval1D(annotation.getBegin(), annotation.getEnd()), annotation); } return index; }
public String calcmNPHead () { Annotation a = m.getContent(); FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(LookupWindowAnnotation.type).iterator(); while (iter.hasNext()) { LookupWindowAnnotation lwa = (LookupWindowAnnotation) iter.next(); if (lwa.getBegin()<=a.getBegin() && lwa.getEnd()==a.getEnd()) return "yes"; } return "no"; }