Package org.apache.uima.resource.metadata

Examples of org.apache.uima.resource.metadata.ProcessingResourceMetaData


        {
            throw new InvocationTargetException(e);
        }
       
//      set type system to collection reader
        ProcessingResourceMetaData collectionReaderMetaData =
            collectionReaderDescripton.getCollectionReaderMetaData();
       
        collectionReaderMetaData.setTypeSystem(typeSystemDescriptor);
       
        XMLParser xmlParser = UIMAFramework.getXMLParser();
       
        InputStream inIndex = getClass().getResourceAsStream(
                "Index.xml");

        if (inIndex == null)
        {
            throw new InvocationTargetException(null,
                    "org/apache/uima/caseditor/ui/action/Index.xml"
                    + " is missing on the classpath");
        }
       
        XMLInputSource xmlIndexSource = new XMLInputSource(inIndex,
                new File(""));
       
        FsIndexDescription indexDesciptor;
       
        try
        {
            indexDesciptor = (FsIndexDescription) xmlParser
            .parse(xmlIndexSource);
        }
        catch (InvalidXMLException e)
        {
            throw new InvocationTargetException(e);
        }
       
        collectionReaderMetaData.setFsIndexes(new FsIndexDescription[]
                {indexDesciptor});
       
        CollectionReader collectionReader;
        try
        {
View Full Code Here


   * Retrieves the name.
   *
   * @return the name
   */
  public String getName() {
    ProcessingResourceMetaData trainerMetaData = casConsumerDescriptor.getCasConsumerMetaData();

    return trainerMetaData.getName();
  }
View Full Code Here

    aeDescription.setResourceManagerConfiguration(r.getResourceManagerConfiguration());
    setAeDescription(aeDescription);
  }

  private AnalysisEngineMetaData convertToAeMetaData(ResourceMetaData r) {
    ProcessingResourceMetaData p = (ProcessingResourceMetaData) r;
    AnalysisEngineMetaData d = UIMAFramework.getResourceSpecifierFactory()
            .createAnalysisEngineMetaData();
    d.setCapabilities(p.getCapabilities());
    d.setConfigurationParameterDeclarations(p.getConfigurationParameterDeclarations());
    d.setConfigurationParameterSettings(p.getConfigurationParameterSettings());
    d.setCopyright(p.getCopyright());
    d.setDescription(p.getDescription());
    d.setFsIndexCollection(p.getFsIndexCollection());
    d.setName(p.getName());
    d.setTypePriorities(p.getTypePriorities());
    d.setTypeSystem(p.getTypeSystem());
    d.setVendor(p.getVendor());
    d.setVersion(p.getVersion());
    d.setOperationalProperties(p.getOperationalProperties());
    return d;
  }
View Full Code Here

    d.setOperationalProperties(p.getOperationalProperties());
    return d;
  }

  private ProcessingResourceMetaData convertFromAeMetaData(AnalysisEngineMetaData p) {
    ProcessingResourceMetaData d = UIMAFramework.getResourceSpecifierFactory()
            .createProcessingResourceMetaData();
    d.setCapabilities(p.getCapabilities());
    d.setConfigurationParameterDeclarations(p.getConfigurationParameterDeclarations());
    d.setConfigurationParameterSettings(p.getConfigurationParameterSettings());
    d.setCopyright(p.getCopyright());
    d.setDescription(p.getDescription());
    d.setFsIndexCollection(p.getFsIndexCollection());
    d.setName(p.getName());
    d.setTypePriorities(p.getTypePriorities());
    d.setTypeSystem(p.getTypeSystem());
    d.setVendor(p.getVendor());
    d.setVersion(p.getVersion());
    d.setOperationalProperties(p.getOperationalProperties());
    return d;
  }
View Full Code Here

    typeSystemsToMerge = new ArrayList();
    typePrioritiesToMerge = new ArrayList();
    fsIndexesToMerge = new ArrayList();
    Iterator it = mdList.iterator();
    while (it.hasNext()) {
      ProcessingResourceMetaData md = (ProcessingResourceMetaData) it.next();
      if (md.getTypeSystem() != null)
        typeSystemsToMerge.add(md.getTypeSystem());
      if (md.getTypePriorities() != null)
        typePrioritiesToMerge.add(md.getTypePriorities());
      if (md.getFsIndexCollection() != null)
        fsIndexesToMerge.add(md.getFsIndexCollection());
    }
  }
View Full Code Here

    aeDescription.setResourceManagerConfiguration(r.getResourceManagerConfiguration());
    setAeDescription(aeDescription);
  }

  private AnalysisEngineMetaData convertToAeMetaData(ResourceMetaData r) {
    ProcessingResourceMetaData p = (ProcessingResourceMetaData) r;
    AnalysisEngineMetaData d = UIMAFramework.getResourceSpecifierFactory()
            .createAnalysisEngineMetaData();
    d.setCapabilities(p.getCapabilities());
    d.setConfigurationParameterDeclarations(p.getConfigurationParameterDeclarations());
    d.setConfigurationParameterSettings(p.getConfigurationParameterSettings());
    d.setCopyright(p.getCopyright());
    d.setDescription(p.getDescription());
    d.setFsIndexCollection(p.getFsIndexCollection());
    d.setName(p.getName());
    d.setTypePriorities(p.getTypePriorities());
    d.setTypeSystem(p.getTypeSystem());
    d.setVendor(p.getVendor());
    d.setVersion(p.getVersion());
    d.setOperationalProperties(p.getOperationalProperties());
    ((AnalysisEngineMetaData_impl)d).setInfoset(((MetaDataObject_impl)r).getInfoset());
    return d;
  }
