Package org.apache.uima.analysis_engine.impl

Examples of org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl


    // Initialize the CollectionReader, passing the appropriate UimaContext
    // We pass an empty descriptor to satisfy the Collection Reader's initialize
    // method; we don't want to do any additional set-up of resources or
    // config params, that's all handled in the initialization of the enclosing
    // Primitive AnalysisEngine.
    AnalysisEngineDescription_impl desc = new AnalysisEngineDescription_impl();

    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.put(Resource.PARAM_UIMA_CONTEXT, aContext);
    mCollectionReader.initialize(desc, paramsMap);
    mUimaContext = aContext;
View Full Code Here


   * @see org.apache.uima.core.AnalysisComponent#initialize(org.apache.uima.UimaContext)
   */
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    // Initialize the CasConsumer, passing the appropriate UimaContext
    // and a dummy descriptor containing the metadata passed to our constructor
    AnalysisEngineDescription_impl desc = new AnalysisEngineDescription_impl();
    desc.setMetaData(mMetaData);

    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.put(Resource.PARAM_UIMA_CONTEXT, aContext);
    mCasConsumer.initialize(desc, paramsMap);
  }
View Full Code Here

    // Initialize the CollectionReader, passing the appropriate UimaContext
    // We pass an empty descriptor to satisfy the Collection Reader's initialize
    // method; we don't want to do any additional set-up of resources or
    // config params, that's all handled in the initialization of the enclosing
    // Primitive AnalysisEngine.
    AnalysisEngineDescription_impl desc = new AnalysisEngineDescription_impl();

    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.put(Resource.PARAM_UIMA_CONTEXT, aContext);
    mCollectionReader.initialize(desc, paramsMap);
    mUimaContext = aContext;
View Full Code Here

   * @see org.apache.uima.core.AnalysisComponent#initialize(org.apache.uima.UimaContext)
   */
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    // Initialize the CasConsumer, passing the appropriate UimaContext
    // and a dummy descriptor containing the metadata passed to our constructor
    AnalysisEngineDescription_impl desc = new AnalysisEngineDescription_impl();
    desc.setMetaData(mMetaData);

    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.put(Resource.PARAM_UIMA_CONTEXT, aContext);
    mCasConsumer.initialize(desc, paramsMap);
  }
View Full Code Here

  public static AnalysisEngineDescription createAggregateDescription(
      boolean multipleDeploymentAllowed, List<List<String>> overrides, String... descriptorPaths)
      throws Exception {

    // create the descriptor and set configuration parameters
    AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
    resolver.setPathResolverClassLoader(desc.getClass().getClassLoader());
    desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
    desc.setPrimitive(false);
    ResourceSpecifier[] specifiers = new ResourceSpecifier[descriptorPaths.length];

    // Allow scale up
    desc.getAnalysisEngineMetaData().getOperationalProperties()
        .setMultipleDeploymentAllowed(multipleDeploymentAllowed);
    // Stores component names derived from implementation class
    List<String> flowNames = new ArrayList<String>();
    int inx = 0;
    // First produce ResourceSpecifiers from provided descriptors
    for (String aeDescription : descriptorPaths) {
      /*
      aeDescription = Utils.resolvePlaceholderIfExists(aeDescription,
          System.getProperties());
      XMLInputSource in = null;
      if (!aeDescription.endsWith(".xml")) {
        aeDescription = aeDescription.replace('.', '/') + ".xml";
        URL relativeURL = resolver.resolveRelativePath(getRelativePathWithProtocol(aeDescription));
//        URL relativeURL = resolveRelativePath(aeDescription);
        in = new XMLInputSource(relativeURL);
      } else {
        in = new XMLInputSource(aeDescription);
      }
      // XMLInputSource in = new XMLInputSource(aeDescription);
      ResourceSpecifier specifier = UIMAFramework.getXMLParser()
          .parseResourceSpecifier(in);
      specifiers[inx++] = specifier;
      */
      specifiers[inx++] = getResourceSpecifier(aeDescription);
      // UimaClassFactory.produceResourceSpecifier(aeDescription);
    }

    for (String aeDescription : descriptorPaths) {
      Import descriptorImport = new Import_impl();
      // If user provides a descriptor with .xml at the end, assume he
      // wants import by location
      if (aeDescription.endsWith(".xml")) {
        aeDescription = Utils.resolvePlaceholderIfExists(aeDescription,
            System.getProperties());
        if (!aeDescription.startsWith("file:")) {
          aeDescription = "file:" + aeDescription;
        }
        descriptorImport.setLocation(aeDescription);
      } else {
        // uima import by name expects dot separated path as in
        // a.b.descriptor and no .xml at the end
        descriptorImport.setName(aeDescription);
      }
      String key = new String(aeDescription);
      if (key.startsWith("file:")) {
        key = key.substring(5); // skip "file:"
      }
      if (key.endsWith(".xml")) {
        key = key.substring(0, key.indexOf(".xml")); // strip ".xml"
      }
      // preprocess the ae descriptor name to replace "/" and
      // "\" with ".". We will use the ae
      // descriptor name as AE key in the aggregate
      if (key.indexOf("/") != -1) {
        key = key.replaceAll("/", ".");
      }
      if (key.indexOf("\\") != -1) {
        key = key.replaceAll("\\\\", ".");
      }
      key = key.substring(key.lastIndexOf(".") + 1);
      desc.getDelegateAnalysisEngineSpecifiersWithImports().put(key,
          descriptorImport);
      flowNames.add(key);

    }
    String fcsn;
    if ( (fcsn = DuccPropertiesResolver.getInstance().getProperty(FlowControllerResourceSpecifier)) != null ) {
      FlowControllerDeclaration fcd = new FlowControllerDeclaration_impl();
      desc.setFlowControllerDeclaration(fcd);
      fcd.setImport(new Import_impl());   
      fcd.setKey(FlowControllerKey);
      fcd.getImport().setName(fcsn);
    }
   
    FixedFlow fixedFlow = new FixedFlow_impl();
    fixedFlow.setFixedFlow(flowNames.toArray(new String[flowNames.size()]));
    desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
    addOverrides(overrides, desc, specifiers, flowNames);

    return desc;
  }
