Package org.apache.uima.collection.metadata

Examples of org.apache.uima.collection.metadata.CpeDescription


   *          how many threads are used by the cpm
   *
   * @return CollectionProcessingEngine - initialized cpe
   */
  private CollectionProcessingEngine setupCpm(int documentCount, int threadCount) throws Exception {
    CpeDescription cpeDesc = null;
    CollectionProcessingEngine cpe = null;

    try {
      String colReaderBase = JUnitExtension.getFile("CpmTests" + separator
              + "ErrorTestCollectionReader.xml").getAbsolutePath();
      String taeBase = JUnitExtension.getFile("CpmTests" + separator + "ErrorTestAnnotator.xml").getAbsolutePath();
      String casConsumerBase = JUnitExtension.getFile("CpmTests" + separator
              + "ErrorTestCasConsumer.xml").getAbsolutePath();

      // created needed descriptors
      String colReaderDesc = DescriptorMakeUtil.makeCollectionReader(colReaderBase, documentCount);
      String taeDesc = DescriptorMakeUtil.makeAnalysisEngine(taeBase);
      String casConsumerDesc = DescriptorMakeUtil.makeCasConsumer(casConsumerBase);

      // create cpm descriptor
      cpeDesc = CpeDescriptorFactory.produceDescriptor();
      cpeDesc.setInputQueueSize(2);
      cpeDesc.setOutputQueueSize(2);
      cpeDesc.setProcessingUnitThreadCount(threadCount);

      // add tae
      CpeIntegratedCasProcessor integratedProcessor = CpeDescriptorFactory
              .produceCasProcessor("ErrorTestAnnotator");
      integratedProcessor.setDescriptor(taeDesc);
      cpeDesc.addCasProcessor(integratedProcessor);

      // add casConsumer
      CpeIntegratedCasProcessor casConsumer = CpeDescriptorFactory
              .produceCasProcessor("ErrorTest CasConsumer");
      casConsumer.setDescriptor(casConsumerDesc);
      cpeDesc.addCasProcessor(casConsumer);

      // add collectionReader
      cpeDesc.addCollectionReader(colReaderDesc);

      // produce cpe
      cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, null, null);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here


   *
   * @return CollectionProcessingEngine - initialized cpe
   */
  private CollectionProcessingEngine setupCpm(int documentCount, int threadCount, int poolSize,
      ResourceManager resourceManager) throws Exception {
    CpeDescription cpeDesc = null;
    CollectionProcessingEngine cpe = null;

    try {
      String colReaderBase = JUnitExtension.getFile("CpmTests" + separator
              + "ErrorTestCollectionReader.xml").getAbsolutePath();
      String taeBase = JUnitExtension.getFile("CpmTests" + separator + "aggrContainingPearSpecifier.xml").getAbsolutePath();
      String casConsumerBase = JUnitExtension.getFile("CpmTests" + separator
              + "ErrorTestCasConsumer.xml").getAbsolutePath();

      // created needed descriptors
      String colReaderDesc = DescriptorMakeUtil.makeCollectionReader(colReaderBase, documentCount);
//      String taeDesc = DescriptorMakeUtil.makeAnalysisEngine(taeBase);
      String taeDesc = taeBase;
      String casConsumerDesc = DescriptorMakeUtil.makeCasConsumer(casConsumerBase);

      // create cpm descriptor
      cpeDesc = CpeDescriptorFactory.produceDescriptor();
      cpeDesc.setInputQueueSize(threadCount);
      cpeDesc.setOutputQueueSize(threadCount);
      cpeDesc.setProcessingUnitThreadCount(threadCount);
      cpeDesc.getCpeCasProcessors().setPoolSize(poolSize);

      // add tae
      CpeIntegratedCasProcessor integratedProcessor = CpeDescriptorFactory
              .produceCasProcessor("ErrorTestAnnotator");
      integratedProcessor.setDescriptor(taeDesc);
      cpeDesc.addCasProcessor(integratedProcessor);

      // add casConsumer
      CpeIntegratedCasProcessor casConsumer = CpeDescriptorFactory
              .produceCasProcessor("ErrorTest CasConsumer");
      casConsumer.setDescriptor(casConsumerDesc);
      cpeDesc.addCasProcessor(casConsumer);

      // add collectionReader
      cpeDesc.addCollectionReader(colReaderDesc);

      // produce cpe
      cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, resourceManager, null);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  public void equal(File aReferenceDescriptorFile, CpeDescription aGeneratedDescriptor) {
    try {
     
      XMLInputSource in = new XMLInputSource(aReferenceDescriptorFile);
      CpeDescription referenceDesc = UIMAFramework.getXMLParser().parseCpeDescription(in);

      // First Check Collection Reader
      CpeCollectionReader[] readers = referenceDesc.getAllCollectionCollectionReaders();
      if (readers[0] != null) {
        if (aGeneratedDescriptor.getAllCollectionCollectionReaders() == null
                || aGeneratedDescriptor.getAllCollectionCollectionReaders()[0] == null) {

          fail("<collectionReader> element not found in generated CPE Descriptor");
        } else {
          // Collection Reader element is present in the generated descriptor
          if (readers[0].getCollectionIterator() != null) {
            assertTrue(isCollectionIteratorTheSame(readers[0].getCollectionIterator(),
                    aGeneratedDescriptor.getAllCollectionCollectionReaders()[0]
                            .getCollectionIterator()));
          }

          if (readers[0].getCasInitializer() != null) {
            assertTrue(isCasInitializerTheSame(readers[0].getCasInitializer(), aGeneratedDescriptor
                    .getAllCollectionCollectionReaders()[0].getCasInitializer()));

          }
        }
      }
      CpeConfiguration refCpeConfig = referenceDesc.getCpeConfiguration();
      if (refCpeConfig != null) {
        if (aGeneratedDescriptor.getCpeConfiguration() == null) {
          fail("<cpeConfig> element not found in generated CPE Descriptor");
        } else {
          isConfigTheSame(refCpeConfig, aGeneratedDescriptor.getCpeConfiguration());

        }
      }
      CpeCasProcessors refCasProcessors = referenceDesc.getCpeCasProcessors();
      if (refCasProcessors != null) {
        if (aGeneratedDescriptor.getCpeCasProcessors() == null) {
          fail("<casProcessors> element not found in generated CPE Descriptor");
        } else {
          compareCasProcessors(referenceDesc.getCpeCasProcessors(), aGeneratedDescriptor
                  .getCpeCasProcessors());
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

   * will have default settings.
   *
   * @return An empty CpeDescription object with default settings
   */
  public static CpeDescription produceDescriptor() {
    CpeDescription descriptor = null;
    descriptor = new CpeDescriptionImpl();

    try {
      descriptor.setCpeConfiguration(produceCpeConfiguration(descriptor));
      descriptor.getCpeConfiguration().setNumToProcess((int) CpeDefaultValues.NUM_TO_PROCESS);
      descriptor.getCpeConfiguration().setDeployment(CpeDefaultValues.DEPLOY_AS);
      descriptor.getCpeConfiguration().setCheckpoint(produceCpeCheckpoint());
      descriptor.getCpeConfiguration().getCheckpoint().setFilePath("");
      descriptor.getCpeConfiguration().getCheckpoint().setFrequency(300000, true);
      descriptor.getCpeConfiguration().setCpeTimer(new CpeTimerImpl(""));
      return descriptor;

    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

    try
    {
        xmlIn = new XMLInputSource(this.pkgBrowser.getInstallationDescriptor()
                .getMainComponentDesc());
        CpeDescription cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(xmlIn);
   
        CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(
                cpeDescription, getResourceManager(this.pkgBrowser), null);
   
        // create Test status object
View Full Code Here

      System.exit(1);
    }

    // parse CPE descriptor
    System.out.println("Parsing CPE Descriptor");
    CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
            new XMLInputSource(args[0]));
    // instantiate CPE
    System.out.println("Instantiating CPE");
    mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
View Full Code Here

  /**
   * @return
   */
  private CpeDescription createEmptyCpeDescription() {
    CpeDescription cpeDesc = CpeDescriptorFactory.produceDescriptor();
    // We use CAS pool size default of 3
    try {
      CpeCasProcessors cpeCasProcs = CpeDescriptorFactory.produceCasProcessors();
      cpeDesc.setCpeCasProcessors(cpeCasProcs);
      cpeCasProcs.setPoolSize(3);
    } catch (CpeDescriptorException e) {
      e.printStackTrace(); // this should never happen
    }
    return cpeDesc;
View Full Code Here

    try
    {
        xmlIn = new XMLInputSource(this.pkgBrowser.getInstallationDescriptor()
                .getMainComponentDesc());
        CpeDescription cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(xmlIn);
   
        CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(
                cpeDescription, getResourceManager(this.pkgBrowser), null);
   
        // create Test status object
View Full Code Here

    try
    {
        xmlIn = new XMLInputSource(this.pkgBrowser.getInstallationDescriptor()
                .getMainComponentDesc());
        CpeDescription cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(xmlIn);
   
        CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(
                cpeDescription, getResourceManager(this.pkgBrowser), null);
   
        // create Test status object
View Full Code Here

  /**
   * @return
   */
  private CpeDescription createEmptyCpeDescription() {
    CpeDescription cpeDesc = CpeDescriptorFactory.produceDescriptor();
    // We use CAS pool size default of 3
    try {
      CpeCasProcessors cpeCasProcs = CpeDescriptorFactory.produceCasProcessors();
      cpeDesc.setCpeCasProcessors(cpeCasProcs);
      cpeCasProcs.setPoolSize(3);
    } catch (CpeDescriptorException e) {
      e.printStackTrace(); // this should never happen
    }
    return cpeDesc;
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.metadata.CpeDescription

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.