/** * Performs parsing on the given {@link CAS} object. */ public void process(CAS cas) { FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(mSentenceType); for (AnnotationFS sentence : sentences) { process(cas, sentence); } }
.getAnnotationIndex(removeAnnotationType);
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); } }
FSIndex<AnnotationFS> tokenAnnotationIndex = tcas.getAnnotationIndex(mTokenType);
/** * 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; } }
@Override public void process(CAS cas) throws AnalysisEngineProcessException { FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(sentenceType);
@Override protected void setBestCategory(CAS tcas, String bestCategory) { FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType); AnnotationFS categoryAnnotation; if (categoryIndex.size() > 0) { categoryAnnotation = categoryIndex.iterator().next(); } else { categoryAnnotation = tcas.createAnnotation(mCategoryType, 0, tcas.getDocumentText().length()); tcas.getIndexRepository().addFS(categoryAnnotation); } categoryAnnotation.setStringValue(mCategoryFeature, bestCategory); } }
protected void process(CAS cas, AnnotationFS sentenceAnnotation) { FSIndex<AnnotationFS> allTokens = cas.getAnnotationIndex(mTokenType); ContainingConstraint containingConstraint = new ContainingConstraint(sentenceAnnotation); String sentence = sentenceAnnotation.getCoveredText(); Iterator<AnnotationFS> containingTokens = cas.createFilteredIterator( allTokens.iterator(), containingConstraint); List<Span> tokenSpans = new LinkedList<>(); while (containingTokens.hasNext()) { AnnotationFS token = containingTokens.next(); tokenSpans.add(new Span(token.getBegin() - sentenceAnnotation.getBegin(), token.getEnd() - sentenceAnnotation.getBegin())); } ParseConverter converter = new ParseConverter(sentence, tokenSpans.toArray(new Span[tokenSpans.size()])); Parse unparsedTree = converter.getParseForTagger(); if (unparsedTree.getChildCount() > 0) { Parse parse = mParser.parse(unparsedTree); // TODO: We need a strategy to handle the case that a full // parse could not be found. What to do in this case? parse = converter.transformParseFromTagger(parse); if (mLogger.isLoggable(Level.INFO)) { StringBuffer parseString = new StringBuffer(); parse.show(parseString); mLogger.log(Level.INFO, parseString.toString()); } createAnnotation(cas, sentenceAnnotation.getBegin(), parse); } }
public void process(CAS tcas) { FSIndex<AnnotationFS> sentenceIndex = tcas.getAnnotationIndex(mNameType);
.getAnnotationIndex(containerType);
/** * Performs parsing on the given {@link CAS} object. */ public void process(CAS cas) { FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(mSentenceType); for (AnnotationFS sentence : sentences) { process(cas, sentence); } }
/** * Process the given CAS object. */ public void processCas(CAS cas) { FSIndex<AnnotationFS> sentenceIndex = cas.getAnnotationIndex(mSentenceType); for (AnnotationFS sentenceAnnotation : sentenceIndex) { processSentence(cas, sentenceAnnotation); } }
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); }
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 processSentence(CAS tcas, AnnotationFS sentence) { FSIndex<AnnotationFS> chunkIndex = tcas.getAnnotationIndex(mChunkType); ContainingConstraint containingConstraint = new ContainingConstraint(sentence); Iterator<AnnotationFS> chunkIterator = tcas.createFilteredIterator( chunkIndex.iterator(), containingConstraint); while (chunkIterator.hasNext()) { AnnotationFS chunkAnnotation = (AnnotationFS) chunkIterator.next(); processChunk(tcas, (chunkAnnotation)); } }
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); } }
@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); } }
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; }