View Full Code Here

    ((AnalysisEngineMetaData_impl)d).setInfoset(((MetaDataObject_impl)r).getInfoset());
    return d;
  }

  private ProcessingResourceMetaData convertFromAeMetaData(AnalysisEngineMetaData p) {
    ProcessingResourceMetaData d = UIMAFramework.getResourceSpecifierFactory()
            .createProcessingResourceMetaData();
    d.setCapabilities(p.getCapabilities());
    d.setConfigurationParameterDeclarations(p.getConfigurationParameterDeclarations());
    d.setConfigurationParameterSettings(p.getConfigurationParameterSettings());
    d.setCopyright(p.getCopyright());
    d.setDescription(p.getDescription());
    d.setFsIndexCollection(p.getFsIndexCollection());
    d.setName(p.getName());
    d.setTypePriorities(p.getTypePriorities());
    d.setTypeSystem(p.getTypeSystem());
    d.setVendor(p.getVendor());
    d.setVersion(p.getVersion());
    d.setOperationalProperties(p.getOperationalProperties());
    ((MetaDataObject_impl)d).setInfoset(((MetaDataObject_impl)p).getInfoset());
    return d;
  }
View Full Code Here

    typeSystemsToMerge = new ArrayList();
    typePrioritiesToMerge = new ArrayList();
    fsIndexesToMerge = new ArrayList();
    Iterator it = mdList.iterator();
    while (it.hasNext()) {
      ProcessingResourceMetaData md = (ProcessingResourceMetaData) it.next();
      if (md.getTypeSystem() != null)
        typeSystemsToMerge.add(md.getTypeSystem());
      if (md.getTypePriorities() != null)
        typePrioritiesToMerge.add(md.getTypePriorities());
      if (md.getFsIndexCollection() != null)
        fsIndexesToMerge.add(md.getFsIndexCollection());
    }
  }
