Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.AnalysisEngineDescription


  public Map getMetadataAsMap() throws ResourceInitializationException {
    return processingResourceMap;
  }

  public void setMetadata(String aDescriptorName) throws Exception {
    AnalysisEngineDescription specifier = UIMAFramework.getXMLParser()
            .parseAnalysisEngineDescription(new XMLInputSource(new File(aDescriptorName)));

    AnalysisEngineMetaData meta = specifier.getAnalysisEngineMetaData();
    addMetadata(meta);
  }
View Full Code Here


    addMetadata(meta);
  }

  private void addProcessingResourceMetadata(String mapkey, String aDescriptorName)
          throws Exception {
    AnalysisEngineDescription specifier = UIMAFramework.getXMLParser()
            .parseAnalysisEngineDescription(new XMLInputSource(new File(aDescriptorName)));

    AnalysisEngineMetaData meta = specifier.getAnalysisEngineMetaData();
    addMetadata(meta);
    processingResourceMap.put(mapkey, meta);
  }
View Full Code Here

    }
    URL aedesc = RutaEngine.class.getResource("BasicEngine.xml");
    XMLInputSource inae = new XMLInputSource(aedesc);
    ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(inae);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    AnalysisEngineDescription aed = (AnalysisEngineDescription) specifier;

    ae = UIMAFramework.produceAnalysisEngine(aed, resMgr, null);
    File tempFile = File.createTempFile("RutaCDE", RutaEngine.SCRIPT_FILE_EXTENSION);
    tempFile.deleteOnExit();
    FileUtils.saveString2File(sb.toString(), tempFile, "UTF-8");
View Full Code Here

    script += rule;
    URL aedesc = RutaEngine.class.getResource("BasicEngine.xml");
    XMLInputSource inae = new XMLInputSource(aedesc);
    ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(inae);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    AnalysisEngineDescription aed = (AnalysisEngineDescription) specifier;
    TypeSystemDescription basicTypeSystem = aed.getAnalysisEngineMetaData().getTypeSystem();
    if (!typeSystemLocation.equals("")) {
      String tsLocation = typeSystemLocation;
      Collection<TypeSystemDescription> tsds = new ArrayList<TypeSystemDescription>();
      tsds.add(basicTypeSystem);
      if (typeSystemLocation.endsWith(".ruta")) {
        IFile iFile = RutaAddonsPlugin.getIFile(typeSystemLocation);
        IPath scriptPath = iFile.getLocation();
        IProject project = iFile.getProject();
        IPath descriptorRootPath = RutaProjectUtils.getDescriptorRootPath(project);
        resMgr.setDataPath(descriptorRootPath.toPortableString());
        IPath path = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath, project);
        tsLocation = path.toPortableString();
      }
      File tsFile = new File(tsLocation);
      XMLInputSource ints = new XMLInputSource(tsFile);
      TypeSystemDescription importTSD = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              ints);
      importTSD.resolveImports(resMgr);
      tsds.add(importTSD);
      TypeSystemDescription mergeTypeSystems = CasCreationUtils.mergeTypeSystems(tsds);
      aed.getAnalysisEngineMetaData().setTypeSystem(mergeTypeSystems);
    }
    aed.resolveImports(resMgr);
    ae = UIMAFramework.produceAnalysisEngine(aed, resMgr, null);
    File tempFile = File.createTempFile("RutaRuta", RutaEngine.SCRIPT_FILE_EXTENSION);
    tempFile.deleteOnExit();
    FileUtils.saveString2File(script, tempFile, "UTF-8");
    String portableString = Path.fromOSString(tempFile.getParentFile().getPath())
View Full Code Here

      url = RutaTestUtils.class.getClassLoader().getResource(
              "org/apache/uima/ruta/example/extensions/TestEngine.xml");
    }
    XMLInputSource in = new XMLInputSource(url);
    ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
    AnalysisEngineDescription aed = (AnalysisEngineDescription) specifier;

    TypeSystemDescription basicTypeSystem = aed.getAnalysisEngineMetaData().getTypeSystem();
    for (int i = 1; i <= amount; i++) {
      basicTypeSystem.addType(TYPE + i, "Type for Testing", "uima.tcas.Annotation");
    }

    if (complexTypes != null) {
      Set<Entry<String, String>> entrySet = complexTypes.entrySet();
      for (Entry<String, String> entry : entrySet) {
        String name = entry.getKey();
        TypeDescription addType = basicTypeSystem.addType(name, "Type for Testing",
                entry.getValue());
        if (features != null) {
          List<TestFeature> list = features.get(name);
          for (TestFeature f : list) {
            addType.addFeature(f.name, f.description, f.range);
          }
        }
      }
    }

    Collection<TypeSystemDescription> tsds = new ArrayList<TypeSystemDescription>();
    tsds.add(basicTypeSystem);
    TypeSystemDescription mergeTypeSystems = CasCreationUtils.mergeTypeSystems(tsds);
    aed.getAnalysisEngineMetaData().setTypeSystem(mergeTypeSystems);

    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
    ae.setConfigParameterValue(RutaEngine.PARAM_SCRIPT_PATHS, new String[] { ruleFile
            .getParentFile().getPath() });
    String name = ruleFile.getName();
