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

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

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

CAS.getAnnotationIndex介绍

[英]Get the standard annotation index.
[中]获取标准注释索引。

代码示例

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

/**
 * Performs parsing on the given {@link CAS} object.
 */
public void process(CAS cas) {
 FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(mSentenceType);
 for (AnnotationFS sentence : sentences) {
  process(cas, sentence);
 }
}

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

.getAnnotationIndex(removeAnnotationType);

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

public void process(CAS cas) {

  FSIterator<AnnotationFS> tokenAnnotations = cas.getAnnotationIndex(mTokenType).iterator();
  List<String> tokensList = new ArrayList<>();

  while (tokenAnnotations.hasNext()) {
   tokensList.add(tokenAnnotations.next().getCoveredText());
  }

  double[] result =
    mCategorizer.categorize(tokensList.toArray(new String[tokensList.size()]));

  String bestCategory = mCategorizer.getBestCategory(result);

  setBestCategory(cas, bestCategory);
 }
}

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

FSIndex<AnnotationFS> tokenAnnotationIndex = tcas.getAnnotationIndex(mTokenType);

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

/**
 * Create a new combo iterator.
 *
 * @param cas
 *          The CAS we're operating on.
 * @param upper
 *          The type of the upper iterator, e.g., sentence.
 * @param lower
 *          The type of the lower iterator, e.g., token.
 */
public AnnotationComboIterator(CAS cas, Type upper, Type lower) {
 this.upperIt = cas.getAnnotationIndex(upper).iterator();
 this.lowerIt = cas.getAnnotationIndex(lower).iterator();
 this.upperIt.moveToFirst();
 this.lowerIt.moveToFirst();
 if (this.upperIt.isValid()) {
  final AnnotationFS upperFS = this.upperIt.get();
  this.upperBegin = upperFS.getBegin();
  this.upperEnd = upperFS.getEnd();
 } else {
  this.nextLowerChecked = true;
 }
}

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

