Package org.apache.uima.ruta

Examples of org.apache.uima.ruta.RutaModule


  private void recursiveLoadScript(String toLoad, Map<String, RutaModule> additionalScripts,
          Map<String, AnalysisEngine> additionalEngines, String viewName)
          throws AnalysisEngineProcessException {
    String location = locate(toLoad, scriptPaths, SCRIPT_FILE_EXTENSION);
    RutaModule eachScript = null;
    if (location == null) {
      try {
        String scriptPath = toLoad.replaceAll("\\.", "/") + SCRIPT_FILE_EXTENSION;
        eachScript = loadScriptIS(scriptPath);
      } catch (IOException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      } catch (RecognitionException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      }
    } else {
      try {
        eachScript = loadScript(location);
      } catch (IOException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      } catch (RecognitionException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      }
    }
    additionalScripts.put(toLoad, eachScript);

    for (String add : eachScript.getScripts().keySet()) {
      if (!additionalScripts.containsKey(add)) {
        recursiveLoadScript(add, additionalScripts, additionalEngines, viewName);
      }
    }

    Set<String> engineKeySet = eachScript.getEngines().keySet();
    for (String eachEngineLocation : engineKeySet) {
      if (!additionalEngines.containsKey(eachEngineLocation)) {
        String engineLocation = locate(eachEngineLocation, descriptorPaths, ".xml");
        if (engineLocation == null) {
          String engineLocationIS = locateIS(eachEngineLocation, descriptorPaths, ".xml");
View Full Code Here


    String name = scriptFile.getName();
    int lastIndexOf = name.lastIndexOf(SCRIPT_FILE_EXTENSION);
    if (lastIndexOf != -1) {
      name = name.substring(0, lastIndexOf);
    }
    RutaModule script = parser.file_input(name);
    return script;
  }
View Full Code Here

    }
    int lastIndexOf = name.lastIndexOf(SCRIPT_FILE_EXTENSION);
    if (lastIndexOf != -1) {
      name = name.substring(0, lastIndexOf);
    }
    RutaModule script = parser.file_input(name);
    return script;
  }
View Full Code Here

  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    RutaModule thisScript = parent.getScript();
    AnalysisEngine targetEngine = thisScript.getEngine(namespace);
    ConfigurationParameterDeclarations configurationParameterDeclarations = targetEngine
            .getAnalysisEngineMetaData().getConfigurationParameterDeclarations();

    Set<Entry<IStringExpression, IRutaExpression>> entrySet = parameterMap.entrySet();
    for (Entry<IStringExpression, IRutaExpression> entry : entrySet) {
View Full Code Here

    this.namespace = namespace;
  }

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaModule thisScript = element.getParent().getScript();
    AnalysisEngine targetEngine = thisScript.getEngine(namespace);
    if (targetEngine != null) {
      try {
        callEngine(match, crowd, targetEngine, element, stream);
      } catch (AnalysisEngineProcessException e) {
        e.printStackTrace();
      } catch (ResourceInitializationException e) {
        e.printStackTrace();
      }
    } else {
      String scriptName = namespace;
      String blockName = namespace;
      String[] split = namespace.split("[.]");
      if (split.length > 1) {
        scriptName = split[0];
        blockName = split[split.length - 1];
      }
      RutaModule targetScript = thisScript.getScript(scriptName);
      if (targetScript != null) {
        callScript(blockName, match, element, stream, crowd, targetScript);
      } else {
        System.out.println("Found no script: " + scriptName);
      }
View Full Code Here

  private void recursiveLoadScript(String toLoad, Map<String, RutaModule> additionalScripts,
          Map<String, AnalysisEngine> additionalEngines, String viewName)
          throws AnalysisEngineProcessException {
    String location = locate(toLoad, scriptPaths, SCRIPT_FILE_EXTENSION);
    RutaModule eachScript = null;
    if (location == null) {
      try {
        String scriptPath = toLoad.replaceAll("\\.", "/") + SCRIPT_FILE_EXTENSION;
        eachScript = loadScriptIS(scriptPath);
      } catch (IOException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      } catch (RecognitionException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      }
    } else {
      try {
        eachScript = loadScript(location);
      } catch (IOException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      } catch (RecognitionException e) {
        throw new AnalysisEngineProcessException(new FileNotFoundException("Script [" + toLoad
                + "] cannot be found at [" + collectionToString(scriptPaths)
                + "] with extension .ruta"));
      }
    }
    additionalScripts.put(toLoad, eachScript);

    for (String add : eachScript.getScripts().keySet()) {
      if (!additionalScripts.containsKey(add)) {
        recursiveLoadScript(add, additionalScripts, additionalEngines, viewName);
      }
    }

    Set<String> engineKeySet = eachScript.getEngines().keySet();
    for (String eachEngineLocation : engineKeySet) {
      if (!additionalEngines.containsKey(eachEngineLocation)) {
        String engineLocation = locate(eachEngineLocation, descriptorPaths, ".xml");
        if (engineLocation == null) {
          String engineLocationIS = locateIS(eachEngineLocation, descriptorPaths, ".xml");
View Full Code Here

    String name = scriptFile.getName();
    int lastIndexOf = name.lastIndexOf(SCRIPT_FILE_EXTENSION);
    if (lastIndexOf != -1) {
      name = name.substring(0, lastIndexOf);
    }
    RutaModule script = parser.file_input(name);
    return script;
  }
View Full Code Here

    }
    int lastIndexOf = name.lastIndexOf(SCRIPT_FILE_EXTENSION);
    if (lastIndexOf != -1) {
      name = name.substring(0, lastIndexOf);
    }
    RutaModule script = parser.file_input(name);
    return script;
  }
View Full Code Here

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {

    RutaModule thisScript = element.getParent().getScript();

    AnalysisEngine targetEngine = thisScript.getEngine(namespace);
    if (targetEngine != null) {
      try {
        callEngine(match, crowd, targetEngine, element, stream);
      } catch (AnalysisEngineProcessException e) {
        e.printStackTrace();
      } catch (ResourceInitializationException e) {
        e.printStackTrace();
      }
    } else {
      String scriptName = namespace;
      String blockName = namespace;
      String[] split = namespace.split("[.]");
      if (split.length > 1) {
        scriptName = split[0];
        blockName = split[split.length - 1];
      }
      RutaModule targetScript = thisScript.getScript(scriptName);
      if (targetScript != null) {
        callScript(blockName, match, element, stream, crowd, targetScript);
      } else {
        System.out.println("Found no script: " + scriptName);
      }
View Full Code Here

  private void recursiveLoadScript(String toLoad, Map<String, RutaModule> additionalScripts,
          Map<String, AnalysisEngine> additionalEngines, String viewName) throws AnalysisEngineProcessException {
    String location = locate(toLoad, scriptPaths, SCRIPT_FILE_EXTENSION);
    try {
      TypeSystemDescription localTSD = getLocalTSD(toLoad);
      RutaModule eachScript = loadScript(location, localTSD);
      additionalScripts.put(toLoad, eachScript);
      for (String add : eachScript.getScripts().keySet()) {
        if (!additionalScripts.containsKey(add)) {
          recursiveLoadScript(add, additionalScripts, additionalEngines, viewName);
        }
      }
      Set<String> engineKeySet = eachScript.getEngines().keySet();
      for (String eachEngineLocation : engineKeySet) {
        if (!additionalEngines.containsKey(eachEngineLocation)) {
          String engineLocation = locate(eachEngineLocation, descriptorPaths, ".xml");
          try {
            AnalysisEngine eachEngine = engineLoader.loadEngine(engineLocation, viewName);
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.RutaModule

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.