Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.ResultSpecification


        // see if this next cas processor was previously given this result spec, and
        // if so, set a flag indicating this
       
        Map<String, ResultSpecification> lastResultSpecForComponent = mParentController.getLastResultSpecForComponent();
        String component = node.getCasProcessorKey();
        ResultSpecification neededResultSpec = node.getResultSpec();     
        ResultSpecification previousResultSpec = lastResultSpecForComponent.get(component);
       
        if (null == previousResultSpec || previousResultSpec != neededResultSpec) {
          lastResultSpecForComponent.put(component, neededResultSpec);
          return new SimpleStepWithResultSpec(component, neededResultSpec);
        }
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

          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

    // do proper typecasts and call process method
    try {
      if (mAnnotator instanceof TextAnnotator) {
        CAS cas = (CAS) aCAS;
        ResultSpecification rs = getResultSpecForLanguage(cas.getDocumentLanguage());
        rs.setTypeSystem(cas.getTypeSystem());
        ((TextAnnotator) mAnnotator).process(cas, rs);
      } else if (mAnnotator instanceof JTextAnnotator) {
        JCas jcas = (JCas) aCAS;
        ResultSpecification rs = getResultSpecForLanguage(jcas.getDocumentLanguage());
        rs.setTypeSystem(jcas.getTypeSystem());
        ((JTextAnnotator) mAnnotator).process(jcas, rs);
      } else if (mAnnotator instanceof GenericAnnotator) {
        mDefaultResultSpecification.setTypeSystem(((CAS) aCAS).getTypeSystem());
        ((GenericAnnotator) mAnnotator).process((CAS) aCAS, mDefaultResultSpecification);
      }
View Full Code Here

   * @param language
   * @return
   */
  private ResultSpecification getResultSpecForLanguage(String language) {
    // we cache this since it is called for each document
    ResultSpecification rs = (ResultSpecification) mLanguageToResultSpecMap.get(language);
    if (rs == null) {
      TypeOrFeature[] tofs = mDefaultResultSpecification.getResultTypesAndFeatures(language);
      if (tofs.length > 0) {
        rs = UIMAFramework.getResourceSpecifierFactory().createResultSpecification();
        rs.setResultTypesAndFeatures(tofs);
      } else {
        // special case: if annotator lists no outputs for this language, all it
        // with all possible outputs. This is mainly for backwards compatibility,
        // but here's a rationalization: the FlowController wants us to invoke the
        // annotator, so calling it with no outputs doesn't really make sense.
View Full Code Here

        tcas.setDocumentText("new test");
        mAE.process(tcas);
        tcas.reset();

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

        tcas.setDocumentText("testing...");
        mAE.process(tcas, resultSpec);
        tcas.reset();
View Full Code Here

  public void process(JCas aJCas) {
    jcas = aJCas;
    input = jcas.getDocumentText();

    // Create Annotations
    ResultSpecification resultSpec = getResultSpecification();
    boolean timeWanted = resultSpec.containsType("org.apache.uima.tutorial.TimeAnnot", aJCas.getDocumentLanguage());
    boolean dateWanted = resultSpec.containsType("org.apache.uima.tutorial.DateAnnot", aJCas.getDocumentLanguage());

    if (timeWanted)
      makeAnnotations(timeAnnotationMaker, hoursMinutesPattern, dfTimeShort);
   
    if (dateWanted) {   
View Full Code Here

      AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
      // create a CAS
      CAS cas = ae.newCAS();

      // build ResultSpec if Type and Feature names were specified on commandline
      ResultSpecification resultSpec = null;
      if (args.length > 2) {
        resultSpec = ae.createResultSpecification(cas.getTypeSystem());
        for (int i = 2; i < args.length; i++) {
          if (args[i].indexOf(':') > 0) // feature name
          {
            resultSpec.addResultFeature(args[i]);
          } else {
            resultSpec.addResultType(args[i], false);
          }
        }
      }

      // read contents of file
View Full Code Here

      casImpl.reinit(serializer);

      // 2. create result spec
      if (ae != null) {

        ResultSpecification rs = ae.createResultSpecification();
        for (int i = 0; i < resultSpecTypes.length; ++i) {
          // allAnnotatorFeatures is not considere here! (TODO)
          rs
                  .addResultType(casImpl.getTypeSystemImpl().getType(resultSpecTypes[i]).getName(),
                          false);
        }
        for (int i = 0; i < resultSpecFeatures.length; ++i) {
          rs.addResultFeature(casImpl.getTypeSystemImpl().getFeature(resultSpecFeatures[i])
                  .getName());
        }
        // 3. call process with cas
        ae.process(casImpl, rs);
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.