org.apache.uima.resource.ResourceManager类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.uima.resource.ResourceManager类的一些代码示例,展示了ResourceManager类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager类的具体详情如下:
包路径:org.apache.uima.resource.ResourceManager
类名称:ResourceManager

ResourceManager介绍

[英]A ResourceManager holds a collection of org.apache.uima.resource.Resourceobjects, each registered under a specified key.
[中]一个ResourceManager包含一个组织的集合。阿帕奇。尤玛。资源Resourceobjects,每个都在指定的密钥下注册。

代码示例

代码示例来源:origin: apache/uima-uimaj

if (null == parentResourceManager) {
 rsrcMgr = UIMAFramework.newDefaultResourceManager();
} else {
 rsrcMgr = ((ResourceManager_impl) parentResourceManager).copy();
rsrcMgr.setExtensionClassPath(sp.classPath, true);
if (parentResourceManager != null) {
 rsrcMgr.setCasManager(parentResourceManager.getCasManager());  // shares the same merged type system
UIMAFramework.getLogger(this.getClass()).logrb(
   Level.CONFIG,
   this.getClass().getName(),
  rsrcMgr.setDataPath(sp.dataPath);
  UIMAFramework.getLogger(this.getClass()).logrb(
     Level.CONFIG,
     this.getClass().getName(),

代码示例来源:origin: org.dkpro.lab/dkpro-lab-uima

private ClassLoader getExtensionClassLoader()
{
  if (resMgr == null) {
    return null;
  }
  else {
    return resMgr.getExtensionClassLoader();
  }
}

代码示例来源:origin: CLLKazan/UIMA-Ext

classifierJarURL = classifierJarFile.toURI().toURL();
} else {
  ResourceManager rm = UIMAFramework.newDefaultResourceManager();
  if (additionalSearchPaths != null) {
    List<String> dpElements = Lists.newLinkedList();
    dpElements.add(rm.getDataPath());
    dpElements.addAll(Arrays.asList(additionalSearchPaths));
    rm.setDataPath(dataPathJoiner.join(dpElements));
  classifierJarURL = rm.resolveRelativePath(classifierJarPath);
  if (classifierJarURL == null) {
    throw new IllegalStateException(String.format(

代码示例来源:origin: apache/uima-uimaj

MetaDataCacheKey(ResourceSpecifier resourceSpecifier, ResourceManager resourceManager) {
 this.resourceSpecifier = resourceSpecifier;
 this.rmClassLoader = (null == resourceManager) ? null : resourceManager.getExtensionClassLoader(); // can be null
 this.rmDataPath = (null == resourceManager) ? null : resourceManager.getDataPath();
}

代码示例来源:origin: org.apache.uima/uimaj-tools

/**
 * Creates the resource manager.
 *
 * @return the resource manager
 */
public ResourceManager createResourceManager() {
 ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
 if (classPath != null && classPath.trim().length() > 0) {
  try {
   resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true);
  } catch (MalformedURLException e1) {
   error.newError(IError.ERROR, getString("Internal Error", null), e1);
  }
 }
 else {
   resourceManager.setExtensionClassLoader(this.getClass().getClassLoader(), true);
 }
 return resourceManager;
}

代码示例来源:origin: org.apache.uima/uimaj-tools

if (this.dataPathName != null) {
 try {
  rsrcMgr = UIMAFramework.newDefaultResourceManager();
  rsrcMgr.setDataPath(this.dataPathName);
 } catch (MalformedURLException e) {
  StringBuffer msg = new StringBuffer();
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
 this.ae = UIMAFramework.produceAnalysisEngine(specifier);
} else {
 this.ae = UIMAFramework.produceAnalysisEngine(specifier, rsrcMgr, null);

代码示例来源:origin: org.apache.uima/textmarker-core

private TypeSystemDescription getLocalTSD(String toLoad) throws InvalidXMLException, IOException {
 TypeSystemDescription localTSD = localTSDMap.get(toLoad);
 if (localTSD == null) {
  String locateTSD = locate(toLoad, descriptorPaths, "TypeSystem.xml", true);
  if (locateTSD != null) {
   localTSD = UIMAFramework.getXMLParser().parseTypeSystemDescription(
       new XMLInputSource(locateTSD));
   ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
   resMgr.setDataPath(getDataPath());
   localTSD.resolveImports(resMgr);
   localTSDMap.put(toLoad, localTSD);
  }
 }
 return localTSD;
}

代码示例来源:origin: org.apache.uima/uimaj-cpe

aResourceManager = UIMAFramework.newDefaultResourceManager();
uimaContext = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), aResourceManager,
    UIMAFramework.newConfigurationManager());
   resMgrCfg = UIMAFramework.getXMLParser().parseResourceManagerConfiguration(
       new XMLInputSource(descriptorPath));
   aResourceManager.initializeExternalResources(resMgrCfg, "/", null);

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

ResourceSpecifierFactory resourceSpecifierFactory = UIMAFramework.getResourceSpecifierFactory();
    extensionTypeSystemFile.getLocation().toFile());
XMLParser xmlParser = UIMAFramework.getXMLParser();
  resourceManager = new ResourceManager_impl(classLoader);
 } else {
  resourceManager = UIMAFramework.newDefaultResourceManager();
     .getPersistentProperty((new QualifiedName("", "CDEdataPath")));
 if (dataPath != null) {
  resourceManager.setDataPath(dataPath);

代码示例来源:origin: apache/uima-uimaj

resMgr = UIMAFramework.newDefaultResourceManager();
 Logger logger = UIMAFramework.getLogger(this.getClass());
 logger.setResourceManager(resMgr);
  configMgr = UIMAFramework.newConfigurationManager();
  mUimaContextAdmin.getResourceManager().initializeExternalResources(resMgrCfg,
      mUimaContextAdmin.getQualifiedContextName(), aAdditionalParmsForExtResources);
 } finally {
if (resourceDependencies != null) {
 mUimaContextAdmin.getResourceManager().resolveAndValidateResourceDependencies(
     resourceDependencies, mUimaContextAdmin.getQualifiedContextName());

代码示例来源:origin: org.apache.uima/ConceptMapper

public static void main(String[] args) throws Exception {
 String dictionaryResourceName = DICTIONARY_RESOURCE_NAME;
 if (args.length == 2) {
  // do nothing
 } else if (args.length == 3) {
  dictionaryResourceName = args[2];
 } else {
  usage();
  System.exit(17);
 }
 AnalysisEngineDescription conceptMapperDesc = UIMAFramework.getXMLParser()
     .parseAnalysisEngineDescription(new XMLInputSource(args[0]));
 AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(conceptMapperDesc);
 DictionaryResource_impl dict = (DictionaryResource_impl) ae.getResourceManager().getResource(
     dictionaryResourceName);
 OutputStream output = new BufferedOutputStream(new FileOutputStream(args[1]));
 dict.serializeEntries(output);
 output.close();
 ae.destroy();
 // for some reason JVM won't exit normally,
 // probably because CPM threads are alive?
 System.exit(0);
}

代码示例来源:origin: org.apache.uima/ConceptMapper

public void initCPM() throws DictionaryLoaderException {
 try {
  ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
  String dp = System.getProperty("uima.datapath");
  if (null != dp) {
   resMgr.setDataPath(dp);
  }
  ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
  cas = ae.newCAS();
 } catch (ResourceInitializationException e) {
  throw new DictionaryLoaderException(e);
 } catch (MalformedURLException e) {
   throw new DictionaryLoaderException(e);
 }
}

代码示例来源:origin: edu.utah.bmi.nlp/nlp-core

public ResourceManager createResourceManager() {
  ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
  try {
    resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true);
  } catch (MalformedURLException e1) {
    error.newError(IError.ERROR, getString("Internal Error", null), e1);
  }
  return resourceManager;
}

代码示例来源:origin: org.apache.uima/uimaj-ep-configurator

ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
  resourceManager.setExtensionClassPath(
  cachedRMcl = new SoftReference<UIMAClassLoader>((UIMAClassLoader) resourceManager.getExtensionClassLoader());
 resourceManager.setDataPath(dataPath);
} catch (MalformedURLException e1) {
 throw new InternalErrorCDE(Messages.getString("MultiPageEditor.14"), e1); //$NON-NLS-1$

代码示例来源:origin: org.apache.uima/uimaj-as-core

private void initializeComponentCasPool(int aComponentCasPoolSize, long anInitialCasHeapSize, boolean disableJCasCache) {
 if (aComponentCasPoolSize > 0) {
  EECasManager_impl cm = (EECasManager_impl) getResourceManager().getCasManager();
  
  cm.setInitialCasHeapSize(anInitialCasHeapSize);
  cm.setPoolSize(getUimaContextAdmin().getUniqueName(), aComponentCasPoolSize);
  if ( disableJCasCache ) {
   cm.disableJCasCaching();
  }
  if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
   UIMAFramework.getLogger(CLASS_NAME).logrb(
       Level.INFO,
       CLASS_NAME.getName(),
       "initializeComponentCasPool",
       UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
       "UIMAEE_cas_pool_config_INFO",
       new Object[] { getComponentName(), getUimaContextAdmin().getQualifiedContextName(),
         aComponentCasPoolSize, anInitialCasHeapSize / 4, disableJCasCache });
  }
 } 
}

代码示例来源:origin: apache/uima-uimaj

/**
 * returns a valid ResourceManager with the information from the PackageBrowser object.
 * 
 * @param pkgBrowser
 *          packageBrowser object of an installed PEAR package
 * 
 * @return a ResourceManager object with the information from the PackageBrowser object.
 * 
 * @throws IOException passthru
 */
private static ResourceManager getResourceManager(PackageBrowser pkgBrowser) throws IOException {
 ResourceManager resourceMgr = UIMAFramework.newDefaultResourceManager();
 // set component data path
 if (pkgBrowser.getComponentDataPath() != null) {
  resourceMgr.setDataPath(pkgBrowser.getComponentDataPath());
 }
 // set component classpath
 if (pkgBrowser.buildComponentClassPath() != null) {
  resourceMgr.setExtensionClassPath(pkgBrowser.buildComponentClassPath(), true);
 }
 return resourceMgr;
}

代码示例来源:origin: CLLKazan/UIMA-Ext

public static File resolveFile(String path, ResourceManager resMgr)
    throws URISyntaxException, MalformedURLException {
  Preconditions.checkArgument(path != null);
  if (resMgr == null) {
    resMgr = UIMAFramework.newDefaultResourceManager();
  }
  URL modelBaseURL = resMgr.resolveRelativePath(path);
  if (modelBaseURL == null)
    throw new IllegalStateException(format(
        "Can't resolve path %s using an UIMA relative path resolver", path));
  return new File(modelBaseURL.toURI());
}

代码示例来源:origin: org.apache.uima/ruta-ep-ide-ui

private Set<String> getTypes(IFolder folder, String filePath) throws InvalidXMLException,
    IOException {
 Set<String> types = new HashSet<String>();
 IFile iFile = getFile(folder, filePath);
 URL url;
 try {
  url = iFile.getLocationURI().toURL();
  ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
  resMgr.setDataPath(folder.getLocation().toPortableString());
  types = getTypes(url, resMgr);
 } catch (MalformedURLException e) {
  e.printStackTrace();
 }
 return types;
}

代码示例来源:origin: apache/uima-uimaj

/**
 * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceURL(java.lang.String,
 *      java.lang.String[])
 */
public URL getResourceURL(String aKey, String[] aParams) throws ResourceAccessException {
 URL result = getResourceManager().getResourceURL(makeQualifiedName(aKey), aParams);
 if (result != null) {
  return result;
 } else {
  // try as an unmanaged resource (deprecated)
  URL unmanagedResourceUrl = null;
  try {
   unmanagedResourceUrl = getResourceManager().resolveRelativePath(aKey);
  } catch (MalformedURLException e) {
   // if key is not a valid path then it cannot be resolved to an unmanged resource
  }
  if (unmanagedResourceUrl != null) {
   UIMAFramework.getLogger().logrb(Level.WARNING, this.getClass().getName(), "getResourceURL",
       LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING", new Object[] { aKey });
   return unmanagedResourceUrl;
  }
  return null;
 }
}

代码示例来源:origin: apache/uima-uimaj

/**
 * Acquires Resource InputStreams using the ResourceManager.
 * 
 * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceAsStream(java.lang.String)
 */
public InputStream getResourceAsStream(String aKey) throws ResourceAccessException {
 InputStream result = getResourceManager().getResourceAsStream(makeQualifiedName(aKey));
 if (result != null) {
  return result;
 } else {
  // try as an unmanaged resource (deprecated)
  URL unmanagedResourceUrl = null;
  try {
   unmanagedResourceUrl = getResourceManager().resolveRelativePath(aKey);
  } catch (MalformedURLException e) {
   // if key is not a valid path then it cannot be resolved to an unmanged resource
  }
  if (unmanagedResourceUrl != null) {
   UIMAFramework.getLogger().logrb(Level.WARNING, this.getClass().getName(),
       "getResourceAsStream", LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING",
       new Object[] { aKey });
   try {
    return unmanagedResourceUrl.openStream();
   } catch (IOException e) {
    throw new ResourceAccessException(e);
   }
  }
  return null;
 }
}

相关文章