org.apache.uima.cas.CAS.createAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.apache.uima.cas.CAS.createAnnotation()方法的一些代码示例,展示了CAS.createAnnotation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.createAnnotation()方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:createAnnotation

CAS.createAnnotation介绍

[英]Create a new annotation. Note that you still need to insert the annotation into the index repository yourself.
[中]创建新注释。请注意,您仍然需要自己将注释插入索引存储库。

代码示例

代码示例来源:origin: apache/opennlp

private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations,
                String tag, int start, int end) {
 AnnotationFS chunk = tcas.createAnnotation(mChunkType,
   tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd());
 chunk.setStringValue(mChunkFeature, tag);
 tcas.getIndexRepository().addFS(chunk);
}

代码示例来源:origin: apache/opennlp

.createAnnotation(tokenType,
  sentenceOffset + tokenSpans[i].getStart(), sentenceOffset
    + tokenSpans[i].getEnd());

代码示例来源: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

nameAnnotations[i] = cas.createAnnotation(nameType, startIndex, endIndex);
cas.getIndexRepository().addFS(nameAnnotations[i]);

代码示例来源:origin: apache/opennlp

protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) {
 Parse[] parseChildren = parse.getChildren();
 AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length];
 // do this for all children
 for (int i = 0; i < parseChildren.length; i++) {
  parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]);
 }
 AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset +
   parse.getSpan().getStart(), offset + parse.getSpan().getEnd());
 parseAnnotation.setStringValue(mTypeFeature, parse.getType());
 if (probabilityFeature != null) {
  parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb());
 }
 ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length);
 childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length);
 parseAnnotation.setFeatureValue(childrenFeature, childrenArray);
 cas.getIndexRepository().addFS(parseAnnotation);
 return parseAnnotation;
}

代码示例来源:origin: apache/opennlp

sentences[i] = cas.createAnnotation(sentenceType,
  sentPositions[i].getStart() + containerAnnotation.getBegin(),
  sentPositions[i].getEnd() + containerAnnotation.getBegin());

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.arktools-gpl

private void createTokenAnnotation(CAS cas, int start, int end)
{
  AnnotationFS tokenAnno = cas.createAnnotation(tokenType, start, end);
  cas.addFsToIndexes(tokenAnno);
}

代码示例来源:origin: hltfbk/Excitement-Open-Platform

public static PredicateTruth mapPredicateTruth(PredTruth pt, JCas jcas, int begin, int end){
  Type type = jcas.getTypeSystem().getType(PRED_TRUTH_MAP.get(pt).getName());
  PredicateTruth ret = (PredicateTruth)jcas.getCas().createAnnotation(type, begin, end);
  return ret;
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.io-asl

private void chunkComplete()
  {
    if (openChunk != null) {
      Type chunkType = mappingProvider.getTagType(openChunk);
      AnnotationFS chunk = cas.createAnnotation(chunkType, start, end);
      chunk.setStringValue(chunkValue,
          internTags && openChunk != null ? openChunk.intern() : openChunk);
      cas.addFsToIndexes(chunk);
      openChunk = null;
    }
  }
}

代码示例来源:origin: dkpro/dkpro-core

