org.apache.uima.resource.ResourceManager.resolveRelativePath()方法的使用及代码示例

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

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

ResourceManager.resolveRelativePath介绍

[英]Attempts to resolve a relative path to an absolute path using the same mechanism that the ResourceManager uses to find resources -- a lookup in the datapath followed by a lookup in the classpath.
[中]尝试使用ResourceManager用于查找资源的相同机制将相对路径解析为绝对路径——在datapath中查找,然后在classpath中查找。

代码示例

代码示例来源: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: CLLKazan/UIMA-Ext

private URL getSerializedDictionaryURL() {
    URL serDictUrl;
    try {
      serDictUrl = UIMAFramework.newDefaultResourceManager()
          .resolveRelativePath(DEFAULT_SERIALIZED_DICT_RELATIVE_PATH);
    } catch (MalformedURLException e) {
      // should never happen as the URL is hard-coded here
      throw new IllegalStateException(e);
    }
    if (serDictUrl == null) {
      throw new IllegalStateException(String.format("Can't find %s in UIMA datapath",
          DEFAULT_SERIALIZED_DICT_RELATIVE_PATH));
    }
    return serDictUrl;
  }
}

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

rm.setDataPath(dataPathJoiner.join(dpElements));
classifierJarURL = rm.resolveRelativePath(classifierJarPath);
if (classifierJarURL == null) {
  throw new IllegalStateException(String.format(

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

/**
 * Locates Resource URL's using the ResourceManager.
 * 
 * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceURL(java.lang.String)
 */
public URL getResourceURL(String aKey) throws ResourceAccessException {
 URL result = getResourceManager().getResourceURL(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(), "getResourceURL",
       LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING", new Object[] { aKey });
   return unmanagedResourceUrl;
  }
  return null;
 }
}

代码示例来源: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;
 }
}

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

/**
 * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceAsStream(java.lang.String,
 *      java.lang.String[])
 */
public InputStream getResourceAsStream(String aKey, String[] aParams)
    throws ResourceAccessException {
 InputStream result = getResourceManager().getResourceAsStream(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(),
       "getResourceAsStream", LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING",
       new Object[] { aKey });
   try {
    return unmanagedResourceUrl.openStream();
   } catch (IOException e) {
    throw new ResourceAccessException(e);
   }
  }
  return null;
 }
}

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

URL url;
try {
 url = aResourceManager.resolveRelativePath(filename);
 UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
     "findAbsoluteUrl", LOG_RESOURCE_BUNDLE, "UIMA_import_by__CONFIG",

相关文章