Examples of AggregateBuilder


Examples of org.apache.uima.fit.factory.AggregateBuilder

    ruta.getAnalysisEngineMetaData()
            .getTypeSystem()
            .addType("org.apache.uima.T1", "Type for Testing", "uima.tcas.Annotation");

    final AggregateBuilder builder = new AggregateBuilder();
    builder.add(ruta, "_InitialView", "text");

    return builder.createAggregate();
  }
View Full Code Here

Examples of org.apache.uima.fit.factory.AggregateBuilder

    // This resource is shared between the UimaAcronymAnnotator and UimaMeetingAnnotator
    ExternalResourceDescription resource = createExternalResourceDescription(
            StringMapResource_impl.class,
            "file:src/main/resources/org/apache/uima/fit/examples/tutorial/ex6/uimaAcronyms.txt");

    AggregateBuilder builder = new AggregateBuilder();
    builder.add(createEngineDescription(UimaAcronymAnnotator.class,
            UimaAcronymAnnotator.RES_ACRONYM_TABLE, resource));
    builder.add(createEngineDescription(UimaMeetingAnnotator.class,
            UimaMeetingAnnotator.RES_UIMA_TERM_TABLE, resource));
    AnalysisEngine engine = createEngine(builder.createAggregateDescription());

    JCas jCas = engine.newJCas();
    jCas.setDocumentText("Let's meet to talk about the CPE. The meeting is over at Yorktown 01-144");
    new Meeting(jCas, 0, 33).addToIndexes();
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

        paths);
  }

  @Override
  public void train(CollectionReader collectionReader, File directory) throws Exception {
    AggregateBuilder builder = new AggregateBuilder();
    // replace cTAKES entity mentions and modifiers in the system view with the gold annotations
    builder.add(AnalysisEngineFactory.createPrimitiveDescription(ReplaceCTakesEntityMentionsAndModifiersWithGold.class));
    // add the relation extractor, configured for training mode
    AnalysisEngineDescription classifierAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
        this.classifierAnnotatorClass,
        this.additionalParameters);
    ConfigurationParameterFactory.addConfigurationParameters(
        classifierAnnotator,
        RelationExtractorAnnotator.PARAM_GOLD_VIEW_NAME,
        RelationExtractorEvaluation.GOLD_VIEW_NAME,
        DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
        this.dataWriterClass,
        DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
        directory.getPath());
    builder.add(classifierAnnotator);

    // run the data-writing pipeline
    SimplePipeline.runPipeline(collectionReader, builder.createAggregateDescription());

    // train the classifier and package it into a .jar file
    HideOutput hider = new HideOutput();
    JarClassifierBuilder.trainAndPackage(directory, this.trainingArguments);
    hider.restoreOutput();
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

  }

  @Override
  protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
      throws Exception {
    AggregateBuilder builder = new AggregateBuilder();
    // replace cTAKES entity mentions and modifiers in the system view with the gold annotations
    builder.add(AnalysisEngineFactory.createPrimitiveDescription(ReplaceCTakesEntityMentionsAndModifiersWithGold.class));
    // add the relation extractor, configured for classification mode
    AnalysisEngineDescription classifierAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
        this.classifierAnnotatorClass,
        this.additionalParameters);
    ConfigurationParameterFactory.addConfigurationParameters(
        classifierAnnotator,
        GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
        new File(directory, "model.jar").getPath());
    builder.add(classifierAnnotator);

    // statistics will be based on the "category" feature of the BinaryTextRelations
    AnnotationStatistics<String> stats = new AnnotationStatistics<String>();
    Function<BinaryTextRelation, HashableArguments> getSpan = new Function<BinaryTextRelation, HashableArguments>() {
      @Override
      public HashableArguments apply(BinaryTextRelation relation) {
        return new HashableArguments(relation);
      }
    };
    Function<BinaryTextRelation, String> getOutcome = AnnotationStatistics.annotationToFeatureValue("category");

    // calculate statistics, iterating over the results of the classifier
    AnalysisEngine engine = builder.createAggregate();
    for (JCas jCas : new JCasIterable(collectionReader, engine)) {

      // get the gold view
      JCas goldView;
      try {
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

 
 
  public static AnalysisEngine createGoldAnnotator(File knowtatorXMLDirectory)
      throws ResourceInitializationException {
    // pipeline to read manual annotations into the gold view, not the default view
        AggregateBuilder goldAnnotatorBuilder = new AggregateBuilder();
        goldAnnotatorBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
            ViewCreatorAnnotator.class,
            ViewCreatorAnnotator.PARAM_VIEW_NAME,
            RelationExtractorEvaluation.GOLD_VIEW_NAME));
        goldAnnotatorBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
            CopyDocumentTextToGoldView.class));
        goldAnnotatorBuilder.add(
            AnalysisEngineFactory.createPrimitiveDescription(DocumentIDAnnotator.class),
            CAS.NAME_DEFAULT_SOFA, RelationExtractorEvaluation.GOLD_VIEW_NAME);
        goldAnnotatorBuilder.add(
            AnalysisEngineFactory.createPrimitiveDescription(
              GoldEntityAndRelationReader.class,
              GoldEntityAndRelationReader.PARAM_INPUTDIR,
              knowtatorXMLDirectory.getPath()),
            CAS.NAME_DEFAULT_SOFA, RelationExtractorEvaluation.GOLD_VIEW_NAME);
        AnalysisEngine goldAnnotator = goldAnnotatorBuilder.createAggregate();
        return goldAnnotator;
  }
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

    // Write standalone description files
    clearparserDepParserDesc.toXML(new FileOutputStream(new File(options.outputRoot, "ClearParserDependencyParserAE.xml")));
    clearparserSRLDesc.toXML(new FileOutputStream(new File(options.outputRoot, "ClearParserSemanticRoleLabelerAE.xml")));

    // Write aggregate plaintext description files
    AggregateBuilder aggregateBuilder = getPlaintextAggregateBuilder();
    writeAggregateDescriptions(aggregateBuilder, clearparserDepParserDesc, clearparserSRLDesc, options.outputRoot, "PlaintextAggregate.xml");

    // Write aggregate tokenized description files
    aggregateBuilder = getTokenizedAggregateBuilder();
    writeAggregateDescriptions(aggregateBuilder, clearparserDepParserDesc, clearparserSRLDesc, options.outputRoot, "TokenizedAggregate.xml");
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

   * @return
   * @throws InvalidXMLException
   * @throws IOException
   */
  public static AggregateBuilder getPlaintextAggregateBuilder() throws InvalidXMLException, IOException {
    AggregateBuilder aggregateBuilder = new AggregateBuilder();
    aggregateBuilder.add(loadDescription(SIMPLE_SEGMENTER_PATH));
    aggregateBuilder.add(loadDescription(SENTENCE_DETECTOR_PATH));
    aggregateBuilder.add(loadDescription(TOKENIZER_PATH));
    aggregateBuilder.add(loadDescription(LVG_BASE_TOKEN_ANNOTATOR_PATH));
    aggregateBuilder.add(loadDescription(POS_TAGGER_PATH));
    return aggregateBuilder;
  }
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

   * @return
   * @throws InvalidXMLException
   * @throws IOException
   */
  public static AggregateBuilder getTokenizedAggregateBuilder() throws InvalidXMLException, IOException {
    AggregateBuilder aggregateBuilder = new AggregateBuilder();
    aggregateBuilder.add(loadDescription(SIMPLE_SEGMENTER_PATH));
    aggregateBuilder.add(loadDescription(LVG_BASE_TOKEN_ANNOTATOR_PATH));
    return aggregateBuilder;
  }
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

   * @return
   * @throws InvalidXMLException
   * @throws IOException
   */
  public static AggregateBuilder getTokenizedInfPosAggregateBuilder() throws InvalidXMLException, IOException {
    AggregateBuilder aggregateBuilder = new AggregateBuilder();
    aggregateBuilder.add(loadDescription(SIMPLE_SEGMENTER_PATH));
    aggregateBuilder.add(loadDescription(LVG_BASE_TOKEN_ANNOTATOR_PATH));
    aggregateBuilder.add(loadDescription(POS_TAGGER_PATH));
    return aggregateBuilder;
  }
View Full Code Here

Examples of org.uimafit.factory.AggregateBuilder

public class RelationExtractorAnnotatorsTest {

  @Test
  public void test() throws Exception {
    // create the pipeline
    AggregateBuilder builder = new AggregateBuilder();
    builder.add(this.findDescription(ModifierExtractorAnnotator.class));
    builder.add(this.findDescription(DegreeOfRelationExtractorAnnotator.class));
    builder.add(this.findDescription(EntityMentionPairRelationExtractorAnnotator.class));
    AnalysisEngine engine = builder.createAggregate();
    JCas jCas = engine.newJCas();

    // populate the CAS with an example sentence
    // TODO: add annotations to support phrase chunk and dependency features
    TokenBuilder<BaseToken, Sentence> tokenBuilder = new TokenBuilder<BaseToken, Sentence>(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.