org.apache.uima.cas.text.AnnotationIndex.size()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(73)

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

AnnotationIndex.size介绍

暂无

代码示例

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

@Override
 public int size() {
  return index.size();
 }
}

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

public long getHistogram(Type type) {
 return cas.getAnnotationIndex(type).size();
}

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

public int getHistogram(Type type) {
 return cas.getAnnotationIndex(type).size();
}

代码示例来源:origin: CLLKazan/UIMA-Ext

@SuppressWarnings("unchecked")
public static <A extends AnnotationFS> A getSingleAnnotation(JCas cas, Class<A> typeJCasClass) {
  Type annoType = CasUtil.getAnnotationType(cas.getCas(), typeJCasClass);
  AnnotationIndex<Annotation> annoIdx = cas.getAnnotationIndex(annoType);
  if (annoIdx.size() == 0) {
    return null;
  } else if (annoIdx.size() == 1) {
    return (A) annoIdx.iterator().next();
  } else {
    throw new IllegalStateException(String.format(
        "Too much (>1) annotations of type %s", annoType));
  }
}

代码示例来源:origin: HeidelTime/heideltime

/**
 * Runs the IntervalTagger on the JCAS object.
 * @param jcas jcas object
 */
private void runIntervalTagger(JCas jcas) {
  logger.log(Level.FINEST, "Running Interval Tagger...");
  Integer beforeAnnotations = jcas.getAnnotationIndex().size();
  
  // Prepare the options for IntervalTagger's execution
  Properties settings = new Properties();
  settings.put(IntervalTagger.PARAM_LANGUAGE, language.getResourceFolder());
  settings.put(IntervalTagger.PARAM_INTERVALS, true);
  settings.put(IntervalTagger.PARAM_INTERVAL_CANDIDATES, false);
  
  // Instantiate and process with IntervalTagger
  IntervalTaggerWrapper iTagger = new IntervalTaggerWrapper();
  iTagger.initialize(settings);
  iTagger.process(jcas);
  
  // debug output
  Integer afterAnnotations = jcas.getAnnotationIndex().size();
  logger.log(Level.FINEST, "Annotation delta: " + (afterAnnotations - beforeAnnotations));
}

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

