Package org.uimafit.factory

Examples of org.uimafit.factory.AggregateBuilder


      throws Exception {
//    AnalysisEngine classifierAnnotator = AnalysisEngineFactory.createPrimitive(AssertionCleartkAnalysisEngine.getDescription(
//        GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
//        new File(directory, "model.jar").getPath()));

    AggregateBuilder builder = new AggregateBuilder();
   
    // directory is such as /cTAKES/workspaces/Apache-cTAKES-trunk/ctakes/ctakes-assertion/sharp_data/model/eval.model
   
    AnalysisEngineDescription goldCopierAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceIdentifiedAnnotationsSystemToGoldCopier.class);
    builder.add(goldCopierAnnotator);
   
    AnalysisEngineDescription assertionAttributeClearerAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceAnnotationsSystemAssertionClearer.class);
    builder.add(assertionAttributeClearerAnnotator);
   
    if ( options.noCleartk ) {
      addExternalAttributeAnnotatorsToAggregate(builder);
    } else {
      addCleartkAttributeAnnotatorsToAggregate(directory, builder);
    }

    if (options.evalOnly && evaluationOutputDirectory != null) {
      // short circuit any other stuff in the pipeline
      builder = new AggregateBuilder();
     
      // uimafit find available type systems on classpath
      TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();
     
        AnalysisEngineDescription noOp =
        AnalysisEngineFactory.createPrimitiveDescription(
              NoOpAnnotator.class,
              typeSystemDescription);
      builder.add(noOp);
     
        AnalysisEngineDescription mergeGold =
        AnalysisEngineFactory.createPrimitiveDescription(org.apache.ctakes.assertion.eval.MergeGoldViewFromOneCasIntoInitialViewOfAnotherCas.class, typeSystemDescription);
      builder.add(mergeGold);
     
    } else if (evaluationOutputDirectory!=null)  {
        AnalysisEngineDescription xwriter =
        AnalysisEngineFactory.createPrimitiveDescription(
              XWriter.class,
              AssertionComponents.CTAKES_CTS_TYPE_SYSTEM_DESCRIPTION,
              XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
              evaluationOutputDirectory,
              XWriter.PARAM_XML_SCHEME_NAME,
              XWriter.XMI,
              XWriter.PARAM_FILE_NAMER_CLASS_NAME,
              CtakesFileNamer.class.getName());
        builder.add(xwriter);
    }
   
    //SimplePipeline.runPipeline(collectionReader,  builder.createAggregateDescription());
    //AnalysisEngineDescription aggregateDescription = builder.createAggregateDescription();
   
    AnalysisEngine aggregate = builder.createAggregate();
   
    AnnotationStatisticsCompact polarityStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact conditionalStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact uncertaintyStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact subjectStats = new AnnotationStatisticsCompact();
View Full Code Here


          // use the uimafit method of finding available type system
          // descriptor via META-INF/org.uimafit/types.txt
          // (found in ctakes-type-system/src/main/resources)
        TypeSystemDescriptionFactory.createTypeSystemDescription();
     
      AggregateBuilder aggregate = new AggregateBuilder();
     
      CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
          FilesInDirectoryCollectionReader.class,
          typeSystemDescription,
          "InputDirectory",
          textDirectory.toString()
          );
     
      // read the UMLS_CEM data from Knowtator
      AnalysisEngineDescription goldAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
          SHARPKnowtatorXMLReader.class,
          typeSystemDescription,
          "TextDirectory", // 3/13/13 halgrim changed from "TextURI" trying to work with new SHARPKnowtatorXMLReader.java
          //"/work/medfacts/sharp/data/2012-10-16_full_data_set_updated/Seed_Corpus/sandbox/batch02_mayo/knowtator/"
          textDirectory.toString() + "/"
      );
      aggregate.add(goldAnnotator);

      // write just the XMI version of what's in Knowtator UMLS_CEM
      AnalysisEngineDescription xWriter = AnalysisEngineFactory.createPrimitiveDescription(
          XWriter.class,
          typeSystemDescription,
          XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
          xmiDirectory.toString(),
          XWriter.PARAM_FILE_NAMER_CLASS_NAME,
          CtakesFileNamer.class.getName()
      );
      aggregate.add(xWriter);

      // fill in other values that are necessary for preprocessing
      AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
          "desc/analysis_engine/AttributeDiscoveryPreprocessor"
          );
      aggregate.add(preprocessAnnotator);
     
      if (trainDirectory!=null && testDirectory!=null && devDirectory!=null) {
        File subcorpusDirectory;
        switch (SharpCorpusSplit.split(currentBatchDirectory)) {
        case TRAIN:
          subcorpusDirectory = trainDirectory;
          break;
        case TEST:
          subcorpusDirectory = testDirectory;
          break;
        case DEV:
          subcorpusDirectory = devDirectory;
          break;
        case CROSSVAL:
          subcorpusDirectory = trainDirectory;
          break;
        default:
          subcorpusDirectory = trainDirectory;
          break;
        }
        AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
            XWriter.class,
            typeSystemDescription,
            XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
            subcorpusDirectory,
            XWriter.PARAM_FILE_NAMER_CLASS_NAME,
            CtakesFileNamer.class.getName()
        );
        aggregate.add(xWriter2);
