本文整理汇总了Java中org.apache.uima.cas.text.AnnotationFS.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationFS.getEnd方法的具体用法?Java AnnotationFS.getEnd怎么用?Java AnnotationFS.getEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.text.AnnotationFS
的用法示例。
在下文中一共展示了AnnotationFS.getEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotationToLabel
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public DictionaryTerm annotationToLabel(AnnotationFS annotationFS) {
FeatureStructure conceptsFeatureValue = annotationFS.getFeatureValue(conceptsFeature);
if (!(conceptsFeatureValue instanceof ArrayFS)) {
throw new IllegalStateException("Concepts feature structure is not array.");
}
ArrayFS conceptsArray = (ArrayFS) conceptsFeatureValue;
int size = conceptsArray.size();
List<DictionaryConcept> concepts = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
AnnotationFS conceptFeatureStructure = (AnnotationFS) conceptsArray.get(i);
concepts.add(dictionaryConceptLabelAdapter.annotationToLabel(conceptFeatureStructure));
}
return new DictionaryTerm(annotationFS.getBegin(), annotationFS.getEnd(), concepts);
}
示例2: annotationToLabel
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public T annotationToLabel(AnnotationFS annotationFS) {
FeatureStructure cuesValue = annotationFS.getFeatureValue(cues);
if (!(cuesValue instanceof ArrayFS)) {
throw new IllegalStateException("Cues is not ArrayFS");
}
ArrayFS cuesArray = (ArrayFS) cuesValue;
int size = cuesArray.size();
List<Span> cueTerms = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
FeatureStructure cueFs = cuesArray.get(i);
if (!(cueFs instanceof AnnotationFS)) {
throw new IllegalStateException();
}
AnnotationFS cueAnnotation = (AnnotationFS) cueFs;
Span span = new Span(cueAnnotation.getBegin(),
cueAnnotation.getEnd());
cueTerms.add(span);
}
return create(annotationFS.getBegin(), annotationFS.getEnd(), cueTerms);
}
示例3: distanceBetween
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
* @param anno1
* @param anno2
* @return 0 if given annotation overlap else return distance between the
* end of first (in text direction) annotation and the begin of
* second annotation.
*/
private static int distanceBetween(AnnotationFS anno1, AnnotationFS anno2) {
AnnotationFS first;
AnnotationFS second;
if (anno1.getBegin() > anno2.getBegin()) {
first = anno2;
second = anno1;
} else if (anno1.getBegin() < anno2.getBegin()) {
first = anno1;
second = anno2;
} else {
return 0;
}
int result = second.getBegin() - first.getEnd();
return result >= 0 ? result : 0;
}
示例4: mapEvent
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void mapEvent(UimaBratEventMapping evMapping, AnnotationFS uEvent) {
if (context.isMapped(uEvent)) {
return;
}
BratEventType bType = evMapping.bratType;
// use UIMA event annotation boundaries as Brat event trigger boundaries
BratEventTrigger trigger = new BratEventTrigger(bType,
uEvent.getBegin(), uEvent.getEnd(), uEvent.getCoveredText());
// assign id to trigger
trigger = bac.register(trigger);
// fill slots
Multimap<String, BratAnnotation<?>> roleAnnotations = makeRoleMap(
uEvent, bType, evMapping.roleFeatures);
// create
BratEvent bEvent = new BratEvent(bType, trigger, roleAnnotations);
// assign id
bEvent = bac.register(bEvent);
// map to note
mapNotes(evMapping, bEvent, uEvent);
// memorize
context.mapped(uEvent, bEvent);
}
示例5: getOffsetsFromRequest
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
* Extract offset information from the current request. These are either offsets of an existing
* selected annotations or offsets contained in the request for the creation of a new
* annotation.
*/
private Offsets getOffsetsFromRequest(IRequestParameters request, JCas jCas, VID aVid)
throws IOException
{
if (aVid.isNotSet() || aVid.isSynthetic()) {
// Create new span annotation - in this case we get the offset information from the
// request
String offsets = request.getParameterValue(PARAM_OFFSETS).toString();
OffsetsList offsetLists = JSONUtil.getJsonConverter().getObjectMapper()
.readValue(offsets, OffsetsList.class);
int annotationBegin = getModelObject().getWindowBeginOffset()
+ offsetLists.get(0).getBegin();
int annotationEnd = getModelObject().getWindowBeginOffset()
+ offsetLists.get(offsetLists.size() - 1).getEnd();
return new Offsets(annotationBegin, annotationEnd);
}
else {
// Edit existing span annotation - in this case we look up the offsets in the CAS
// Let's not trust the client in this case.
AnnotationFS fs = WebAnnoCasUtil.selectByAddr(jCas, aVid.getId());
return new Offsets(fs.getBegin(), fs.getEnd());
}
}
示例6: getSpan
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public Serializable getSpan(JCas aJCas, int aBegin, int aEnd, AnnotationFeature aFeature,
String aLabelValue)
{
List<Token> tokens = selectOverlapping(aJCas, Token.class, aBegin, aEnd);
int begin = tokens.get(0).getBegin();
int end = tokens.get(tokens.size() - 1).getEnd();
String baseName = StringUtils.substringBeforeLast(getAnnotationTypeName(), CHAIN) + LINK;
Type linkType = CasUtil.getType(aJCas.getCas(), baseName);
for (AnnotationFS fs : CasUtil.selectCovered(aJCas.getCas(), linkType, begin, end)) {
if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
return getFeatureValue(aFeature, fs);
}
}
return null;
}
示例7: annotationToLabel
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public DictionaryConcept annotationToLabel(AnnotationFS annotationFS) {
return new DictionaryConcept(
annotationFS.getBegin(),
annotationFS.getEnd(),
annotationFS.getStringValue(identifierFeature),
annotationFS.getStringValue(sourceFeature),
annotationFS.getStringValue(semanticTypeFeature),
annotationFS.getDoubleValue(confidenceFeature)
);
}
示例8: textAfter
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
* @param anno an annotation
* @param contextCharNum number of characters
* @return contextCharNum characters after the given annotation
*/
public static String textAfter(AnnotationFS anno, int contextCharNum) {
Preconditions.checkArgument(contextCharNum >= 0);
String txt = anno.getCAS().getDocumentText();
int begin = anno.getEnd();
int end = Math.min(txt.length(), begin + contextCharNum);
return txt.substring(begin, end);
}
示例9: compare
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public int compare(AnnotationFS arg0, AnnotationFS arg1)
{
int beginDiff = arg0.getBegin() - arg1.getBegin();
if (beginDiff == 0) {
return arg1.getEnd() - arg0.getEnd();
}
else {
return beginDiff;
}
}
示例10: onMatch
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void onMatch(AnnotationFS gold, AnnotationFS sys) {
OverlapHelper.evaluateOverlap(gold, sys, measures);
if (gold.getBegin() == sys.getBegin() && gold.getEnd() == sys.getEnd()) {
exactMatchingCounter++;
} else {
partialMatchingCounter++;
}
}
示例11: evaluator
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Bean
public BestMatchEvaluatorBase evaluator() {
return new BestMatchEvaluatorBase() {
@Override
protected RecognitionMeasures evaluateAnno(AnnotationFS goldAnno,
AnnotationFS sysAnno) {
RecognitionMeasures result = new RecognitionMeasures();
int overlapBegin = Math.max(goldAnno.getBegin(), sysAnno.getBegin());
int overlapEnd = Math.min(goldAnno.getEnd(), sysAnno.getEnd());
if (overlapBegin >= overlapEnd) {
// annotations do not overlap
result.incrementMissing(1);
result.incrementSpurious(1);
} else {
result.incrementMatching(overlapEnd - overlapBegin);
// calc missing
if (goldAnno.getBegin() < overlapBegin) {
result.incrementMissing(overlapBegin - goldAnno.getBegin());
}
if (goldAnno.getEnd() > overlapEnd) {
result.incrementMissing(goldAnno.getEnd() - overlapEnd);
}
// calc spurious
if (sysAnno.getBegin() < overlapBegin) {
result.incrementSpurious(overlapBegin - sysAnno.getBegin());
}
if (sysAnno.getEnd() > overlapEnd) {
result.incrementSpurious(sysAnno.getEnd() - overlapEnd);
}
}
return result;
}
};
}
示例12: mapEntity
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void mapEntity(UimaBratEntityMapping entMapping, AnnotationFS uEntity) {
if (context.isMapped(uEntity)) {
return;
}
BratEntityType bType = entMapping.bratType;
// create brat annotation instance
BratEntity bEntity = new BratEntity(bType,
uEntity.getBegin(), uEntity.getEnd(), uEntity.getCoveredText());
// add to container - it assigns ID
bEntity = bac.register(bEntity);
// map to note
mapNotes(entMapping, bEntity, uEntity);
// memorize
context.mapped(uEntity, bEntity);
}
示例13: matchSequence
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
public static String matchSequence(AutomatonEngine a, String str) {
final List<RegexOccurrence> episodes = Lists.newLinkedList();
RecognitionHandler rh = new RecognitionHandler() {
@Override
public void recognizedEpisode(RegexOccurrence episode) {
episodes.add(episode);
}
};
a.addRecognitionHandler(rh);
StringTokenizer st = new StringTokenizer(str, " ");
int i = 0;
while(st.hasMoreTokens()) {
String s = st.nextToken();
Annotation anno = Mockito.mock(Annotation.class);
Mockito.when(anno.getCoveredText()).thenReturn(s);
Mockito.when(anno.getBegin()).thenReturn(i);
Mockito.when(anno.getEnd()).thenReturn(i+1);
a.nextAnnotation(anno, true);
i += 1;
}
a.finish();
List<String> results = Lists.newLinkedList();
for(RegexOccurrence e:episodes) {
String result = Joiner.on(' ').join(e.getLabels());
AnnotationFS first;
AnnotationFS last;
if(e.size() > 0) {
first = e.getLabelledAnnotations().get(0).getAnnotation();
last = e.getLabelledAnnotations().get(e.size()-1).getAnnotation();
result += " (" + first.getBegin() + "," + last.getEnd() + ")";
} else {
result += " (none)";
}
results.add(result);
}
return Joiner.on(" | ").join(results);
}
示例14: isMultiToken
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private boolean isMultiToken(AnnotationFS aFs)
{
for (AnnotationUnit unit : units) {
if (unit.begin <= aFs.getBegin() && unit.end > aFs.getBegin()
&& unit.end < aFs.getEnd()) {
return true;
}
}
return false;
}
示例15: createAnnotation
import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
* A Helper method to add annotation to CAS
*/
private Integer createAnnotation(AnnotatorState aState, CAS aCas, int aBegin, int aEnd)
throws AnnotationException
{
// If stacking is not allowed and there already is an annotation, then return the address
// of the existing annotation.
Type type = CasUtil.getType(aCas, getAnnotationTypeName());
for (AnnotationFS fs : CasUtil.selectCovered(aCas, type, aBegin, aEnd)) {
if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
if (!allowStacking) {
return getAddr(fs);
}
}
}
AnnotationFS newAnnotation = aCas.createAnnotation(type, aBegin, aEnd);
// If if the layer attaches to a feature, then set the attach-feature to the newly
// created annotation.
if (getAttachFeatureName() != null) {
Type theType = CasUtil.getType(aCas, getAttachTypeName());
Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName());
if (CasUtil.selectCovered(aCas, theType, aBegin, aEnd).isEmpty()) {
throw new AnnotationException("No annotation of type [" + getAttachTypeName()
+ "] to attach to at location [" + aBegin + "-" + aEnd + "].");
}
CasUtil.selectCovered(aCas, theType, aBegin, aEnd).get(0)
.setFeatureValue(attachFeature, newAnnotation);
}
aCas.addFsToIndexes(newAnnotation);
publishEvent(new SpanCreatedEvent(this, aState.getDocument(),
aState.getUser().getUsername(), newAnnotation));
return getAddr(newAnnotation);
}