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


Java AnnotationStatistics类代码示例

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


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

示例1: main

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Options options = CliFactory.parseArguments(Options.class, args);

  List<File> trainFiles = getFilesFromDirectory(options.getTrainDirectory());
  List<File> testFiles = getFilesFromDirectory(options.getTestDirectory());

  QuestionCategoryEvaluation evaluation =
      new QuestionCategoryEvaluation(options.getModelsDirectory(), options.getTrainingArguments());

  // Run Cross Validation
  List<AnnotationStatistics<String>> foldStats = evaluation.crossValidation(trainFiles, 2);
  AnnotationStatistics<String> crossValidationStats = AnnotationStatistics.addAll(foldStats);

  System.err.println("Cross Validation Results:");
  System.err.print(crossValidationStats);
  System.err.println();
  System.err.println(crossValidationStats.confusions());
  System.err.println();

  // Run Holdout Set
  AnnotationStatistics<String> holdoutStats = evaluation.trainAndTest(trainFiles, testFiles);
  System.err.println("Holdout Set Results:");
  System.err.print(holdoutStats);
  System.err.println();
  System.err.println(holdoutStats.confusions());
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:27,代码来源:QuestionCategoryEvaluation.java

示例2: main

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Options options = CliFactory.parseArguments(Options.class, args);

	// find training files
	List<File> allFiles = Arrays.asList(options.getTrainDirectory().listFiles(new FilenameFilter() {

		@Override
		public boolean accept(File dir, String name) {
			return name.endsWith("xmi");
		}
	}));

	AbstractEvaluation evaluator = new Evaluation(options.getModelsDirectory());
	List<AnnotationStatistics<String>> crossValidationStatsList = evaluator.crossValidation(allFiles, 5); // .trainAndTest(trainFiles,
	AnnotationStatistics<String> crossValidationStats = AnnotationStatistics.addAll(crossValidationStatsList);

	System.out.println(crossValidationStats);
	System.out.println(ClearTkUtil.toCmdLine(crossValidationStats.confusions()));
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:20,代码来源:Evaluation.java

示例3: main

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Options options = CliFactory.parseArguments(Options.class, args);

	// find training files
	List<File> trainFiles = Arrays.asList(options.getTrainDirectory().listFiles());

	System.err.println(trainFiles.toString());
	MentionDetectionEvaluation evaluator = new MentionDetectionEvaluation(options.getModelsDirectory());
	AnnotationStatistics<String> crossValidationStats = evaluator.trainAndTest(trainFiles, trainFiles);// AnnotationStatistics.addAll(foldStats);

	System.err.println("Cross Validation Results:");
	System.err.print(crossValidationStats);
	System.err.println();
	System.err.println(crossValidationStats.confusions());
	System.err.println();

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:18,代码来源:MentionDetectionEvaluation.java

示例4: main

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Options options = CliFactory.parseArguments(Options.class, args);

  // find training files
  List<File> trainFiles = new ArrayList<File>(FileUtils.listFiles(
      options.getTrainDirectory(),
      new MascTextFileFilter(),
      FileFilterUtils.falseFileFilter()));

  // run cross validation
  EvaluateNamedEntityChunker evaluator = new EvaluateNamedEntityChunker(
      options.getModelsDirectory());
  List<AnnotationStatistics<String>> foldStats = evaluator.crossValidation(trainFiles, 2);
  AnnotationStatistics<String> crossValidationStats = AnnotationStatistics.addAll(foldStats);

  System.err.println("Cross Validation Results:");
  System.err.print(crossValidationStats);
  System.err.println();
  System.err.println(crossValidationStats.confusions());
  System.err.println();

  // train and save a model using all the data
  evaluator.trainAndTest(trainFiles, Collections.<File> emptyList());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:25,代码来源:EvaluateNamedEntityChunker.java

示例5: 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

示例6: main

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Options options = CliFactory.parseArguments(Options.class, args);

  List<File> trainFiles = getFilesFromDirectory(options.getTrainDirectory());
  List<File> testFiles = getFilesFromDirectory(options.getTestDirectory());

  DocumentClassificationEvaluation evaluation = new DocumentClassificationEvaluation(
      options.getModelsDirectory(),
      options.getTrainingArguments());

  // Run Cross Validation
  List<AnnotationStatistics<String>> foldStats = evaluation.crossValidation(trainFiles, 2);
  AnnotationStatistics<String> crossValidationStats = AnnotationStatistics.addAll(foldStats);

  System.err.println("Cross Validation Results:");
  System.err.print(crossValidationStats);
  System.err.println();
  System.err.println(crossValidationStats.confusions());
  System.err.println();

  // Run Holdout Set
  AnnotationStatistics<String> holdoutStats = evaluation.trainAndTest(trainFiles, testFiles);
  System.err.println("Holdout Set Results:");
  System.err.print(holdoutStats);
  System.err.println();
  System.err.println(holdoutStats.confusions());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:28,代码来源:DocumentClassificationEvaluation.java