//        SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
      }

      SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    }

    logger.info("Finished!");
  }
View Full Code Here

      // use the uimafit method of finding available type system
      // descriptor via META-INF/org.uimafit/types.txt
      // (found in ctakes-type-system/src/main/resources)
      TypeSystemDescriptionFactory.createTypeSystemDescription();

    AggregateBuilder aggregate = new AggregateBuilder();

    CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
        I2B2Challenge2010CollectionReader.class,
        typeSystemDescription,
        "inputDir",
        parentDirectory
    );

    // fill in other values that are necessary for preprocessing
    AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
        "desc/analysis_engine/AttributeDiscoveryPreprocessor"
    );
    aggregate.add(preprocessAnnotator);

    if (preprocessedDirectory!=null) {
      AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
          XWriter.class,
          typeSystemDescription,
          XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
          preprocessedDirectory,
          XWriter.PARAM_FILE_NAMER_CLASS_NAME,
          CtakesFileNamer.class.getName()
      );
      aggregate.add(xWriter2);
      //    SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
    }

    SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    logger.info("Finished!");
  }
View Full Code Here

  throws ResourceInitializationException, UIMAException, IOException {

    TypeSystemDescription typeSystemDescription =
      TypeSystemDescriptionFactory.createTypeSystemDescription();

    AggregateBuilder aggregate = new AggregateBuilder();

    // input dir is hard-coded in AssertionConst
    CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
        NegExCorpusReader.class,
        typeSystemDescription
    );

    // fill in other values that are necessary for preprocessing
    AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
        "desc/analysis_engine/AttributeDiscoveryPreprocessor"
    );
    aggregate.add(preprocessAnnotator);

    if (preprocessedDirectory!=null) {
      AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
          XWriter.class,
          typeSystemDescription,
          XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
          preprocessedDirectory,
          XWriter.PARAM_FILE_NAMER_CLASS_NAME,
          CtakesFileNamer.class.getName()
      );
      aggregate.add(xWriter2);
      //    SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
    }

    SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    logger.info("Finished!");
  }
View Full Code Here

    HashMap<File,File> splitMipacq = new HashMap<File,File>();
    splitMipacq.put(new File(inputDirectory+"/text/train"), preprocessedDirectory);
    splitMipacq.put(new File(inputDirectory+"/text/test"),  testDirectory);
    splitMipacq.put(new File(inputDirectory+"/text/dev"),   devDirectory);
    for (File inDir : splitMipacq.keySet() ) {
      AggregateBuilder aggregate = new AggregateBuilder();

      CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
          FilesInDirectoryCollectionReader.class,
          typeSystemDescription,
          "InputDirectory",
          inDir
          );

      // read the UMLS_CEM data from Knowtator
      AnalysisEngineDescription goldAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
          MiPACQKnowtatorXMLReader.class,
          typeSystemDescription,
          MiPACQKnowtatorXMLReader.PARAM_TEXT_DIRECTORY,
          inDir
          );

      aggregate.add(goldAnnotator);
      // fill in other values that are necessary for preprocessing
      AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
          "desc/analysis_engine/AttributeDiscoveryPreprocessor"
          );
      aggregate.add(preprocessAnnotator);

      if (preprocessedDirectory!=null) {
        AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
            XWriter.class,
            typeSystemDescription,
            XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
            splitMipacq.get(inDir),
            XWriter.PARAM_FILE_NAMER_CLASS_NAME,
            CtakesFileNamer.class.getName()
            );
        aggregate.add(xWriter2);
        //    SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
      }

      SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    }
     
    logger.info("Finished!");
  }