@Override
public void process(CAS cas) throws AnalysisEngineProcessException {
 FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(sentenceType);

代码示例来源: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 void process(CAS cas, AnnotationFS sentenceAnnotation) {
 FSIndex<AnnotationFS> allTokens = cas.getAnnotationIndex(mTokenType);
 ContainingConstraint containingConstraint =
   new ContainingConstraint(sentenceAnnotation);
 String sentence = sentenceAnnotation.getCoveredText();
 Iterator<AnnotationFS> containingTokens = cas.createFilteredIterator(
   allTokens.iterator(), containingConstraint);
 List<Span> tokenSpans = new LinkedList<>();
 while (containingTokens.hasNext()) {
  AnnotationFS token = containingTokens.next();
  tokenSpans.add(new Span(token.getBegin() - sentenceAnnotation.getBegin(),
    token.getEnd() - sentenceAnnotation.getBegin()));
 }
 ParseConverter converter = new ParseConverter(sentence, tokenSpans.toArray(new Span[tokenSpans.size()]));
 Parse unparsedTree = converter.getParseForTagger();
 if (unparsedTree.getChildCount() > 0) {
  Parse parse = mParser.parse(unparsedTree);
  // TODO: We need a strategy to handle the case that a full
  //       parse could not be found. What to do in this case?
  parse = converter.transformParseFromTagger(parse);
  if (mLogger.isLoggable(Level.INFO)) {
   StringBuffer parseString = new StringBuffer();
   parse.show(parseString);
   mLogger.log(Level.INFO, parseString.toString());
  }
  createAnnotation(cas, sentenceAnnotation.getBegin(), parse);
 }
}

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

public void process(CAS tcas) {
 FSIndex<AnnotationFS> sentenceIndex = tcas.getAnnotationIndex(mNameType);

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

.getAnnotationIndex(containerType);

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

/**
 * Performs parsing on the given {@link CAS} object.
 */
public void process(CAS cas) {
 FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(mSentenceType);
 for (AnnotationFS sentence : sentences) {
  process(cas, sentence);
 }
}

代码示例来源:origin: Ailab403/ailab-mltk4j

/**
 * Process the given CAS object.
 */
public void processCas(CAS cas) {
 
 FSIndex<AnnotationFS> sentenceIndex = cas.getAnnotationIndex(mSentenceType);
 for (AnnotationFS sentenceAnnotation : sentenceIndex) {
  processSentence(cas, sentenceAnnotation);
 }
}

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

private void updateIterators(CAS cas, Type basicType, FilterManager filter,
    AnnotationFS additionalWindow) {
 if (additionalWindow != null) {
  this.basicIt = cas.getAnnotationIndex(basicType).subiterator(additionalWindow);
 } else {
  this.basicIt = cas.getAnnotationIndex(basicType).iterator();
 }
 currentIt = filter.createFilteredIterator(cas, basicType);
}

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

private void updateIterators(CAS cas, Type basicType, FilterManager filter,
    AnnotationFS additionalWindow) {
 if (additionalWindow != null) {
  this.basicIt = cas.getAnnotationIndex(basicType).subiterator(additionalWindow);
 } else {
  this.basicIt = cas.getAnnotationIndex(basicType).iterator();
 }
 currentIt = filter.createFilteredIterator(cas, basicType);
}

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

public List<AnnotationFS> getAllofType(Type type) {
 List<AnnotationFS> result = new ArrayList<AnnotationFS>();
 FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(type).iterator();
 while (iterator.isValid()) {
  FeatureStructure featureStructure = iterator.get();
  result.add((AnnotationFS) featureStructure);
  iterator.moveToNext();
 }
 return result;
}

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

public List<AnnotationFS> getAllofType(Type type) {
 List<AnnotationFS> result = new ArrayList<AnnotationFS>();
 FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(type).iterator();
 while (iterator.isValid()) {
  FeatureStructure featureStructure = iterator.get();
  result.add((AnnotationFS) featureStructure);
  iterator.moveToNext();
 }
 return result;
}

代码示例来源:origin: Ailab403/ailab-mltk4j

private void processSentence(CAS tcas, AnnotationFS sentence) {
 FSIndex<AnnotationFS> chunkIndex = tcas.getAnnotationIndex(mChunkType);
 
 ContainingConstraint containingConstraint = 
  new ContainingConstraint(sentence);
 Iterator<AnnotationFS> chunkIterator = tcas.createFilteredIterator(
   chunkIndex.iterator(), containingConstraint);
 
 while (chunkIterator.hasNext()) {
  AnnotationFS chunkAnnotation = (AnnotationFS) chunkIterator.next();
  processChunk(tcas, (chunkAnnotation));
 }
}

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

public void process(CAS cas) {

  FSIterator<AnnotationFS> tokenAnnotations = cas.getAnnotationIndex(mTokenType).iterator();
  List<String> tokensList = new ArrayList<>();

  while (tokenAnnotations.hasNext()) {
   tokensList.add(tokenAnnotations.next().getCoveredText());
  }

  double[] result =
    mCategorizer.categorize(tokensList.toArray(new String[tokensList.size()]));

  String bestCategory = mCategorizer.getBestCategory(result);

  setBestCategory(cas, bestCategory);
 }
}

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

@SuppressWarnings("unchecked")
  public static <T extends AnnotationFS> FeaturePathIterator<T> create(CAS aCas, Type aType,
      String aPath)
    throws FeaturePathException
  {
    FSIterator<T> iterator = ((AnnotationIndex<T>) aCas.getAnnotationIndex(aType))
        .iterator();
    final FeaturePathInfo fp = new FeaturePathInfo();
    fp.initialize(aPath);
    return new FeaturePathIterator<T>(iterator, fp);
  }
}

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

public static FeatureStructure getTcasFS(CAS aCasView, String aTypeS) {
 org.apache.uima.cas.FeatureStructure idFS = null;
 Type type = aCasView.getTypeSystem().getType(aTypeS);
 if (type != null) {
  FSIterator<AnnotationFS> idIter = aCasView.getAnnotationIndex(type).iterator();
  while (idIter.isValid()) {
   idFS = idIter.get();
   idIter.moveToNext();
  }
 }
 return idFS;
}

相关文章