private void chunkComplete()
  {
    if (openChunk != null) {
      Type chunkType = mappingProvider.getTagType(openChunk);
      AnnotationFS chunk = cas.createAnnotation(chunkType, start, end);
      chunk.setStringValue(chunkValue,
          internTags && openChunk != null ? openChunk.intern() : openChunk);
      cas.addFsToIndexes(chunk);
      openChunk = null;
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.io-asl

private void chunkComplete()
  {
    if (openChunk != null) {
      Type chunkType = mappingProvider.getTagType(openChunk);
      AnnotationFS chunk = cas.createAnnotation(chunkType, start, end);
      chunk.setStringValue(chunkValue,
          internTags && openChunk != null ? openChunk.intern() : openChunk);
      cas.addFsToIndexes(chunk);
      openChunk = null;
    }
  }
}

代码示例来源:origin: dkpro/dkpro-core

private void chunkComplete()
  {
    if (openChunk != null) {
      Type chunkType = mappingProvider.getTagType(openChunk);
      AnnotationFS chunk = cas.createAnnotation(chunkType, start, end);
      chunk.setStringValue(chunkValue,
          internTags && openChunk != null ? openChunk.intern() : openChunk);
      cas.addFsToIndexes(chunk);
      openChunk = null;
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.treetagger-asl

private void chunkComplete()
  {
    if (openChunk != null) {
      Type chunkType = mappingProvider.getTagType(openChunk);
      Chunk chunk = (Chunk) cas.createAnnotation(chunkType, start, end);
      chunk.setChunkValue(openChunk.intern());
      cas.addFsToIndexes(chunk);
      openChunk = null;
    }
  }
};

代码示例来源:origin: fr.univ-nantes.julestar/uima-tree-tagger-wrapper

private void annotate(CAS cas, Feature feature, int begin, int end, String value) {
  Type type = feature.getDomain();
  AnnotationFS annotation = cas.createAnnotation(type, begin, end);
  annotation.setStringValue(feature,value);
  cas.addFsToIndexes(annotation);
}

代码示例来源:origin: de.unidue.ltl.flextag/flextag-core

private POS createPartOfSpeechAnnotationFromOutcome(JCas aJCas, int begin, int end,
    String aOutcome)
{
  Type posTag = mappingProvider.getTagType(aOutcome);
  POS posAnno = (POS) aJCas.getCas().createAnnotation(posTag, begin, end);
  posAnno.setPosValue(aOutcome);
  posAnno.addToIndexes();
  return posAnno;
}

代码示例来源:origin: org.apache.uima/textmarker-core

public TextMarkerBasic getNextBasic2(AnnotationFS previous) {
 AnnotationFS pointer = cas
     .createAnnotation(basicType, previous.getEnd() - 1, previous.getEnd());
 currentIt.moveTo(pointer);
 if (currentIt.isValid()) {
  TextMarkerBasic basic = (TextMarkerBasic) currentIt.get();
  return basic;
 }
 return null;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

/**
 * Create a new link annotation. Already adds the chain to the CAS.
 */
private AnnotationFS newLink(JCas aJCas, int aBegin, int aEnd)
{
  Type linkType = CasUtil.getType(aJCas.getCas(), getAnnotationTypeName());
  AnnotationFS newLink = aJCas.getCas().createAnnotation(linkType, aBegin, aEnd);
  aJCas.getCas().addFsToIndexes(newLink);
  return newLink;
}

代码示例来源:origin: webanno/webanno

private AnnotationFS createPOSAnno(JCas aJCas, String aValue, int aBegin, int aEnd)
{
  Type type = aJCas.getTypeSystem().getType(POS.class.getTypeName());
  
  AnnotationFS clickedFs = aJCas.getCas().createAnnotation(type, aBegin, aEnd);
  Feature posValue = type.getFeatureByBaseName("PosValue");
  clickedFs.setStringValue(posValue, aValue);
  aJCas.addFsToIndexes(clickedFs);
  return clickedFs;
}

代码示例来源:origin: webanno/webanno

private static AnnotationFS makeLinkHostFS(JCas aJCas, String aType, int aBegin, int aEnd,
    FeatureStructure... aLinks)
{
  Type hostType = aJCas.getTypeSystem().getType(aType);
  AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
  if (aLinks != null) {
    hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
        FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
  }
  aJCas.getCas().addFsToIndexes(hostA1);
  return hostA1;
}

代码示例来源:origin: webanno/webanno

public static void makeLinkHostFS(JCas aJCas, int aBegin, int aEnd, FeatureStructure... aLinks)
{
  Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE);
  AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd);
  hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"),
      FSCollectionFactory.createFSArray(aJCas, asList(aLinks)));
  aJCas.getCas().addFsToIndexes(hostA1);
}

相关文章