本文整理了Java中org.apache.uima.cas.FSIndex.iterator()
方法的一些代码示例,展示了FSIndex.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FSIndex.iterator()
方法的具体详情如下:
包路径:org.apache.uima.cas.FSIndex
类名称:FSIndex
方法名:iterator
[英]Return an iterator over the index. The iterator will be set to the start position of the index.
[中]返回索引上的迭代器。迭代器将被设置为索引的起始位置。
代码示例来源:origin: apache/opennlp
allRemoveAnnotations.iterator(), containingConstraint);
代码示例来源:origin: apache/opennlp
@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);
}
}
代码示例来源:origin: apache/opennlp
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);
}
}
代码示例来源:origin: apache/uima-uimaj
@Override
public FSIterator<T> iterator() {
return (FSIterator<T>) this.index.iterator();
}
代码示例来源:origin: apache/uima-uimaj
@Override
public FSIterator<T> iterator(FeatureStructure fs) {
return (FSIterator<T>) this.index.iterator(fs);
}
代码示例来源:origin: org.apache.uima/uimafit-core
@Override
public Iterator<T> iterator() {
return index.withSnapshotIterators().iterator();
}
代码示例来源:origin: apache/uima-uimaj
@Override
@SuppressWarnings("unchecked")
public FSIterator<SofaFS> getSofaIterator() {
FSIndex<SofaFS> sofaIndex = (FSIndex<SofaFS>) ( FSIndex<?>) this.svd.baseCAS.indexRepository.getIndex(CAS.SOFA_INDEX_NAME);
return sofaIndex.iterator();
}
代码示例来源:origin: apache/uima-uimaj
@Override
public FSIterator<T> iterator(boolean ambiguous) {
if (ambiguous) {
return (FSIterator<T>) this.index.iterator();
}
// return non-constrained, non-strict, unambiguous iterator
boolean strict = false;
boolean isBounded = false;
return new Subiterator<T>(this.index.iterator(), null, 0, 0, ambiguous, strict, isBounded, ((FSIndexRepositoryImpl.IndexImpl<T>)(this.index)).getFsRepositoryImpl());
}
代码示例来源:origin: apache/uima-uimaj
private static FeatureStructure[] getIndexContents(FSIndex<? extends FeatureStructure> fsIndex) {
return getIndexContents(fsIndex.iterator());
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
private void removeOverlap(JCas jCas) {
HashMap<String, IntervalST> typeSpanMap = new HashMap<>();
FSIndex annoIndex = jCas.getAnnotationIndex();
Iterator annoIter = annoIndex.iterator();
while (annoIter.hasNext()) {
Object obj = annoIter.next();
String typeName = obj.getClass().getCanonicalName();
IntervalST thisSpanTree = typeSpanMap.getOrDefault(typeName, new IntervalST());
checkOverlap(thisSpanTree, (Annotation) obj);
}
}
代码示例来源:origin: apache/uima-uimaj
@Override
public FSIterator<T> subiterator(AnnotationFS annot, boolean ambiguous, boolean strict) {
boolean isBounded = true;
return new Subiterator<T>(this.index.iterator(), annot, 0, 0, ambiguous, strict, isBounded, ((FSIndexRepositoryImpl.IndexImpl<T>)(this.index)).getFsRepositoryImpl());
}
代码示例来源:origin: Ailab403/ailab-mltk4j
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));
}
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
private void indexAnnotations(JCas jCas) {
for (Class conceptType : evidenceAnnotationTree.keySet()) {
FSIndex annoIndex = jCas.getAnnotationIndex(conceptType);
Iterator annoIter = annoIndex.iterator();
IntervalST<Annotation> intervalST = new IntervalST<>();
while (annoIter.hasNext()) {
Annotation anno = (Annotation) annoIter.next();
intervalST.put(new Interval1D(anno.getBegin(), anno.getEnd()), anno);
}
evidenceAnnotationTree.put(conceptType, intervalST);
}
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
private void indexScopes(JCas jCas) {
scopes.clear();
for (Class scopeClass : scopeIndex.values()) {
FSIndex annoIndex = jCas.getAnnotationIndex(scopeClass);
FSIterator annoIter = annoIndex.iterator();
IntervalST<Annotation> scopeTree = new IntervalST<>();
while (annoIter.hasNext()) {
Annotation scopeAnnotation = (Annotation) annoIter.next();
scopeTree.put(new Interval1D(scopeAnnotation.getBegin(), scopeAnnotation.getEnd()), scopeAnnotation);
}
scopes.put(scopeClass, scopeTree);
}
}
代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor
/**
* Retrieves annotations of the given type from the {@link CAS}.
*
* @param type the type
* @return the annotations
*/
@Override
public Collection<AnnotationFS> getAnnotations(Type type) {
FSIndex<AnnotationFS> annotationIndex = mCAS.getAnnotationIndex(type);
StrictTypeConstraint typeConstrain = new StrictTypeConstraint(type);
FSIterator<AnnotationFS> strictTypeIterator = mCAS
.createFilteredIterator(annotationIndex.iterator(), typeConstrain);
return fsIteratorToCollection(strictTypeIterator);
}
代码示例来源:origin: Ailab403/ailab-mltk4j
public void processCas(CAS cas) throws ResourceProcessException {
FSIndex categoryIndex = cas.getAnnotationIndex(mCategoryType);
if (categoryIndex.size() > 0) {
AnnotationFS categoryAnnotation =
(AnnotationFS) categoryIndex.iterator().next();
// add to event collection
DocumentSample sample = new DocumentSample(
categoryAnnotation.getStringValue(mCategoryFeature),
cas.getDocumentText());
documentSamples.add(sample);
}
}
代码示例来源:origin: org.apache.uima/uimaj-tools
@Override
public void actionPerformed(ActionEvent event) {
String title = this.main.getIndexLabel() + " - " + this.main.getIndex().getType().getName();
MultiAnnotViewerFrame f = new MultiAnnotViewerFrame(title);
f.addWindowListener(new CloseAnnotationViewHandler(this.main));
FSIterator it = this.main.getIndex().iterator();
final String text = this.main.getCas().getDocumentText();
System.out.println("Creating extents.");
AnnotationExtent[] extents = MultiMarkup.createAnnotationMarkups(it, text.length(), this.main
.getStyleMap());
System.out.println("Initializing text frame.");
f.init(text, extents, this.main.getDimension(MainFrame.annotViewSizePref));
System.out.println("Done.");
}
代码示例来源:origin: org.apache.opennlp/opennlp-uima
@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);
}
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
public static IntervalST<Integer> indexAnnotation(JCas jcas, int typeId, ArrayList<Annotation> annotations) {
FSIndex annoIndex = jcas.getAnnotationIndex(typeId);
FSIterator annoIter = annoIndex.iterator();
IntervalST<Integer> index = new IntervalST<>();
int i = 0;
while (annoIter.hasNext()) {
Annotation annotation = (Annotation) annoIter.next();
annotations.add(annotation);
// assume there is no overlapping annotations
index.put(new Interval1D(annotation.getBegin(), annotation.getEnd()), i);
i++;
}
return index;
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
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;
}
内容来源于网络,如有侵权,请联系作者删除!