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); } }
/** * 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 static Annotation getAnnotation(JCas jcas, int typeID) { AnnotationIndex<Annotation> index = jcas.getAnnotationIndex(typeID); Iterator<Annotation> it = index.iterator(); Annotation annotation = null; if (it.hasNext()) { annotation = it.next(); } return annotation; }
private FSIterator<Annotation> getAllAnnotations(JCas jcas, int type) { JFSIndexRepository indexes = jcas.getJFSIndexRepository(); FSIterator<Annotation> annotationsIter = indexes.getAnnotationIndex(type).iterator(); // while (segmentItr.hasNext()) { // } return annotationsIter; }
/** * {@inheritDoc} */ @Override public Iterator<Annotation> getLookupWindowIterator( final JCas jcas ) throws AnnotatorInitializationException { final JFSIndexRepository indexes = jcas.getJFSIndexRepository(); return indexes.getAnnotationIndex( Sentence.type ).iterator(); }
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 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); } }
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()); }
@SuppressWarnings("unchecked") public static <T extends AnnotationFS> FeaturePathIterator<T> create(CAS aCas, Type aType, String aPath) throws FeaturePathException { FSIterator<T> iterator = ((AnnotationIndex<T>) aCas.getAnnotationIndex(aType)) .iterator(); final FeaturePathInfo fp = new FeaturePathInfo(); fp.initialize(aPath); return new FeaturePathIterator<T>(iterator, fp); } }
private void updateIterators(CAS cas, Type basicType, FilterManager filter, AnnotationFS additionalWindow) { if (additionalWindow != null) { this.basicIt = cas.getAnnotationIndex(basicType).subiterator(additionalWindow); } else { this.basicIt = cas.getAnnotationIndex(basicType).iterator(); } currentIt = filter.createFilteredIterator(cas, basicType); }
private void updateIterators(CAS cas, Type basicType, FilterManager filter, AnnotationFS additionalWindow) { if (additionalWindow != null) { this.basicIt = cas.getAnnotationIndex(basicType).subiterator(additionalWindow); } else { this.basicIt = cas.getAnnotationIndex(basicType).iterator(); } currentIt = filter.createFilteredIterator(cas, basicType); }
/** 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; }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { // removeDoctors(aJCas); removeHistoryOf(aJCas); FSIterator<Annotation> iter = aJCas.getJFSIndexRepository().getAnnotationIndex(Markable.type).iterator(); expandToNP(aJCas, FSIteratorToList.convert(iter)); mergeNP(aJCas); elevateAdjectives(aJCas); iter = aJCas.getJFSIndexRepository().getAnnotationIndex(Markable.type).iterator(); rmDup(FSIteratorToList.convert(iter)); }
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"; }