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

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

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

CAS.getIndexRepository介绍

[英]Get the index repository.
[中]获取索引存储库。

代码示例

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

+ tokenSpans[i].getEnd());
cas.getIndexRepository().addFS(tokenAnnotations[i]);

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

cas.getIndexRepository().addFS(nameAnnotations[i]);

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

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

sentPositions[i].getEnd() + containerAnnotation.getBegin());
cas.getIndexRepository().addFS(sentences[i]);

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

public static IndexInfo[] getIndexes(CAS cas) {
 Iterator<String> it = cas.getIndexRepository().getLabels();
 List<IndexInfo> ll = new ArrayList<IndexInfo>();
 while (it.hasNext()) {
  ll.add(new IndexInfo(cas, it.next()));
 }
 return ll.toArray(new IndexInfo[ll.size()]);
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

/**
 * Internally removes an annotation from the {@link CAS}.
 *
 * @param featureStructure the feature structure
 */
private void removeAnnotationInternal(FeatureStructure featureStructure) {
 getCAS().getIndexRepository().removeFS(featureStructure);
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

/**
 * Internally removes an annotation from the {@link CAS}.
 *
 * @param featureStructure the feature structure
 */
private void addFeatureStructureInternal(FeatureStructure featureStructure) {
 getCAS().getIndexRepository().addFS(featureStructure);
}

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

public static Set<FeatureStructure> collectIndexed(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>(Comparator.comparingInt(llcas::ll_getFSRef));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fses::add);
  return fses;
}

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

public static Set<FeatureStructure> collectReachable(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>(Comparator.comparingInt(llcas::ll_getFSRef));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fs -> collect(fses, fs));
  return fses;
}

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

public Object getSubTypes() {
 FSIndexRepository ir = cas.getIndexRepository();
 Type type = fsIndex.getType();
 List<Type> subtypes = cas.getTypeSystem().getProperlySubsumedTypes(type);
 DebugNameValuePair[] r = new DebugNameValuePair[subtypes.size()];
 int i = 0;
 Iterator<Type> it = subtypes.iterator();
 while (it.hasNext()) {
  Type stype = it.next();
  r[i++] = new DebugNameValuePair("Type: " + stype.getName(),
      new UnexpandedFeatureStructures(ir.getIndex(indexName, stype)));
 }
 return r;
}

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

public static Set<FeatureStructure> collectIndexed(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1)
      - llcas.ll_getFSRef(fs2));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fs -> fses.add(fs));
  return fses;
}

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

public static Set<FeatureStructure> collectIndexed(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1)
      - llcas.ll_getFSRef(fs2));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fs -> fses.add(fs));
  return fses;
}

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

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: de.tudarmstadt.ukp.dkpro.argumentation.types/de.tudarmstadt.ukp.dkpro.argumentation.types

/**
 * Returns {@code true} if {@code jCas} contains {@link WebArgumentMetadata}
 *
 * @param jCas jCas
 * @return boolean
 */
public static boolean hasWebArgumentMetadata(final JCas jCas)
{
  FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS(
      CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class));
  return iterator.hasNext();
}

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

public static Set<FeatureStructure> collectReachable(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1)
      - llcas.ll_getFSRef(fs2));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fs -> collect(fses, fs));
  return fses;
}

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

public static Set<FeatureStructure> collectReachable(CAS aCas)
{
  LowLevelCAS llcas = aCas.getLowLevelCAS();
  Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1)
      - llcas.ll_getFSRef(fs2));
  FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
      aCas.getTypeSystem().getTopType());
  i.forEachRemaining(fs -> collect(fses, fs));
  return fses;
}

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

@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: nlpie/biomedicus

public static void copyFeatureStructuresOfType(String typeName, CAS sourceView,
  CAS destinationView) {
 FeatureStructureCopyingQueue featureStructureCopyingQueue = new FeatureStructureCopyingQueue(
   sourceView,
   destinationView);
 FSIterator<FeatureStructure> iterator = sourceView.getIndexRepository()
   .getAllIndexedFS(sourceView.getTypeSystem().getType(typeName));
 while (iterator.hasNext()) {
  FeatureStructure featureStructure = iterator.get();
  featureStructureCopyingQueue.enqueue(featureStructure);
 }
 featureStructureCopyingQueue.run();
}

相关文章