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

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

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

CAS.addFsToIndexes介绍

[英]Add a feature structure to all appropriate indexes in the repository associated with this CAS View. If no indexes exist for the type of FS that you are adding, then a bag (unsorted) index will be automatically created.

Important: after you have called addFsToIndexes(...) on a FS, do not change the values of any features used for indexing. If you do, the index will become corrupted and may be unusable. If you need to change an index feature value, first call #removeFsFromIndexes(FeatureStructure) on the FS, change the feature values, then call addFsToIndexes(...) again.
[中]将功能结构添加到与此CAS视图关联的存储库中的所有适当索引中。如果添加的FS类型不存在索引,则会自动创建一个行李(未排序)索引。
重要提示:在FS上调用addFsToIndexes(...)后,不要更改用于索引的任何功能的值。如果这样做,索引将损坏,并且可能无法使用。如果需要更改索引特征值,请首先在FS上调用#removeFsFromIndexes(FeatureStructure),更改特征值,然后再次调用addFsToIndexes(...)

代码示例

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

protected void documentDone(CAS cas) {
 // TODO: Create confidence FS
 // contains String name type
 // contains Double prob
 if (documentConfidenceType != null) {
  FeatureStructure confidenceFS = cas.createFS(documentConfidenceType);
  confidenceFS.setDoubleValue(documentConfidenceFeature,
    documentConfidence.mean());
  confidenceFS.setStringValue(documentConfidenceNameTypeFeature,
    mNameType.getName());
  cas.addFsToIndexes(confidenceFS);
 }
 // Clears the adaptive data which was created for the current document
 mNameFinder.clearAdaptiveData();
 documentConfidence = new Mean();
}

代码示例来源: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: org.apache.uima/textmarker-core

public void addAnnotation(AnnotationFS annotation, boolean addToIndex, RuleMatch creator) {
 if (addToIndex) {
  cas.addFsToIndexes(annotation);
 }
 addAnnotation(annotation, creator);
}

代码示例来源:origin: UKPLab/argument-reasoning-comprehension-task

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

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

@Override
public void finished(RutaStream stream, List<RutaInferenceVisitor> visitors) {
 for (FeatureStructure each : fsList) {
  each.getCAS().addFsToIndexes(each);
 }
}

代码示例来源:origin: apache/uima-uimaj

/**
 * add this FS to indexes in a specific view, perhaps different from the creation view
 * @param jcas the JCas
 */
public void addToIndexes(JCas jcas) {
  jcas.getCas().addFsToIndexes(this);
}

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

public void finished(TextMarkerStream stream, List<TextMarkerInferenceVisitor> visitors) {
 for (FeatureStructure each : fsList) {
  each.getCAS().addFsToIndexes(each);
 }
}

代码示例来源:origin: nlpie/biomedicus

/**
  * Copies a generic {@code FeatureStructure} to another of the same type.
  *
  * @param from {@code FeatureStructure} to copy from.
  * @param to {@code FeatureStructure} to copy to.
  */
 public void copy(FeatureStructure from, FeatureStructure to) {
  fsCopiers.getOrDefault(from.getType().getName(), this::defaultCopy).accept(from, to);
  to.getCAS().addFsToIndexes(to);
 }
}

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

private RutaBasic createRutaBasic(int begin, int end) {
 RutaBasic newTMB = new RutaBasic(getJCas(), begin, end);
 newTMB.setLowMemoryProfile(lowMemoryProfile);
 beginAnchors.put(begin, newTMB);
 endAnchors.put(end, newTMB);
 cas.addFsToIndexes(newTMB);
 return newTMB;
}

代码示例来源: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: 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: 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: 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.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: de.unistuttgart.ims/uimautil

public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) {
    if (JCasUtil.exists(jcas, targetClass)) {
      return JCasUtil.selectSingle(jcas, targetClass);
    } else {
      T annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass));
      jcas.getCas().addFsToIndexes(annotation);
      return annotation;
    }
  }
}

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

private static void makeChainHead(Type aType, AnnotationFS first)
{
  CAS cas = first.getCAS();
  FeatureStructure h = cas.createFS(aType);
  FSUtil.setFeature(h, "first", first);
  cas.addFsToIndexes(h);
}

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

private static AnnotationFS makeChainLink(Type aType, CAS aCas,
    int aBegin, int aEnd, String aLabel, String aLinkLabel, AnnotationFS aNext)
{
  AnnotationFS link = aCas.createAnnotation(aType, aBegin, aEnd);
  FSUtil.setFeature(link, "next", aNext);
  FSUtil.setFeature(link, "referenceType", aLabel);
  FSUtil.setFeature(link, "referenceRelation", aLinkLabel);
  aCas.addFsToIndexes(link);
  return link;
}

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

public static AnnotationFS makeLinkHostMultiSPanFeatureFS(JCas aJCas, int aBegin, int aEnd,
    Feature aSpanFeature, String aValue, 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)));
  hostA1.setStringValue(aSpanFeature, aValue);
  aJCas.getCas().addFsToIndexes(hostA1);
  return hostA1;
}

相关文章