View Full Code Here

  private static JCas getJcas(File f) {
    List<File> list = new ArrayList<File>();
    list.add(f);
    CollectionReader cr;
    AggregateBuilder builder;
   
    try {
      cr = getCollectionReader(list);
      builder = new AggregateBuilder();

      // uimafit find available type systems on classpath
      TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();

      AnalysisEngineDescription noOp = AnalysisEngineFactory.createPrimitiveDescription(NoOpAnnotator.class, typeSystemDescription);
      builder.add(noOp);
    } catch (ResourceInitializationException e) {
      throw new RuntimeException(e);
    }

    try {
      //SimplePipeline.runPipeline(cr, builder.createAggregate());
      AnalysisEngine engine = builder.createAggregate();

      final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
      metaData.add(cr.getMetaData());
      metaData.add(engine.getMetaData());
     
View Full Code Here

          // use the uimafit method of finding available type system
          // descriptor via META-INF/org.uimafit/types.txt
          // (found in ctakes-type-system/src/main/resources)
        TypeSystemDescriptionFactory.createTypeSystemDescription();
     
      AggregateBuilder aggregate = new AggregateBuilder();
     
      CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
          FilesInDirectoryCollectionReader.class,
          typeSystemDescription,
          "InputDirectory",
          textDirectory.toString()
          );
     
      // read the UMLS_CEM data from Knowtator
      AnalysisEngineDescription goldAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
          SHARPKnowtatorXMLReader.class,
          typeSystemDescription,
          "TextDirectory", // 3/13/13 halgrim changed from "TextURI" trying to work with new SHARPKnowtatorXMLReader.java
          //"/work/medfacts/sharp/data/2012-10-16_full_data_set_updated/Seed_Corpus/sandbox/batch02_mayo/knowtator/"
          textDirectory.toString() + "/"
      );
      aggregate.add(goldAnnotator);

      // write just the XMI version of what's in Knowtator UMLS_CEM
      AnalysisEngineDescription xWriter = AnalysisEngineFactory.createPrimitiveDescription(
          XWriter.class,
          typeSystemDescription,
          XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
          xmiDirectory.toString(),
          XWriter.PARAM_FILE_NAMER_CLASS_NAME,
          CtakesFileNamer.class.getName()
      );
      aggregate.add(xWriter);

      // fill in other values that are necessary for preprocessing
      AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
          "desc/analysis_engine/AttributeDiscoveryPreprocessor"
          );
      aggregate.add(preprocessAnnotator);
     
      if (trainDirectory!=null && testDirectory!=null && devDirectory!=null) {
        File subcorpusDirectory;
        switch (SharpCorpusSplit.split(currentBatchDirectory)) {
        case TRAIN:
          subcorpusDirectory = trainDirectory;
          break;
        case TEST:
          subcorpusDirectory = testDirectory;
          break;
        case DEV:
          subcorpusDirectory = devDirectory;
          break;
        case CROSSVAL:
          subcorpusDirectory = trainDirectory;
          break;
        default:
          subcorpusDirectory = trainDirectory;
          break;
        }
        AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
            XWriter.class,
            typeSystemDescription,
            XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
            subcorpusDirectory,
            XWriter.PARAM_FILE_NAMER_CLASS_NAME,
            CtakesFileNamer.class.getName()
        );
        aggregate.add(xWriter2);
//        SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
      }

      SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    }

    logger.info("Finished!");
  }
View Full Code Here

      // use the uimafit method of finding available type system
      // descriptor via META-INF/org.uimafit/types.txt
      // (found in ctakes-type-system/src/main/resources)
      TypeSystemDescriptionFactory.createTypeSystemDescription();

    AggregateBuilder aggregate = new AggregateBuilder();

    CollectionReaderDescription collectionReader = CollectionReaderFactory.createDescription(
        I2B2Challenge2010CollectionReader.class,
        typeSystemDescription,
        "inputDir",
        parentDirectory
    );

    // fill in other values that are necessary for preprocessing
    AnalysisEngineDescription preprocessAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(
        "desc/analysis_engine/AttributeDiscoveryPreprocessor"
    );
    aggregate.add(preprocessAnnotator);

    if (trainDirectory!=null) {
      AnalysisEngineDescription xWriter2 = AnalysisEngineFactory.createPrimitiveDescription(
          XWriter.class,
          typeSystemDescription,
          XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
          trainDirectory,
          XWriter.PARAM_FILE_NAMER_CLASS_NAME,
          CtakesFileNamer.class.getName()
      );
      aggregate.add(xWriter2);
      //    SimplePipeline.runPipeline(collectionReader, goldAnnotator, xWriter, xWriter2);
    }

    SimplePipeline.runPipeline(collectionReader, aggregate.createAggregateDescription());
    logger.info("Finished!");
  }