private void saveEntities( final JCas jcas, final int encounterNum, final long patientNum, final String providerId,
             final Timestamp startDate ) throws SQLException {
 final AnnotationIndex<Annotation> identifiedsIndex = jcas.getAnnotationIndex( IdentifiedAnnotation.type );
 if ( identifiedsIndex == null || identifiedsIndex.size() == 0 ) {
   return;

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

private void saveEntities( final JCas jcas, final int encounterNum, final long patientNum, final String providerId,
             final Timestamp startDate ) throws SQLException {
 final AnnotationIndex<Annotation> identifiedsIndex = jcas.getAnnotationIndex( IdentifiedAnnotation.type );
 if ( identifiedsIndex == null || identifiedsIndex.size() == 0 ) {
   return;

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

private static JCas getViewWithGoldAnnotations(JCas correspondingCasThatHasGoldAnnotations) {
  JCas viewWithPreexistingGoldAnnotations = null;
  try {
    viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations.getView(AssertionEvaluation.GOLD_VIEW_NAME);
  } catch (org.apache.uima.cas.CASRuntimeException cre) {
    // Let it just continue if there's an exception and check for null later
  } catch (org.apache.uima.cas.CASException viewException) {
    // Let it just continue if there's an exception and check for null later
  } catch (NullPointerException npe) {
    // Let it just continue if there's an exception and check for null later
  }
  if (viewWithPreexistingGoldAnnotations == null) {
    viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations;
    LOGGER.debug("Using view " + viewWithPreexistingGoldAnnotations.getViewName());
    int n  = viewWithPreexistingGoldAnnotations.getAnnotationIndex().size();
    LOGGER.debug("With " + n + " annotations");
    if (n==0) {
      Iterator<CAS> iter = viewWithPreexistingGoldAnnotations.getCas().getViewIterator();
      while (iter.hasNext()) {
        CAS cas = iter.next();
        LOGGER.debug("view " + cas.getViewName() + " has " + cas.getAnnotationIndex().size() + " indexed annotations.");
        
      }
      throw new RuntimeException("n==0");
    }
  }
  return viewWithPreexistingGoldAnnotations;
}

代码示例来源:origin: CLLKazan/UIMA-Ext

private void process(CAS cas, PrintWriter out) {
  AnnotationIndex<AnnotationFS> tokenIdx = cas.getAnnotationIndex(tokenType);
  Multimap<AnnotationFS, String> tokLabelsMap = HashMultimap.create(tokenIdx.size(), 1);

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

private static JCas getViewWithGoldAnnotations(JCas correspondingCasThatHasGoldAnnotations) {
  JCas viewWithPreexistingGoldAnnotations = null;
  try {
    viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations.getView(AssertionEvaluation.GOLD_VIEW_NAME);
  } catch (org.apache.uima.cas.CASRuntimeException cre) {
    // Let it just continue if there's an exception and check for null later
  } catch (org.apache.uima.cas.CASException viewException) {
    // Let it just continue if there's an exception and check for null later
  } catch (NullPointerException npe) {
    // Let it just continue if there's an exception and check for null later
  }
  if (viewWithPreexistingGoldAnnotations == null) {
    viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations;
    LOGGER.debug("Using view " + viewWithPreexistingGoldAnnotations.getViewName());
    int n  = viewWithPreexistingGoldAnnotations.getAnnotationIndex().size();
    LOGGER.debug("With " + n + " annotations");
    if (n==0) {
      Iterator<CAS> iter = viewWithPreexistingGoldAnnotations.getCas().getViewIterator();
      while (iter.hasNext()) {
        CAS cas = iter.next();
        LOGGER.debug("view " + cas.getViewName() + " has " + cas.getAnnotationIndex().size() + " indexed annotations.");
        
      }
      throw new RuntimeException("n==0");
    }
  }
  return viewWithPreexistingGoldAnnotations;
}

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

/**
 * returns the number of annotations of specified type in the 
 */
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  ann.removeFromIndexes();
  return annIdx.size();
}

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

/**
 * returns the number of annotations of specified type in the 
 */
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  ann.removeFromIndexes();
  return annIdx.size();
}

代码示例来源:origin: CLLKazan/UIMA-Ext

/**
 * @param cas
 * @param type
 * @param feature
 * @return feature value of the first annotation of given type from given
 *         CAS. E.g., it is useful to get document metadata values. If there
 *         is no such annotation method will return null.
 */
public static String getStringValue(CAS cas, Type type, Feature feature) {
  AnnotationIndex<AnnotationFS> metaIdx = cas.getAnnotationIndex(type);
  if (metaIdx.size() > 0) {
    AnnotationFS meta = metaIdx.iterator().next();
    return meta.getFeatureValueAsString(feature);
  } else {
    return null;
  }
}

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

return;
final Collection<String> tokenizedSentences = new ArrayList<>( sentences.size() );
try {
  for ( Object sentence : sentences ) {

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

try {
 jCas = cas.getJCas();
 size = jCas.getAnnotationIndex(TokenSeed.type).size();
 result = jCas.getTypeSystem().getType(seedType);
} catch (CASException e) {

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

.getAnnotationIndex(annotationType);
int totalAnnotationCount = jcas.getAnnotationIndex().size();
int typeSpecificAnnotationCount = annotationIndex.size();

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

return;
final Collection<String> tokenizedSentences = new ArrayList<>( sentences.size() );
try {
  for ( Object sentence : sentences ) {

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

public static void addSourceDocumentInformation(CAS cas, File each) {
 Type sdiType = cas.getTypeSystem()
     .getType("org.apache.uima.examples.SourceDocumentInformation");
 if (sdiType != null) {
  if (cas.getAnnotationIndex(sdiType).size() == 0) {
   AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(),
       cas.getDocumentAnnotation().getEnd());
   Feature uriFeature = sdiType.getFeatureByBaseName("uri");
   sdi.setStringValue(uriFeature, each.toURI().getPath());
   cas.addFsToIndexes(sdi);
  }
 }
}

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

public static void addSourceDocumentInformation(CAS cas, File each) {
 Type sdiType = cas.getTypeSystem()
     .getType("org.apache.uima.examples.SourceDocumentInformation");
 if (sdiType != null) {
  if (cas.getAnnotationIndex(sdiType).size() == 0) {
   AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(),
       cas.getDocumentAnnotation().getEnd());
   Feature uriFeature = sdiType.getFeatureByBaseName("uri");
   sdi.setStringValue(uriFeature, each.toURI().getPath());
   cas.addFsToIndexes(sdi);
  }
 }
}

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

@Override
public EvaluatedCondition eval(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
 RuleElement element = context.getElement();
 int count = 0;
 Type t = type.getType(context, stream);
 AnnotationIndex<Annotation> annotationIndex = stream.getJCas().getAnnotationIndex(t);
 count = annotationIndex.size();
 if (var != null) {
  element.getParent().getEnvironment().setVariableValue(var, count);
 }
 boolean value = count >= min.getIntegerValue(context, stream)
     && count <= max.getIntegerValue(context, stream);
 return new EvaluatedCondition(this, value);
}

相关文章

微信公众号

最新文章

更多