View Full Code Here

    try {
      File baseDescriptorFile = JUnitExtension
              .getFile("ImportImplTest/subdir/subdir2/AggregateTaeForNestedImportTest.xml");
      File importedFile = JUnitExtension
              .getFile("ImportImplTest/subdir/PrimitiveTaeForNestedImportTest.xml");
      AnalysisEngineDescription_impl agg = (AnalysisEngineDescription_impl) UIMAFramework.getXMLParser()
              .parseAnalysisEngineDescription(new XMLInputSource(baseDescriptorFile));
      assertEquals(baseDescriptorFile.toURL(), agg.getSourceUrl());

      AnalysisEngineDescription_impl prim = (AnalysisEngineDescription_impl) agg.getDelegateAnalysisEngineSpecifiers()
              .get("Annotator1");
      assertEquals(importedFile.toURL(), prim.getSourceUrl());

      prim.getAnalysisEngineMetaData().getTypeSystem().resolveImports();
      assertEquals(1, prim.getAnalysisEngineMetaData().getTypeSystem().getTypes().length);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

    // Initialize the CollectionReader, passing the appropriate UimaContext
    // We pass an empty descriptor to satisfy the Collection Reader's initialize
    // method; we don't want to do any additional set-up of resources or
    // config params, that's all handled in the initialization of the enclosing
    // Primitive AnalysisEngine.
    AnalysisEngineDescription_impl desc = new AnalysisEngineDescription_impl();

    Map paramsMap = new HashMap();
    paramsMap.put(Resource.PARAM_UIMA_CONTEXT, aContext);
    mCollectionReader.initialize(desc, paramsMap);
    mUimaContext = aContext;
View Full Code Here

    try {
      File baseDescriptorFile = JUnitExtension
              .getFile("ImportImplTest/subdir/subdir2/AggregateTaeForNestedImportTest.xml");
      File importedFile = JUnitExtension
              .getFile("ImportImplTest/subdir/PrimitiveTaeForNestedImportTest.xml");
      AnalysisEngineDescription_impl agg = (AnalysisEngineDescription_impl) UIMAFramework.getXMLParser()
              .parseAnalysisEngineDescription(new XMLInputSource(baseDescriptorFile));
      assertEquals(baseDescriptorFile.toURL(), agg.getSourceUrl());

      AnalysisEngineDescription_impl prim = (AnalysisEngineDescription_impl) agg.getDelegateAnalysisEngineSpecifiers()
              .get("Annotator1");
      assertEquals(importedFile.toURL(), prim.getSourceUrl());

      prim.getAnalysisEngineMetaData().getTypeSystem().resolveImports();
      assertEquals(1, prim.getAnalysisEngineMetaData().getTypeSystem().getTypes().length);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() throws Exception {
    try {
      super.setUp();
      mSimpleDesc = new AnalysisEngineDescription_impl();
      mSimpleDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
      mSimpleDesc.setPrimitive(true);
      mSimpleDesc.getMetaData().setName("Test Primitive TAE");
      mSimpleDesc
              .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
View Full Code Here

      AnalysisEnginePool pool = new AnalysisEnginePool("taePool", 3, mSimpleDesc);
      _testProcess(pool, 0);

      // test simple aggregate MultithreadableTextAnalysisEngine
      // (again using TestAnnotator class)
      AnalysisEngineDescription aggDesc = new AnalysisEngineDescription_impl();
      aggDesc.setPrimitive(false);
      aggDesc.getMetaData().setName("Test Aggregate TAE");
      aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("Test", mSimpleDesc);
      FixedFlow_impl flow = new FixedFlow_impl();
      flow.setFixedFlow(new String[] { "Test" });
      aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);
      pool = new AnalysisEnginePool("taePool", 3, aggDesc);
      _testProcess(pool, 0);

      // multiple threads!
      final int NUM_THREADS = 4;
View Full Code Here

TOP

Related Classes of org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_impl

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.