本文整理了Java中org.apache.uima.jcas.tcas.Annotation.addToIndexes()
方法的一些代码示例,展示了Annotation.addToIndexes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.addToIndexes()
方法的具体详情如下:
包路径:org.apache.uima.jcas.tcas.Annotation
类名称:Annotation
方法名:addToIndexes
暂无
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
protected void saveAnnotation(JCas jcas, Constructor<? extends Annotation> annoConstructor, int begin, int end) {
Annotation anno = null;
try {
anno = annoConstructor.newInstance(jcas, begin, end);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
anno.addToIndexes();
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-collectionreaders
/**
* Apply the text and annotations to the jCas.
*
* <p>Once call once.
*/
public void build() {
jCas.setDocumentText(documentText.toString());
for (Annotation a : annotations) {
a.addToIndexes(jCas);
}
}
}
代码示例来源:origin: dstl/baleen
/**
* Apply the text and annotations to the jCas.
*
* <p>Once call once.
*/
public void build() {
jCas.setDocumentText(documentText.toString());
for (Annotation a : annotations) {
a.addToIndexes(jCas);
}
}
}
代码示例来源:origin: org.cleartk/cleartk-util
private void createParentheticals(JCas jCas, String text, int offset)
throws AnalysisEngineProcessException {
Stack<Integer> leftRoundedParens = new Stack<Integer>();
leftRoundedParens.clear();
for (int ci = 0; ci < text.length(); ci++) {
char c = text.charAt(ci);
if (c == leftParen) {
leftRoundedParens.push(ci);
}
if (c == rightParen && !leftRoundedParens.isEmpty()) {
int leftOffset = leftRoundedParens.pop();
Annotation ann;
try {
ann = parentheticalConstructor.newInstance(jCas, offset + leftOffset, offset + ci + 1);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
ann.addToIndexes();
}
}
}
代码示例来源:origin: ClearTK/cleartk
private void createTokens(List<Token> pojoTokens, int offset, JCas jCas)
throws InstantiationException, InvocationTargetException, IllegalAccessException {
for (Token pojoToken : pojoTokens) {
int tokenBegin = pojoToken.getBegin() + offset;
int tokenEnd = pojoToken.getEnd() + offset;
tokenConstructor.newInstance(jCas, tokenBegin, tokenEnd).addToIndexes();
}
}
代码示例来源:origin: edu.utah.bmi.nlp/fastner
protected void saveConcept(JCas jcas, Constructor<? extends Annotation> annoConstructor, int begin, int end, String sectionName, String... rule) {
Annotation anno = null;
try {
anno = annoConstructor.newInstance(jcas, begin, end);
if (anno instanceof ConceptBASE) {
if (sectionName != null)
((ConceptBASE) anno).setSection(sectionName);
if (rule.length > 0) {
((ConceptBASE) anno).setNote(rule[0]);
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
anno.addToIndexes();
}
代码示例来源:origin: CLLKazan/UIMA-Ext
private static void postprocess(int spanBegin, Annotation anno, int begin, int end) {
anno.setBegin(spanBegin + begin);
anno.setEnd(spanBegin + end);
anno.addToIndexes();
}
}
代码示例来源:origin: ClearTK/cleartk
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
String text = jCas.getDocumentText();
breakIterator.setText(text);
int index = breakIterator.first();
int endIndex;
while ((endIndex = breakIterator.next()) != BreakIterator.DONE) {
String annotationText = text.substring(index, endIndex);
if (!annotationText.trim().equals("")) {
try {
annotationConstructor.newInstance(jCas, index, endIndex).addToIndexes();
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
index = endIndex;
}
}
代码示例来源:origin: ClearTK/cleartk
@Override
public Annotation convert(JCas view, TopTreebankNode topNode) {
Annotation annotation = new Annotation(view);
List<Annotation> subAnnotations = new ArrayList<Annotation>();
for (PropbankRelation rel : this.relations) {
subAnnotations.add(rel.convert(view, topNode));
}
// annotation.setAnnotations(UIMAUtil.toFSArray(view, subAnnotations));
int[] span = AnnotationUtil.getAnnotationsExtent(subAnnotations);
annotation.setBegin(span[0]);
annotation.setEnd(span[1]);
annotation.addToIndexes();
return annotation;
}
代码示例来源:origin: org.cleartk/cleartk-corpus
@Override
public Annotation convert(JCas view, TopTreebankNode topNode) {
Annotation annotation = new Annotation(view);
List<Annotation> subAnnotations = new ArrayList<Annotation>();
for (PropbankRelation rel : this.relations) {
subAnnotations.add(rel.convert(view, topNode));
}
// annotation.setAnnotations(UIMAUtil.toFSArray(view, subAnnotations));
int[] span = AnnotationUtil.getAnnotationsExtent(subAnnotations);
annotation.setBegin(span[0]);
annotation.setEnd(span[1]);
annotation.addToIndexes();
return annotation;
}
代码示例来源:origin: apache/ctakes
/**
* returns the number of annotations of specified type in the
*/
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
Annotation ann = new Annotation(jcas, beginSpan, endSpan);
ann.addToIndexes();
AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
ann.removeFromIndexes();
return annIdx.size();
}
代码示例来源:origin: org.apache.ctakes/ctakes-core
/**
* For correct behavior, requires types to be listed in TypePriorities so that the subiterator works as expected
*/
public static FSIterator getAnnotationsIteratorInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
Annotation ann = new Annotation(jcas, beginSpan, endSpan);
ann.addToIndexes();
AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
FSIterator<?> itr = annIdx.subiterator(ann);
ann.removeFromIndexes();
return itr;
}
代码示例来源:origin: org.apache.ctakes/ctakes-core
/**
* returns the number of annotations of specified type in the
*/
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
Annotation ann = new Annotation(jcas, beginSpan, endSpan);
ann.addToIndexes();
AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
ann.removeFromIndexes();
return annIdx.size();
}
代码示例来源:origin: apache/ctakes
/**
* For correct behavior, requires types to be listed in TypePriorities so that the subiterator works as expected
*/
public static FSIterator getAnnotationsIteratorInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
Annotation ann = new Annotation(jcas, beginSpan, endSpan);
ann.addToIndexes();
AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
FSIterator<?> itr = annIdx.subiterator(ann);
ann.removeFromIndexes();
return itr;
}
代码示例来源:origin: dstl/baleen
@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
// Do nothing
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(aJCas.getDocumentText());
while (m.find()) {
Annotation a = new Annotation(aJCas);
a.setBegin(m.start());
a.setEnd(m.end());
a.addToIndexes();
}
}
}
代码示例来源:origin: dstl/baleen
private void addAnnotation(final int start, final int end) {
final Annotation a = new WordToken(jCas);
a.setBegin(start);
a.setEnd(end);
a.addToIndexes();
}
代码示例来源:origin: dstl/baleen
/**
* Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so
*
* @param annot Annotation(s) to add
*/
public void add(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
annot.addToIndexes();
monitor.entityAdded(annot.getType().getName());
if (annot instanceof Entity) {
Entity entity = (Entity) annot;
// Add in a value if it doesn't have one
if (Strings.isNullOrEmpty(entity.getValue())) {
entity.setValue(annot.getCoveredText());
}
addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer));
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
protected Annotation createAnnotation(AnnotationFS annotation, MatchContext context,
RutaStream stream) {
Type t = type.getType(context, stream);
AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t, annotation.getBegin(),
annotation.getEnd());
Annotation newAnnotation = null;
if (newAnnotationFS instanceof Annotation) {
newAnnotation = (Annotation) newAnnotationFS;
newAnnotation.addToIndexes();
} else {
return null;
}
stream.addAnnotation(newAnnotation, context.getRuleMatch());
return newAnnotation;
}
代码示例来源:origin: org.apache.uima/textmarker-core
protected Annotation createAnnotation(AnnotationFS matchedAnnotation, RuleElement element,
TextMarkerStream stream, RuleMatch match) {
Type t = type.getType(element.getParent());
AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t,
matchedAnnotation.getBegin(), matchedAnnotation.getEnd());
Annotation newAnnotation = null;
if (newAnnotationFS instanceof Annotation) {
newAnnotation = (Annotation) newAnnotationFS;
newAnnotation.addToIndexes();
} else {
return null;
}
stream.addAnnotation(newAnnotation, match);
return newAnnotation;
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima
/**
* Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so
*
* @param annot Annotation(s) to add
*/
public void add(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
annot.addToIndexes();
monitor.entityAdded(annot.getType().getName());
if (annot instanceof Entity) {
Entity entity = (Entity) annot;
// Add in a value if it doesn't have one
if (Strings.isNullOrEmpty(entity.getValue())) {
entity.setValue(annot.getCoveredText());
}
addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!