View Full Code Here

    script += rules;
    URL aedesc = RutaEngine.class.getResource("BasicEngine.xml");
    XMLInputSource inae = new XMLInputSource(aedesc);
    ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(inae);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    AnalysisEngineDescription aed = (AnalysisEngineDescription) specifier;
    TypeSystemDescription basicTypeSystem = aed.getAnalysisEngineMetaData().getTypeSystem();
    if (!typeSystemLocation.equals("")) {
      String tsLocation = typeSystemLocation;
      Collection<TypeSystemDescription> tsds = new ArrayList<TypeSystemDescription>();
      tsds.add(basicTypeSystem);
      if (typeSystemLocation.endsWith(".ruta")) {
        IFile iFile = RutaAddonsPlugin.getIFile(typeSystemLocation);
        IPath scriptPath = iFile.getLocation();
        IProject project = iFile.getProject();
        IPath descriptorRootPath = RutaProjectUtils.getDescriptorRootPath(project);
        resMgr.setDataPath(descriptorRootPath.toPortableString());
        IPath path = RutaProjectUtils.getTypeSystemDescriptorPath(scriptPath, project);
        tsLocation = path.toPortableString();
      }
      File tsFile = new File(tsLocation);
      XMLInputSource ints = new XMLInputSource(tsFile);
      TypeSystemDescription importTSD = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              ints);
      importTSD.resolveImports(resMgr);
      tsds.add(importTSD);
      TypeSystemDescription mergeTypeSystems = CasCreationUtils.mergeTypeSystems(tsds);
      aed.getAnalysisEngineMetaData().setTypeSystem(mergeTypeSystems);
    }
    aed.resolveImports(resMgr);
    ae = UIMAFramework.produceAnalysisEngine(aed, resMgr, null);
    File tempFile = File.createTempFile("RutaCDE", RutaEngine.SCRIPT_FILE_EXTENSION);
    tempFile.deleteOnExit();
    FileUtils.saveString2File(script, tempFile, "UTF-8");
    String portableString = Path.fromOSString(tempFile.getParentFile().getPath())
View Full Code Here

  public static URL getResourceURL(String name) {
    return FileLocator.find(TextRulerPlugin.getDefault().getBundle(), new Path(name), null);
  }

  public static AnalysisEngineDescription getAnalysisEngineDescription(String descFile) {
    AnalysisEngineDescription result = null;
    try {
      XMLInputSource in = new XMLInputSource(descFile);
      result = (AnalysisEngineDescription) UIMAFramework.getXMLParser().parseResourceSpecifier(in);
    } catch (Exception e) {
      TextRulerPlugin.error(e);
View Full Code Here

    }
    return result;
  }

  public static AnalysisEngineDescription getAnalysisEngineDescription(URL fileURL) {
    AnalysisEngineDescription result = null;
    try {
      XMLInputSource in = new XMLInputSource(fileURL);
      result = (AnalysisEngineDescription) UIMAFramework.getXMLParser().parseResourceSpecifier(in);
    } catch (Exception e) {
      TextRulerPlugin.error(e);
View Full Code Here

  public static boolean checkRessourceExistence(String resourceFilePath, IScriptProject project) {
    IFolder ddlFolder = project.getProject().getFolder(
            RutaProjectUtils.getDefaultDescriptorLocation());
    final String basicXML = "BasicEngine.xml";
    IFile file = getFile(ddlFolder, basicXML);
    AnalysisEngineDescription aed;
    try {
      URL url = file.getLocationURI().toURL();
      aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(url));
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    ConfigurationParameterSettings configurationParameterSettings = aed.getAnalysisEngineMetaData()
            .getConfigurationParameterSettings();
    String[] paths = (String[]) configurationParameterSettings
            .getParameterValue(RutaEngine.PARAM_RESOURCE_PATHS);
    if (paths == null) {
      IFolder folder = project.getProject().getFolder(
View Full Code Here

  private void updateAE() {
    String descriptorFile = TextRulerToolkit.getEngineDescriptorFromTMSourceFile(new Path(
            preprocessorTMFile));
    sendStatusUpdateToDelegate("loading AE...", TextRulerLearnerState.ML_INITIALIZING, false);

    AnalysisEngineDescription description = TextRulerToolkit
            .getAnalysisEngineDescription(descriptorFile);
    if (description == null) {
      sendStatusUpdateToDelegate("Failed to load descriptor. Please rebuild the project.",
              TextRulerLearnerState.ML_INITIALIZING, false);
      return;
View Full Code Here

TOP

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

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.