View Full Code Here

    }
  }
 
  @Override
  public void train(CollectionReader collectionReader, File directory) throws Exception {
    AggregateBuilder builder = new AggregateBuilder();
   
    //builder.add(AnalysisEngineFactory.createPrimitiveDescription(ReplaceCTakesEntityMentionsAndModifiersWithGold.class));

//    AnalysisEngineDescription assertionDescription = AssertionCleartkAnalysisEngine.getDescription(
//        CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//        //MultiClassLIBSVMDataWriterFactory.class.getName(),
//        MaxentStringOutcomeDataWriter.class.getName(),
//        DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
//        directory.getPath());
//    builder.add(assertionDescription);
   
    AnalysisEngineDescription documentIdPrinterAnnotator = AnalysisEngineFactory.createPrimitiveDescription(DocumentIdPrinterAnalysisEngine.class);
    builder.add(documentIdPrinterAnnotator);
   
    AnalysisEngineDescription goldCopierIdentifiedAnnotsAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceIdentifiedAnnotationsSystemToGoldCopier.class);
    builder.add(goldCopierIdentifiedAnnotsAnnotator);
   
    AnalysisEngineDescription goldCopierSupportingAnnotsAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceSupportingAnnotationsSystemToGoldCopier.class);
    builder.add(goldCopierSupportingAnnotsAnnotator);
   
    AnalysisEngineDescription assertionAttributeClearerAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceAnnotationsSystemAssertionClearer.class);
    builder.add(assertionAttributeClearerAnnotator);
   
    String generalSectionRegexFileUri =
        "org/mitre/medfacts/zoner/section_regex.xml";
    AnalysisEngineDescription zonerAnnotator =
        AnalysisEngineFactory.createPrimitiveDescription(ZoneAnnotator.class,
            ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI,
            generalSectionRegexFileUri
            );
//    builder.add(zonerAnnotator);

    String mayoSectionRegexFileUri =
        "org/mitre/medfacts/uima/mayo_sections.xml";
    AnalysisEngineDescription mayoZonerAnnotator =
        AnalysisEngineFactory.createPrimitiveDescription(ZoneAnnotator.class,
            ZoneAnnotator.PARAM_SECTION_REGEX_FILE_URI,
            mayoSectionRegexFileUri
            );
//    builder.add(mayoZonerAnnotator);
 
