Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.ResultSpecification


              String nextAeKey = ((SimpleStep) nextStep).getAnalysisEngineKey();
              AnalysisEngine nextAe = (AnalysisEngine) mComponentAnalysisEngineMap.get(nextAeKey);
              if (nextAe != null) {
                //check if we have to set result spec, to support capability language flow
                if (nextStep instanceof SimpleStepWithResultSpec) {
                  ResultSpecification rs = ((SimpleStepWithResultSpec)nextStep).getResultSpecification();
                  if (rs != null) {
                    nextAe.setResultSpecification(rs);
                  }
                }
                // invoke next AE in flow
View Full Code Here


          mLastTypeSystem = view.getTypeSystem();
          mCurrentResultSpecification.setTypeSystem(mLastTypeSystem);
          // the actual ResultSpec we send to the component is formed by
          // looking at this primitive AE's declared output types and eliminiating
          // any that are not in mCurrentResultSpecification.
          ResultSpecification analysisComponentResultSpec = computeAnalysisComponentResultSpec(
                  mCurrentResultSpecification, getAnalysisEngineMetaData().getCapabilities());
          mAnalysisComponent.setResultSpecification(analysisComponentResultSpec);
          mResultSpecChanged = false;
        }
       
View Full Code Here

   *
   * @return a ResultSpecifciation to pass to the AnalysisComponent
   */
  protected ResultSpecification computeAnalysisComponentResultSpec(
          ResultSpecification inputResultSpec, Capability[] capabilities) {
    ResultSpecification newResultSpec = new ResultSpecification_impl(inputResultSpec.getTypeSystem());
    List<String> languagesToAdd = new ArrayList<String>();
    for (Capability capability : capabilities) {
      TypeOrFeature[] outputs = capability.getOutputs();
      String[] languages = capability.getLanguagesSupported();
      if (null == languages || languages.length == 0) {
        languages = X_UNSPECIFIED;
      }
     
      for (TypeOrFeature tof : outputs) {
        String tofName = tof.getName();
        languagesToAdd.clear();
        for (String language : languages) {
          if ((tof.isType() && inputResultSpec.containsType(tofName, language)) ||
              (!tof.isType() && inputResultSpec.containsFeature(tofName, language))) {
            languagesToAdd.add(language);
          }
        }
        if (0 < languagesToAdd.size()) {
          if (tof.isType()) {
            newResultSpec.addResultType(tofName, tof.isAllAnnotatorFeatures(),
                languagesToAdd.toArray(EMPTY_STRING_ARRAY));
          } else {
            newResultSpec.addResultFeature(tofName, languagesToAdd.toArray(EMPTY_STRING_ARRAY));
         
        }
      }
    }
    return newResultSpec;   
View Full Code Here

    } else {
      // To form the result spec that will be passed down to each component,
      // we take the union aResultSpec with the inputs of all components in this
      // aggregate. This forms the complete list of types that any component in
      // this aggregate might ever need to produce.
      ResultSpecification resultSpecForComponents = (ResultSpecification) aResultSpec.clone();
      resultSpecForComponents.addCapabilities(getAllComponentCapabilities(), false);

      // now iterate over components and call their setResultSpecification methods
      Iterator<AnalysisEngine> componentIter = _getASB().getComponentAnalysisEngines().values().iterator();
      while (componentIter.hasNext()) {
        AnalysisEngine ae = (AnalysisEngine) componentIter.next();
View Full Code Here

  protected void _testProcess(AnalysisEngineDescription aTaeDesc) throws UIMAException {
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aTaeDesc);
    CAS tcas = ae.newCAS();

    // process(CAS,ResultSpecification)
    ResultSpecification resultSpec = new ResultSpecification_impl(tcas.getTypeSystem());
    resultSpec.addResultType("NamedEntity", true);

    _testProcessInner(ae, tcas, resultSpec, resultSpec);
  }
View Full Code Here

  protected void _testProcess(AnalysisEngineDescription aTaeDesc, String[] languages) throws UIMAException {
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aTaeDesc);
    CAS tcas = ae.newCAS();

    // process(CAS,ResultSpecification)
    ResultSpecification resultSpec = new ResultSpecification_impl(tcas.getTypeSystem());
    resultSpec.addResultType("NamedEntity", true);   // includes subtypes Person, Sentence, Place, Paragraph
                                                     // sets for lang = x-unspecified
   
    ResultSpecification expectedLastResultSpec = new ResultSpecification_impl(tcas.getTypeSystem());
    // interesting case:
    //   Because the annotator extends a UIMA Version 1.x impl class, we go thru an "adapter" interface
    //     which normally replaces the result spec with one that is based on language x-unspecified
    //       (guessing because version 1.x didn't properly support languages)
    //     However there's an exception to this: if the result spec would have no types or features
    //       for the language in the CAS, the original result spec is used, rather than a
    //       new one based on x-unspecified.
    expectedLastResultSpec.addResultType("NamedEntity", true, languages)

    _testProcessInner(ae, tcas, resultSpec, expectedLastResultSpec);
  }
View Full Code Here

              String nextAeKey = ((SimpleStep) nextStep).getAnalysisEngineKey();
              AnalysisEngine nextAe = (AnalysisEngine) mComponentAnalysisEngineMap.get(nextAeKey);
              if (nextAe != null) {
                //check if we have to set result spec, to support capability language flow
                if (nextStep instanceof SimpleStepWithResultSpec) {
                  ResultSpecification rs = ((SimpleStepWithResultSpec)nextStep).getResultSpecification();
                  if (rs != null) {
                    nextAe.setResultSpecification(rs);
                  }
                }
                // invoke next AE in flow
View Full Code Here

            rsFromOutputCapabilities.addCapabilities(this.getAnalysisEngineMetaData().getCapabilities());
          }
          // the actual ResultSpec we send to the component is formed by
          // looking at this primitive AE's declared output types and eliminating
          // any that are not in mCurrentResultSpecification.
          ResultSpecification analysisComponentResultSpec =
            ((ResultSpecification_impl)mCurrentResultSpecification).intersect((ResultSpecification_impl)rsFromOutputCapabilities);
          mAnalysisComponent.setResultSpecification(analysisComponentResultSpec);
          mResultSpecChanged = false;
        }
      
View Full Code Here

    } else {
      // To form the result spec that will be passed down to each component,
      // we take the union aResultSpec with the inputs of all components in this
      // aggregate. This forms the complete list of types that any component in
      // this aggregate might ever need to produce.
      ResultSpecification resultSpecForComponents = (ResultSpecification) aResultSpec.clone();
      resultSpecForComponents.addCapabilities(getAllComponentCapabilities(), false);

      // now iterate over components and call their setResultSpecification methods
      Iterator<AnalysisEngine> componentIter = _getASB().getComponentAnalysisEngines().values().iterator();
      while (componentIter.hasNext()) {
        AnalysisEngine ae = (AnalysisEngine) componentIter.next();
View Full Code Here

    // does nothing by default (for service adapters)
    // overridden in both primitive and aggregate AE implementations
  }

  public void resetResultSpecificationToDefault() {
    ResultSpecification resultSpec = new ResultSpecification_impl();
    resultSpec.addCapabilities(this.getAnalysisEngineMetaData().getCapabilities());
    setResultSpecification(resultSpec);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.analysis_engine.ResultSpecification

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.