示例7: 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

示例8: EventModelInfo

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public EventModelInfo(
    String annotatedFeatureName,
    CleartkInternalModelFactory modelFactory,
    String[] trainingArguments) {
  super(
      Event.class,
      annotatedFeatureName,
      AnnotationStatistics.<Event> annotationToSpan(),
      modelFactory,
      trainingArguments);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:12,代码来源:EventModelInfo.java

示例9: updateStatistics

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public void updateStatistics(
    AnnotationStatistics<String> statistics,
    JCas goldView,
    JCas systemView) {
  Collection<ANNOTATION_TYPE> goldAnns = JCasUtil.select(goldView, this.annotatedClass);
  Collection<ANNOTATION_TYPE> systemAnns = JCasUtil.select(systemView, this.annotatedClass);
  statistics.add(
      goldAnns,
      systemAnns,
      this.getSpan,
      this.getOutcome);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:13,代码来源:ModelInfo.java

示例10: TimeModelInfo

import org.cleartk.eval.AnnotationStatistics; //导入依赖的package包/类
public TimeModelInfo(
    String annotatedFeatureName,
    CleartkInternalModelFactory modelFactory,
    String[] trainingArguments) {
  super(
      Time.class,
      annotatedFeatureName,
      AnnotationStatistics.<Time> annotationToSpan(),
      modelFactory,
      trainingArguments);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:12,代码来源:TimeModelInfo.java

示例11: 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

示例12: test

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

	final String silverViewName = "DP";
	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(PrepareClearTk.class,
			PrepareClearTk.PARAM_VIEW_NAME, goldViewName, PrepareClearTk.PARAM_ANNOTATION_TYPE,
			DramatisPersonae.class, PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class)));

	// Annotators processing the default (system) view:
	// * load the text
	// * parse sentences, tokens, part-of-speech tags
	// * run the named entity chunker
	aggregate.add(AnalysisEngineFactory.createEngineDescription(PrepareClearTk.class,
			PrepareClearTk.PARAM_VIEW_NAME, silverViewName, PrepareClearTk.PARAM_ANNOTATION_TYPE,
			DramatisPersonae.class, PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class)));
	aggregate.add(AnalysisEngineFactory.createEngineDescription(BreakIteratorSegmenter.class,
			BreakIteratorSegmenter.PARAM_WRITE_SENTENCE, false), CAS.NAME_DEFAULT_SOFA, silverViewName);
	aggregate.add(
			AnalysisEngineFactory.createEngineDescription(tagger, CleartkSequenceAnnotator.PARAM_IS_TRAINING, false,
					GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
					JarClassifierBuilder.getModelJarFile(modelDirectory)),
			CAS.NAME_DEFAULT_SOFA, silverViewName);
	aggregate.add(AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
			"target/debug/", XmiWriter.PARAM_USE_DOCUMENT_ID, true));

	// prepare the evaluation statistics
	AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
	// Function<FigureMention, ?> getSpan =
	// AnnotationStatistics.annotationToSpan();

	// 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(silverViewName);

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

		// compare the system mentions to the gold mentions
		stats.add(goldMentions, systemMentions, AnnotationStatistics.annotationToSpan(),
				AnnotationStatistics.annotationToFeatureValue("Gender"));
	}

	return stats;
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:60,代码来源:Evaluation.java

示例13: 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(PrepareEvaluation.class,
			PrepareEvaluation.PARAM_GOLD_VIEW_NAME, goldViewName));

	// Annotators processing the default (system) view:
	// * load the text
	// * parse sentences, tokens, part-of-speech tags
	// * run the named entity chunker
	aggregate.add(AnalysisEngineFactory.createEngineDescription(ClearTkMentionAnnotator.class,
			CleartkSequenceAnnotator.PARAM_IS_TRAINING, false,
			GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
			JarClassifierBuilder.getModelJarFile(modelDirectory)));
	aggregate.add(AnalysisEngineFactory.createEngineDescription(ClearAnnotation.class, ClearAnnotation.PARAM_TYPE,
			TrainingArea.class));
	aggregate.add(AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
			"target/debug/", XmiWriter.PARAM_USE_DOCUMENT_ID, true));

	// prepare the evaluation statistics
	AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
	// Function<FigureMention, ?> getSpan =
	// AnnotationStatistics.annotationToSpan();

	// 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<FigureMention> goldMentions, systemMentions;
		goldMentions = JCasUtil.select(goldView, FigureMention.class);
		systemMentions = JCasUtil.select(systemView, FigureMention.class);

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

	return stats;
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:54,代码来源:MentionDetectionEvaluation.java

示例14: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。