//    URL assertionCuePhraseLookupAnnotatorDescriptorUrl1 = this.getClass().getClassLoader().getResource("org/apache/ctakes/dictionary/lookup/AssertionCuePhraseDictionaryLookupAnnotator.xml");
//    logger.info(String.format("assertionCuePhraseLookupAnnotatorDescriptorUrl1 (slashes): %s", assertionCuePhraseLookupAnnotatorDescriptorUrl1));
//    URL assertionCuePhraseLookupAnnotatorDescriptorUrl2 = this.getClass().getClassLoader().getResource("org.apache.ctakes.dictionary.lookup.AssertionCuePhraseDictionaryLookupAnnotator.xml");
//    logger.info(String.format("assertionCuePhraseLookupAnnotatorDescriptorUrl2 (periods): %s", assertionCuePhraseLookupAnnotatorDescriptorUrl2));
//
//   
//    AnalysisEngineDescription cuePhraseLookupAnnotator =
//        AnalysisEngineFactory.createAnalysisEngineDescription("org/apache/ctakes/dictionary/lookup/AssertionCuePhraseDictionaryLookupAnnotator");
//    builder.add(cuePhraseLookupAnnotator);

    // Set up Feature Selection parameters
    Float featureSelectionThreshold = options.featureSelectionThreshold;
    Class<? extends DataWriter> dataWriterClassFirstPass = getDataWriterClass();
    if (options.featureSelectionThreshold==null) {
      featureSelectionThreshold = 0f;
    }
   
    // Add each assertion Analysis Engine to the pipeline!
    builder.add(AnalysisEngineFactory.createPrimitiveDescription(AlternateCuePhraseAnnotator.class, new Object[]{}));
   
    if (!options.ignorePolarity)
    {
      if (options.useYtexNegation) {
        AnalysisEngineDescription polarityAnnotator = AnalysisEngineFactory.createAnalysisEngineDescription(YTEX_NEGATION_DESCRIPTOR);
        builder.add(polarityAnnotator);
      } else {
        AnalysisEngineDescription polarityAnnotator = AnalysisEngineFactory.createPrimitiveDescription(PolarityCleartkAnalysisEngine.class); //,  this.additionalParamemters);
        ConfigurationParameterFactory.addConfigurationParameters(
            polarityAnnotator,
            AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
            AssertionEvaluation.GOLD_VIEW_NAME,
//            CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//            this.dataWriterFactoryClass.getName(),
            DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
            dataWriterClassFirstPass,
            DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
            new File(directory, "polarity").getPath(),
            AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
            PolarityCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "polarity")),
            AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
            featureSelectionThreshold
            );
        builder.add(polarityAnnotator);
      }
    }

    if (!options.ignoreConditional)
    {
      AnalysisEngineDescription conditionalAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ConditionalCleartkAnalysisEngine.class); //,  this.additionalParamemters);
      ConfigurationParameterFactory.addConfigurationParameters(
          conditionalAnnotator,
          AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
          AssertionEvaluation.GOLD_VIEW_NAME,
//          CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//          this.dataWriterFactoryClass.getName(),
          DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
      dataWriterClassFirstPass,
          DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
          new File(directory, "conditional").getPath(),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
      ConditionalCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "conditional")),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
      featureSelectionThreshold
          );
      builder.add(conditionalAnnotator);
    }

    if (!options.ignoreUncertainty)
    {
      AnalysisEngineDescription uncertaintyAnnotator = AnalysisEngineFactory.createPrimitiveDescription(UncertaintyCleartkAnalysisEngine.class); //,  this.additionalParamemters);
      ConfigurationParameterFactory.addConfigurationParameters(
          uncertaintyAnnotator,
          AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
          AssertionEvaluation.GOLD_VIEW_NAME,
//          CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//          this.dataWriterFactoryClass.getName(),
          DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
      dataWriterClassFirstPass,
          DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
          new File(directory, "uncertainty").getPath(),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
      UncertaintyCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "uncertainty")),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
      featureSelectionThreshold
          );
      builder.add(uncertaintyAnnotator);
    }

    if (!options.ignoreSubject)
    {
      AnalysisEngineDescription subjectAnnotator = AnalysisEngineFactory.createPrimitiveDescription(SubjectCleartkAnalysisEngine.class); //,  this.additionalParamemters);
      ConfigurationParameterFactory.addConfigurationParameters(
          subjectAnnotator,
          AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
          AssertionEvaluation.GOLD_VIEW_NAME,
//          CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//          this.dataWriterFactoryClass.getName(),
          DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
      dataWriterClassFirstPass,
          DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
          new File(directory, "subject").getPath(),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
      SubjectCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "subject")),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
      featureSelectionThreshold
          );
      builder.add(subjectAnnotator);
    }

    if (!options.ignoreGeneric)
    {
    AnalysisEngineDescription genericAnnotator = AnalysisEngineFactory.createPrimitiveDescription(GenericCleartkAnalysisEngine.class); //,  this.additionalParamemters);
    ConfigurationParameterFactory.addConfigurationParameters(
        genericAnnotator,
        AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
        AssertionEvaluation.GOLD_VIEW_NAME,
//        CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//        this.dataWriterFactoryClass.getName(),
        DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
      dataWriterClassFirstPass,
        DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
        new File(directory, "generic").getPath(),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
      GenericCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "generic")),
      AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
      featureSelectionThreshold
        );
    builder.add(genericAnnotator);
    }
   
    // 2/20/13 srh adding
    if (!options.ignoreHistory) {
      AnalysisEngineDescription historyAnnotator = AnalysisEngineFactory.createPrimitiveDescription(HistoryCleartkAnalysisEngine.class);
      ConfigurationParameterFactory.addConfigurationParameters(
          historyAnnotator,
          AssertionCleartkAnalysisEngine.PARAM_GOLD_VIEW_NAME,
          AssertionEvaluation.GOLD_VIEW_NAME,
//          CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
//          this.dataWriterFactoryClass.getName(),
          DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
      dataWriterClassFirstPass,
          DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
          new File(directory, "historyOf").getPath(),
        AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_URI,
        HistoryCleartkAnalysisEngine.createFeatureSelectionURI(new File(directory, "historyOf")),
        AssertionCleartkAnalysisEngine.PARAM_FEATURE_SELECTION_THRESHOLD,
        featureSelectionThreshold
          );
      builder.add(historyAnnotator);
    }

