本文整理了Java中org.apache.uima.jcas.tcas.Annotation.getCAS()
方法的一些代码示例,展示了Annotation.getCAS()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getCAS()
方法的具体详情如下:
包路径:org.apache.uima.jcas.tcas.Annotation
类名称:Annotation
方法名:getCAS
暂无
代码示例来源:origin: fr.univ-nantes.julestar/uima-tree-tagger-wrapper
@Override
public String getText(Annotation annotation) {
synchronized (annotation.getCAS()) {
return annotation.getCoveredText().toLowerCase();
}
}
代码示例来源:origin: dkpro/dkpro-core
/**
* Trim the offsets of the given annotation to remove leading/trailing whitespace.
* <p>
* <b>Note:</b> use this method only if the document text of the CAS has already been set!
* <p>
* <b>Note:</b> best use this method before adding the annotation to the indexes.
*
* @param aAnnotation
* the annotation to trim. Offsets are updated.
*/
public static void trim(Annotation aAnnotation)
{
trim(aAnnotation.getCAS().getDocumentText(), aAnnotation);
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.segmentation-asl
/**
* Trim the offsets of the given annotation to remove leading/trailing whitespace.
* <p>
* <b>Note:</b> use this method only if the document text of the CAS has already been set!
* <p>
* <b>Note:</b> best use this method before adding the annotation to the indexes.
*
* @param aAnnotation
* the annotation to trim. Offsets are updated.
*/
public static void trim(Annotation aAnnotation)
{
trim(aAnnotation.getCAS().getDocumentText(), aAnnotation);
}
代码示例来源:origin: oaqa/baseqa
public static Token getHeadTokenOfAnnotation(Annotation annotation) {
try {
return getHeadTokenInRange(annotation.getCAS().getJCas(), annotation.getBegin(),
annotation.getEnd());
} catch (CASException e) {
return null;
}
}
代码示例来源:origin: fr.univ-nantes.julestar/uima-tree-tagger-wrapper
public void token(Annotation annotation, String tag, String lemma) {
CAS cas = annotation.getCAS();
int begin = annotation.getBegin();
int end = annotation.getEnd();
String picked = null;
if (lemma == null) {
picked = annotation.getCoveredText(); // "unknown"
} else {
String lemmata[] = lemma.split("\\|");
if (lemmata.length == 0) {
picked = lemma;
} else {
picked = lemmata[lemmata.length - 1];
}
}
if (picked.endsWith("?")) {
picked = picked.substring(0, picked.length() - 1);
}
assert (picked != null);
if (this.update) {
this.update(cas, annotation, this.tagFeature, tag);
this.update(cas, annotation, this.lemmaFeature, picked);
} else {
this.annotate(cas, this.tagFeature, begin, end, tag);
this.annotate(cas, this.lemmaFeature, begin, end, picked);
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima
private void addMergeToHistory(Annotation keep, Annotation removed) {
if (keep instanceof Recordable && removed instanceof Base) {
Recordable r = (Recordable) keep;
Base b = (Base) removed;
try {
addToHistory(
keep.getCAS().getJCas(), HistoryEvents.createMerged(r, referrer, b.getInternalId()));
} catch (CASException e) {
monitor.error("Unable to add merge to history", e);
}
}
}
代码示例来源:origin: dstl/baleen
private void addMergeToHistory(Annotation keep, Annotation removed) {
if (keep instanceof Recordable && removed instanceof Base) {
Recordable r = (Recordable) keep;
Base b = (Base) removed;
try {
addToHistory(
keep.getCAS().getJCas(), HistoryEvents.createMerged(r, referrer, b.getInternalId()));
} catch (CASException e) {
monitor.error("Unable to add merge to history", e);
}
}
}
代码示例来源: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: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
srcCAS = srcCAS == null ? curAnno.getCAS() : srcCAS;
代码示例来源: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));
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
throws CASException
JCas aJCas = root.getCAS().getJCas();
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
aJCas = root.getCAS().getJCas();
代码示例来源:origin: org.apache.uima/ruta-core
private void splitAnnotationOnComplete(Annotation annotation, Type typeToSplit,
boolean addToBegin, boolean addToEnd, RuleMatch match, RutaStream stream) {
List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(annotation, typeToSplit);
if (annotationsInWindow == null || annotationsInWindow.isEmpty()) {
return;
}
CAS cas = annotation.getCAS();
CasCopier cc = new CasCopier(cas, cas);
cas.removeFsFromIndexes(annotation);
int overallEnd = annotation.getEnd();
Annotation first = annotation;
for (AnnotationFS each : annotationsInWindow) {
int firstEnd = addToEnd ? each.getEnd() : each.getBegin();
first.setEnd(firstEnd);
boolean valid = trimInvisible(first, stream);
if (valid) {
stream.addAnnotation(first, true, true, match);
}
Annotation second = (Annotation) cc.copyFs(first);
int secondBegin = addToBegin ? each.getBegin() : each.getEnd();
second.setBegin(secondBegin);
second.setEnd(overallEnd);
valid = trimInvisible(second, stream);
if (valid) {
stream.addAnnotation(second, true, true, match);
}
first = second;
}
}
代码示例来源:origin: dstl/baleen
/**
* Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so.
*
* <p>Relations that refer to the given annotation will also be removed.
*
* @param annot Annotation(s) to remove
*/
public void remove(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
if (annot instanceof Recordable) {
try {
addToHistory(
annot.getCAS().getJCas(), HistoryEvents.createAdded((Recordable) annot, referrer));
} catch (CASException e) {
monitor.error("Unable to add to history on remove", e);
}
}
if (annot instanceof Entity) {
for (Relation r : getRelations((Entity) annot)) {
monitor.entityRemoved(r.getType().getName());
r.removeFromIndexes();
}
}
monitor.entityRemoved(annot.getType().getName());
annot.removeFromIndexes();
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima
/**
* Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so.
*
* <p>Relations that refer to the given annotation will also be removed.
*
* @param annot Annotation(s) to remove
*/
public void remove(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
if (annot instanceof Recordable) {
try {
addToHistory(
annot.getCAS().getJCas(), HistoryEvents.createAdded((Recordable) annot, referrer));
} catch (CASException e) {
monitor.error("Unable to add to history on remove", e);
}
}
if (annot instanceof Entity) {
for (Relation r : getRelations((Entity) annot)) {
monitor.entityRemoved(r.getType().getName());
r.removeFromIndexes();
}
}
monitor.entityRemoved(annot.getType().getName());
annot.removeFromIndexes();
}
}
代码示例来源:origin: org.apache.uima/ruta-core
Collection<RutaBasic> basics = stream.getAllBasicsInWindow(annotation);
CAS cas = annotation.getCAS();
CasCopier cc = new CasCopier(cas, cas);
内容来源于网络,如有侵权,请联系作者删除!