View Full Code Here

      File descFile = JUnitExtension
              .getFile("TextAnalysisEngineImplTest/AggregateTaeForMergeTest.xml");
      AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
              new XMLInputSource(descFile));
      Map mergedTypes = new HashMap();
      ProcessingResourceMetaData mergedMetaData = CasCreationUtils
              .mergeDelegateAnalysisEngineMetaData(desc, UIMAFramework.newDefaultResourceManager(),
                      mergedTypes, null);
      TypeSystemDescription typeSys = mergedMetaData.getTypeSystem();
      TypePriorities pri = mergedMetaData.getTypePriorities();
      FsIndexCollection indexColl = mergedMetaData.getFsIndexCollection();

      // test results of merge
      // Type System
      Assert.assertEquals(8, typeSys.getTypes().length);

      TypeDescription type0 = typeSys.getType("NamedEntity");
      Assert.assertNotNull(type0);
      Assert.assertEquals("uima.tcas.Annotation", type0.getSupertypeName());
      Assert.assertEquals(1, type0.getFeatures().length);

      TypeDescription type1 = typeSys.getType("Person");
      Assert.assertNotNull(type1);
      Assert.assertEquals("NamedEntity", type1.getSupertypeName());
      Assert.assertEquals(1, type1.getFeatures().length);

      TypeDescription type2 = typeSys.getType("Place");
      Assert.assertNotNull(type2);
      Assert.assertEquals("NamedEntity", type2.getSupertypeName());
      Assert.assertEquals(3, type2.getFeatures().length);

      TypeDescription type3 = typeSys.getType("Org");
      Assert.assertNotNull(type3);
      Assert.assertEquals("uima.tcas.Annotation", type3.getSupertypeName());
      Assert.assertEquals(0, type3.getFeatures().length);

      TypeDescription type4 = typeSys.getType("DocumentStructure");
      Assert.assertNotNull(type4);
      Assert.assertEquals("uima.tcas.Annotation", type4.getSupertypeName());
      Assert.assertEquals(0, type4.getFeatures().length);

      TypeDescription type5 = typeSys.getType("Paragraph");
      Assert.assertNotNull(type5);
      Assert.assertEquals("DocumentStructure", type5.getSupertypeName());
      Assert.assertEquals(0, type5.getFeatures().length);

      TypeDescription type6 = typeSys.getType("Sentence");
      Assert.assertNotNull(type6);
      Assert.assertEquals("DocumentStructure", type6.getSupertypeName());
      Assert.assertEquals(0, type6.getFeatures().length);

      TypeDescription type7 = typeSys.getType("test.flowController.Test");
      Assert.assertNotNull(type7);
      Assert.assertEquals("uima.tcas.Annotation", type7.getSupertypeName());
      Assert.assertEquals(1, type7.getFeatures().length);

      // Place has merged features, Person has different supertype
      assertEquals(2, mergedTypes.size());
      assertTrue(mergedTypes.containsKey("Place"));
      assertTrue(mergedTypes.containsKey("Person"));

      // Type Priorities
      Assert.assertNotNull(pri);
      TypePriorityList[] priLists = pri.getPriorityLists();
      Assert.assertEquals(3, priLists.length);
      String[] list0 = priLists[0].getTypes();
      String[] list1 = priLists[1].getTypes();
      String[] list2 = priLists[2].getTypes();
      // order of the three lists is not defined
      Assert.assertTrue((list0.length == 2 && list1.length == 2 && list2.length == 3)
              || (list0.length == 2 && list1.length == 3 && list2.length == 2)
              || (list0.length == 3 && list1.length == 2 && list2.length == 2));

      // Indexes
      FsIndexDescription[] indexes = indexColl.getFsIndexes();
      Assert.assertEquals(3, indexes.length);
      // order of indexes is not defined
      String label0 = indexes[0].getLabel();
      String label1 = indexes[1].getLabel();
      String label2 = indexes[2].getLabel();
      Assert.assertTrue(label0.equals("DocStructIndex") || label1.equals("DocStructIndex")
              || label2.equals("DocStructIndex"));
      Assert.assertTrue(label0.equals("PlaceIndex") || label1.equals("PlaceIndex")
              || label2.equals("PlaceIndex"));
      Assert.assertTrue(label0.equals("FlowControllerTestIndex")
              || label1.equals("FlowControllerTestIndex")
              || label2.equals("FlowControllerTestIndex"));

      // Now test case where aggregate contains a remote, and we want to do the
      // merge of the non-remote delegates and report the failure.  (This example
      // also happens to use import-by-name so we need to set the data path.)
      ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
      String pathSep = System.getProperty("path.separator");
      resMgr.setDataPath(JUnitExtension.getFile("TypeSystemDescriptionImplTest/dataPathDir")
              .getAbsolutePath()
              + pathSep
              + JUnitExtension.getFile("TypePrioritiesImplTest/dataPathDir").getAbsolutePath()
              + pathSep
              + JUnitExtension.getFile("FsIndexCollectionImplTest/dataPathDir").getAbsolutePath());

      File descFile2 = JUnitExtension
              .getFile("CasCreationUtilsTest/AggregateTaeWithSoapDelegate.xml");
      AnalysisEngineDescription desc2 = UIMAFramework.getXMLParser()
              .parseAnalysisEngineDescription(new XMLInputSource(descFile2));
      Map mergedTypes2 = new HashMap();
      Map failedRemotes = new HashMap();
      ProcessingResourceMetaData mergedMetaData2 = CasCreationUtils
              .mergeDelegateAnalysisEngineMetaData(desc2, resMgr,
                      mergedTypes2, failedRemotes);
      assertTrue(failedRemotes.containsKey("/RemoteDelegate"));
      // ((Exception)failedRemotes.get("/RemoteDelegate")).printStackTrace();
      assertTrue(mergedMetaData2.getTypeSystem().getTypes().length > 0);

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

      if (!fwImpl.startsWith(Constants.JAVA_FRAMEWORK_NAME)) {
        return false;
      }

      super.initialize(aSpecifier, aAdditionalParams);
      ProcessingResourceMetaData md = (ProcessingResourceMetaData) mDescription.getMetaData();

      // Get logger for this class
      Logger logger = getLogger();
      logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE,
              "UIMA_analysis_engine_init_begin__CONFIG", md.getName());

      // Normalize language codes. Need to do this since a wide variety of
      // spellings are acceptable according to ISO.
      normalizeIsoLangCodes(md);

      // clone this metadata and assign a UUID if not already present
      ResourceMetaData mdCopy = (ResourceMetaData) md.clone();

      if (mdCopy.getUUID() == null) {
        mdCopy.setUUID(UUIDGenerator.generate());
      }
      setMetaData(mdCopy);

      // validate the AnalysisEngineDescription and throw a
      // ResourceInitializationException if there is a problem
      mDescription.validate(getResourceManager());

      // Read parameters from the aAdditionalParams map.
      if (aAdditionalParams == null) {
        aAdditionalParams = Collections.emptyMap();
      }
      // determine if verification mode is on
      mVerificationMode = aAdditionalParams.containsKey(PARAM_VERIFICATION_MODE);

      // determine if this component is Sofa-aware (based on whether it
      // declares any input or output sofas in its capabilities)
      mSofaAware = getAnalysisEngineMetaData().isSofaAware();

      initializeAnalysisComponent(aAdditionalParams);

      // Initialize ResultSpec based on output capabilities
      // TODO: should only do this for outermost AE
      resetResultSpecificationToDefault();

      logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE,
              "UIMA_analysis_engine_init_successful__CONFIG", md.getName());
      return true;
    } catch (ResourceConfigurationException e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] {
                  getMetaData().getName(), aSpecifier.getSourceUrlString() });
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.metadata.ProcessingResourceMetaData

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.