/*
    AnalysisEngineDescription classifierAnnotator = AnalysisEngineFactory.createPrimitiveDescription(
        this.classifierAnnotatorClass,
        this.additionalParameters);
    ConfigurationParameterFactory.addConfigurationParameters(
        classifierAnnotator,
        RelationExtractorAnnotator.PARAM_GOLD_VIEW_NAME,
        RelationExtractorEvaluation.GOLD_VIEW_NAME,
        CleartkAnnotator.PARAM_DATA_WRITER_FACTORY_CLASS_NAME,
        this.dataWriterFactoryClass.getName(),
        DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
        directory.getPath());
    builder.add(classifierAnnotator);
*/   
   
    SimplePipeline.runPipeline(collectionReader,  builder.createAggregateDescription());
   
    //HideOutput hider = new HideOutput();
    for (String currentAssertionAttribute : annotationTypes)
    {
      File currentDirectory = new File(directory, currentAssertionAttribute);
View Full Code Here

      throws Exception {
//    AnalysisEngine classifierAnnotator = AnalysisEngineFactory.createPrimitive(AssertionCleartkAnalysisEngine.getDescription(
//        GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
//        new File(directory, "model.jar").getPath()));

    AggregateBuilder builder = new AggregateBuilder();
   
    // directory is such as /cTAKES/workspaces/Apache-cTAKES-trunk/ctakes/ctakes-assertion/sharp_data/model/eval.model
   
    AnalysisEngineDescription goldCopierAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceIdentifiedAnnotationsSystemToGoldCopier.class);
    builder.add(goldCopierAnnotator);
   
    AnalysisEngineDescription assertionAttributeClearerAnnotator = AnalysisEngineFactory.createPrimitiveDescription(ReferenceAnnotationsSystemAssertionClearer.class);
    builder.add(assertionAttributeClearerAnnotator);
   
    if ( options.noCleartk ) {
      addExternalAttributeAnnotatorsToAggregate(builder);
    } else {
      addCleartkAttributeAnnotatorsToAggregate(directory, builder);
    }

    if (options.evalOnly && evaluationOutputDirectory != null) {
      // short circuit any other stuff in the pipeline
      builder = new AggregateBuilder();
     
      // uimafit find available type systems on classpath
      TypeSystemDescription typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription();
     
        AnalysisEngineDescription noOp =
        AnalysisEngineFactory.createPrimitiveDescription(
              NoOpAnnotator.class,
              typeSystemDescription);
      builder.add(noOp);
     
        AnalysisEngineDescription mergeGold =
        AnalysisEngineFactory.createPrimitiveDescription(org.apache.ctakes.assertion.eval.MergeGoldViewFromOneCasIntoInitialViewOfAnotherCas.class, typeSystemDescription);
      builder.add(mergeGold);
     
    } else if (evaluationOutputDirectory!=null)  {
        AnalysisEngineDescription xwriter =
        AnalysisEngineFactory.createPrimitiveDescription(
              XWriter.class,
              AssertionComponents.CTAKES_CTS_TYPE_SYSTEM_DESCRIPTION,
              XWriter.PARAM_OUTPUT_DIRECTORY_NAME,
              evaluationOutputDirectory,
              XWriter.PARAM_XML_SCHEME_NAME,
              XWriter.XMI,
              XWriter.PARAM_FILE_NAMER_CLASS_NAME,
              CtakesFileNamer.class.getName());
        builder.add(xwriter);
    }
   
    //SimplePipeline.runPipeline(collectionReader,  builder.createAggregateDescription());
    //AnalysisEngineDescription aggregateDescription = builder.createAggregateDescription();
   
    AnalysisEngine aggregate = builder.createAggregate();
   
    AnnotationStatisticsCompact polarityStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact conditionalStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact uncertaintyStats = new AnnotationStatisticsCompact();
    AnnotationStatisticsCompact subjectStats = new AnnotationStatisticsCompact();
View Full Code Here

TOP

Related Classes of org.uimafit.factory.AggregateBuilder

Copyright © 2018 www.massapicom. 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.