当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationStatistics.annotationToFeatureValue方法代码示例

本文整理汇总了Java中org.cleartk.eval.AnnotationStatistics.annotationToFeatureValue方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationStatistics.annotationToFeatureValue方法的具体用法?Java AnnotationStatistics.annotationToFeatureValue怎么用?Java AnnotationStatistics.annotationToFeatureValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cleartk.eval.AnnotationStatistics的用法示例。


在下文中一共展示了AnnotationStatistics.annotationToFeatureValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ModelInfo

import org.cleartk.eval.AnnotationStatistics; //导入方法依赖的package包/类
public ModelInfo(
    Class<ANNOTATION_TYPE> annotatedClass,
    String annotatedFeatureName,
    Function<ANNOTATION_TYPE, ? extends Object> getSpan,
    CleartkInternalModelFactory modelFactory,
    String[] trainingArguments) {
  this.annotatedClass = annotatedClass;
  this.annotatedFeatureName = annotatedFeatureName;
  this.getSpan = getSpan;
  if (this.annotatedFeatureName == null) {
    this.getOutcome = AnnotationStatistics.annotationToNull();
  } else {
    this.getOutcome = AnnotationStatistics.annotationToFeatureValue(this.annotatedFeatureName);
  }
  this.modelFactory = modelFactory;
  this.trainingArguments = trainingArguments;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:18,代码来源:ModelInfo.java

示例2: test

import org.cleartk.eval.AnnotationStatistics; //导入方法依赖的package包/类
@Override
protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
    throws Exception {
  AnnotationStatistics<String> stats = new AnnotationStatistics<String>();

  // Create the document classification pipeline
  AggregateBuilder builder = DocumentClassificationEvaluation.createDocumentClassificationAggregate(
      directory,
      AnnotatorMode.TEST);
  AnalysisEngine engine = builder.createAggregate();

  // Run and evaluate
  Function<UsenetDocument, ?> getSpan = AnnotationStatistics.annotationToSpan();
  Function<UsenetDocument, String> getCategory = AnnotationStatistics.annotationToFeatureValue("category");
  JCasIterator iter = new JCasIterator(collectionReader, engine);
  while (iter.hasNext()) {
    JCas jCas = iter.next();
    JCas goldView = jCas.getView(GOLD_VIEW_NAME);
    JCas systemView = jCas.getView(DocumentClassificationEvaluation.SYSTEM_VIEW_NAME);

    // Get results from system and gold views, and update results accordingly
    Collection<UsenetDocument> goldCategories = JCasUtil.select(goldView, UsenetDocument.class);
    Collection<UsenetDocument> systemCategories = JCasUtil.select(
        systemView,
        UsenetDocument.class);
    stats.add(goldCategories, systemCategories, getSpan, getCategory);
  }

  return stats;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:31,代码来源:DocumentClassificationEvaluation.java

示例3: test

import org.cleartk.eval.AnnotationStatistics; //导入方法依赖的package包/类
@Override
protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory) throws Exception {
  AnnotationStatistics<String> stats = new AnnotationStatistics<String>();

  AggregateBuilder builder = new AggregateBuilder();

  final String defaultViewName = CAS.NAME_DEFAULT_SOFA;
  final String goldViewName = "GoldView";
  builder.add(AnalysisEngineFactory.createEngineDescription(ViewCreatorAnnotator.class,
      ViewCreatorAnnotator.PARAM_VIEW_NAME, goldViewName));
  builder.add(UriToDocumentTextAnnotator.getDescription(), defaultViewName, goldViewName);
  builder.add(AnalysisEngineFactory.createEngineDescription(GoldQuestionCategoryAnnotator.class), defaultViewName,
      goldViewName);
  builder.add(UriToDocumentTextAnnotator.getDescription());
  builder.add(SentenceAnnotator.getDescription());
  builder.add(TokenAnnotator.getDescription());
  builder.add(PosTaggerAnnotator.getDescription());
  builder.add(DefaultSnowballStemmer.getDescription("English"));
  AnalysisEngineDescription documentClassificationAnnotator = AnalysisEngineFactory.createEngineDescription(
      QuestionCategoryAnnotator.class, CleartkAnnotator.PARAM_IS_TRAINING, false,
      GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, JarClassifierBuilder.getModelJarFile(directory));
  builder.add(documentClassificationAnnotator);

  AnalysisEngine engine = builder.createAggregate();

  // Run and evaluate
  Function<QuestionCategoryAnnotation, ?> getSpan = AnnotationStatistics.annotationToSpan();
  Function<QuestionCategoryAnnotation, String> getCategory =
      AnnotationStatistics.annotationToFeatureValue("category");
  JCasIterator iter = new JCasIterator(collectionReader, engine);
  while (iter.hasNext()) {
    JCas jCas = iter.next();
    JCas goldView = jCas.getView(goldViewName);
    JCas systemView = jCas.getView(defaultViewName);
    // Get results from system and gold views, and update results accordingly
    Collection<QuestionCategoryAnnotation> goldCategories =
        JCasUtil.select(goldView, QuestionCategoryAnnotation.class);
    Collection<QuestionCategoryAnnotation> systemCategories =
        JCasUtil.select(systemView, QuestionCategoryAnnotation.class);
    stats.add(goldCategories, systemCategories, getSpan, getCategory);
  }

  return stats;
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:45,代码来源:QuestionCategoryEvaluation.java

示例4: test

import org.cleartk.eval.AnnotationStatistics; //导入方法依赖的package包/类
@Override
protected AnnotationStatistics<String> test(CollectionReader collectionReader, File modelDirectory)
    throws Exception {

  final String defaultViewName = CAS.NAME_DEFAULT_SOFA;
  final String goldViewName = "GoldView";

  // define the pipeline
  AggregateBuilder aggregate = new AggregateBuilder();

  // Annotators processing the gold view:
  // * create the gold view
  // * load the text
  // * load the MASC annotations
  aggregate.add(AnalysisEngineFactory.createEngineDescription(
      ViewCreatorAnnotator.class,
      ViewCreatorAnnotator.PARAM_VIEW_NAME,
      goldViewName));
  aggregate.add(UriToDocumentTextAnnotator.getDescription(), defaultViewName, goldViewName);
  aggregate.add(MascGoldAnnotator.getDescription(), defaultViewName, goldViewName);

  // Annotators processing the default (system) view:
  // * load the text
  // * parse sentences, tokens, part-of-speech tags
  // * run the named entity chunker
  aggregate.add(UriToDocumentTextAnnotator.getDescription());
  aggregate.add(SentenceAnnotator.getDescription());
  aggregate.add(TokenAnnotator.getDescription());
  aggregate.add(PosTaggerAnnotator.getDescription());
  aggregate.add(AnalysisEngineFactory.createEngineDescription(
      NamedEntityChunker.class,
      CleartkSequenceAnnotator.PARAM_IS_TRAINING,
      false,
      GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
      JarClassifierBuilder.getModelJarFile(modelDirectory)));

  // prepare the evaluation statistics
  AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
  Function<NamedEntityMention, ?> getSpan = AnnotationStatistics.annotationToSpan();
  Function<NamedEntityMention, String> getCategory = AnnotationStatistics.annotationToFeatureValue("mentionType");

  // iterate over each JCas to be evaluated
  JCasIterator iter = new JCasIterator(collectionReader, aggregate.createAggregate());
  while (iter.hasNext()) {
    JCas jCas = iter.next();
    JCas goldView = jCas.getView(goldViewName);
    JCas systemView = jCas.getView(defaultViewName);

    // extract the named entity mentions from both gold and system views
    Collection<NamedEntityMention> goldMentions, systemMentions;
    goldMentions = JCasUtil.select(goldView, NamedEntityMention.class);
    systemMentions = JCasUtil.select(systemView, NamedEntityMention.class);

    // compare the system mentions to the gold mentions
    stats.add(goldMentions, systemMentions, getSpan, getCategory);
  }

  return stats;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:60,代码来源:EvaluateNamedEntityChunker.java


注:本文中的org.cleartk.eval.AnnotationStatistics.annotationToFeatureValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。