当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationFS.getBegin方法代码示例

本文整理汇总了Java中org.apache.uima.cas.text.AnnotationFS.getBegin方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationFS.getBegin方法的具体用法?Java AnnotationFS.getBegin怎么用?Java AnnotationFS.getBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.cas.text.AnnotationFS的用法示例。


在下文中一共展示了AnnotationFS.getBegin方法的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);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:20,代码来源:DictionaryTermLabelAdapter.java

示例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);
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:24,代码来源:BiomedicusTsLabelsPlugin.java

示例3: 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;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:17,代码来源:ChainAdapter.java

示例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);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:23,代码来源:UIMA2BratAnnotator.java

示例5: writeFS

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
/**
 * Write an annotation to the file.
 *
 * @param generator
 *            the generator
 * @param annotation
 *            the annotation
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
private void writeFS(JsonGenerator generator, FeatureStructure annotation) throws IOException {
	generator.writeStartObject();

	Type type = annotation.getType();
	generator.writeStringField("type", type.getName());

	List<Feature> features = type.getFeatures();
	if (annotation instanceof AnnotationFS) {
		AnnotationFS annotationFS = (AnnotationFS) annotation;
		if (!(annotationFS.getEnd() == 0 && annotationFS.getBegin() == 0)) {
			generator.writeStringField("coveredText", annotationFS.getCoveredText());
		}
	}

	if (!features.isEmpty()) {
		writeFS(generator, annotation, features);
	}
	generator.writeEndObject();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:30,代码来源:AbstractJsonConsumer.java

示例6: 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());
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:29,代码来源:BratAnnotationEditor.java

示例7: getDistance

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private static int getDistance(AnnotationFS annotation1, AnnotationFS annotation2) {
  if (annotation1.getEnd() < annotation2.getBegin()) {
    return JCasUtil.selectBetween(Token.class, annotation1, annotation2).size();
  } else if (annotation1.getBegin() > annotation2.getEnd()) {
    return JCasUtil.selectBetween(Token.class, annotation2, annotation1).size();
  } else {
    return 0;
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:10,代码来源:DistanceCollectiveAnswerScorer.java

示例8: 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)
  );
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:12,代码来源:DictionaryConceptLabelAdapter.java

示例9: divideAnnotation

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
private void divideAnnotation(AnnotationFS annotation) {
  Objects.requireNonNull(typeToCreate);
  Objects.requireNonNull(dividers);

  FSIterator<AnnotationFS> subiterator = dividers.subiterator(annotation);
  int begin = annotation.getBegin();
  while (subiterator.hasNext()) {
    int end = subiterator.next().getBegin();
    cas.addFsToIndexes(cas.createAnnotation(typeToCreate, begin, end));
    begin = end;
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:13,代码来源:TableAnnotationDivider.java

示例10: 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);
}
 
开发者ID:nantesnlp,项目名称:uima-tokens-regex,代码行数:39,代码来源:TestUtils.java

示例11: getPosition

import org.apache.uima.cas.text.AnnotationFS; //导入方法依赖的package包/类
@Override
public Position getPosition(int aCasId, FeatureStructure aFS, String aFeature, String aRole,
        int aLinkTargetBegin, int aLinkTargetEnd, LinkCompareBehavior aLinkCompareBehavior)
{
    Type type = aFS.getType();
    AnnotationFS sourceFS = (AnnotationFS) aFS.getFeatureValue(type
            .getFeatureByBaseName(sourceFeature));
    AnnotationFS targetFS = (AnnotationFS) aFS.getFeatureValue(type
            .getFeatureByBaseName(targetFeature));
    
    String collectionId = null;
    String documentId = null;
    try {
        DocumentMetaData dmd = DocumentMetaData.get(aFS.getCAS());
        collectionId = dmd.getCollectionId();
        documentId = dmd.getDocumentId();
    }
    catch (IllegalArgumentException e) {
        // We use this information only for debugging - so we can ignore if the information
        // is missing.
    }
    
    String linkTargetText = null;
    if (aLinkTargetBegin != -1 && aFS.getCAS().getDocumentText() != null) {
        linkTargetText = aFS.getCAS().getDocumentText()
                .substring(aLinkTargetBegin, aLinkTargetEnd);
    }
    
    return new ArcPosition(collectionId, documentId, aCasId, getType(), 
            sourceFS != null ? sourceFS.getBegin() : -1,
            sourceFS != null ? sourceFS.getEnd() : -1,
            sourceFS != null ? sourceFS.getCoveredText() : null,
            targetFS != null ? targetFS.getBegin() : -1,
            targetFS != null ? targetFS.getEnd() : -1,
            targetFS != null ? targetFS.getCoveredText() : null,
            aFeature, aRole, aLinkTargetBegin, aLinkTargetEnd, linkTargetText,
            aLinkCompareBehavior);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:39,代码来源:CasDiff2.java

示例12: 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;
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:12,代码来源:ChainAdapter.java

示例13: 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++;
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:9,代码来源:SoftPrecisionRecallListener.java

示例14: 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);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:16,代码来源:UIMA2BratAnnotator.java

示例15: 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;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:12,代码来源:WebannoTsv3Writer.java


注:本文中的org.apache.uima.cas.text.AnnotationFS.getBegin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。