• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ResourceUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils的典型用法代码示例。如果您正苦于以下问题:Java ResourceUtils类的具体用法?Java ResourceUtils怎么用?Java ResourceUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ResourceUtils类属于de.tudarmstadt.ukp.dkpro.core.api.resources包,在下文中一共展示了ResourceUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getStopwords

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
private Set<String> getStopwords()
        throws ResourceInitializationException
{
    Set<String> stopwords = new HashSet<String>();
    try {
        if (chunkTripleStopwordsFile != null && !chunkTripleStopwordsFile.isEmpty()) {
                // each line of the file contains one stopword
                URL stopUrl = ResourceUtils.resolveLocation(chunkTripleStopwordsFile, null);
                InputStream is = stopUrl.openStream();
                stopwords.addAll(IOUtils.readLines(is, "UTF-8"));
        }
    }
    catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
    return stopwords;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:18,代码来源:ChunkTripleMetaCollector.java


示例2: readSentiIntensifiersFile

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
/**
    * Reads input file containing list of intensifiers and builds a map of these intensifiers
 * @param path path of file containing list of intensifiers 
 * @return a map of intensifiers
    * @throws IOException
 */
private Map<String, String[]> readSentiIntensifiersFile(String path) throws IOException {

	URL stopUrl = ResourceUtils.resolveLocation(path);
       InputStream is = stopUrl.openStream();
       List<String> intensifiersLines = new ArrayList<String>();
       intensifiersLines.addAll(IOUtils.readLines(is, "UTF-8"));
       Map<String, String[]> intensifiers = new HashMap<String, String[]>();
       for (String line : intensifiersLines) {
           String[] splitLine = line.toLowerCase().split("\\|\t");
           String word = splitLine[0];
           String[] wordTypeAndScore = splitLine[1].split("\t");
           intensifiers.put(word,wordTypeAndScore);
       }
       return intensifiers;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:22,代码来源:SentimentBaseFeatureExtractor.java


示例3: readSentiWSFile

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
/**
    * Reads input file containing list of sentiment words and builds a map of these sentiment words
 * @param path path of file containing list of sentiment words 
 * @return a map of positive and negative sentiment words
    * @throws IOException
 */
private Map<String, String[]> readSentiWSFile(String path)
       throws IOException
   {
       URL stopUrl = ResourceUtils.resolveLocation(path);
       InputStream is = stopUrl.openStream();
       List<String> sentimentWordLines = new ArrayList<String>();
       sentimentWordLines.addAll(IOUtils.readLines(is, "UTF-8"));
       Map<String, String[]> sentimentWords = new HashMap<String, String[]>();
       for (String line : sentimentWordLines) {
           String[] splitWord = line.toLowerCase().split("\\|");
           String[] splitRest = splitWord[1].split("\t");
           sentimentWords.put(splitWord[0], splitRest);
       }
       return sentimentWords;
   }
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:22,代码来源:SentimentBaseFeatureExtractor.java


示例4: getStopwords

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
/**
 * Gets stopwords from the wordlist stored in resources
 * @return set of stopwords
 * @throws ResourceInitializationException
 */
private Set<String> getStopwords()
        throws ResourceInitializationException
{
    Set<String> stopwords = new HashSet<String>();
    try {
        if (chunkTripleStopwordsFile != null && !chunkTripleStopwordsFile.isEmpty()) {
                // each line of the file contains one stopword
                URL stopUrl = ResourceUtils.resolveLocation(chunkTripleStopwordsFile, null);
                InputStream is = stopUrl.openStream();
                stopwords.addAll(IOUtils.readLines(is, "UTF-8"));
        }
    }
    catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
    return stopwords;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:23,代码来源:T_ChunkTripleFeatureExtractor.java


示例5: getExecutable

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
public File getExecutable() {
  String loc = getExecutablePath() + getExecutableName();
  URL crfExecUrl = getClass().getResource(loc);
  crfExecUrl = ClassLoader.getSystemResource(loc);
  logger.log(Level.FINE, "CrfSuite Location " + loc);
  logger.log(Level.FINE, "CrfSuite Url: " + crfExecUrl);
  File f;
  try {
    if (crfExecUrl != null) {
      f = new File(ResourceUtils.getUrlAsFile(crfExecUrl, true).toURI().getPath());
      if (!f.exists()) {
        f = new File(URLDecoder.decode(f.getAbsolutePath(), ("UTF-8")));
      }
      f.setExecutable(true);
      return f;
    }
    logger.log(Level.WARNING, "The executable could not be found at " + loc);
    return null;
  } catch (IOException e) {
    e.printStackTrace();

    return null;
  }

}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:26,代码来源:CrfSuiteWrapper.java


示例6: initialize

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
    throws ResourceInitializationException
{
	super.initialize(context);

    // read corpus into list (each line one item)
    // further processing will be done in the dedicated TaskA/B readers
	try {
        URL url = ResourceUtils.resolveLocation(corpusFile, null);
        InputStream is = url.openStream();
        rawTweets = IOUtils.readLines(is, "UTF-8");
	}
	catch(IOException e) {
        throw new ResourceInitializationException(new Throwable("Could not read corpus: " + corpusFile));
	}
}
 
开发者ID:zesch,项目名称:semeval,代码行数:18,代码来源:AbstractSemevalTwitterCorpusReader.java


示例7: initModelProvider

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
private void initModelProvider()
    throws ResourceInitializationException
{
    modelProvider = new ModelProviderBase<File>()
    {
        {
            setContextObject(FlexTagUima.this);
            
            setDefault(ARTIFACT_ID, "${groupId}.flextag-model-${language}-${variant}");
            setDefault(LOCATION,
                    "classpath:/${package}/lib/tagger-${language}-${variant}.properties");
            
            setOverride(GROUP_ID, groupid);
            setOverride(LOCATION, modelLocation);
            setOverride(LANGUAGE, language);
            setOverride(VARIANT, variant);
        }

        @Override
        protected File produceResource(URL aUrl)
            throws IOException
        {
            File folder = ResourceUtils.getClasspathAsFolder(aUrl.toString(), true);
            return folder;
        }
    };
    try {
        modelProvider.configure();
    }
    catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:34,代码来源:FlexTagUima.java


示例8: initialize

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);
    this.tree = new DictionaryTree();
    this.tokenizer = loadTokenizer();
    this.textNormalizer = new TextNormalizer(this.caseSensitive, this.accentSensitive);
    this.featureIndexes = parseFeatureMapping();
    InputStream is = null;
    try {
        URL phraseFileUrl = ResourceUtils.resolveLocation(this.dictionaryFile, context);
        is = phraseFileUrl.openStream();
        char separator = csvSeparator.charAt(0);
        CSVReader csvReader = new CSVReader(new InputStreamReader(is, this.dictionaryEncoding), separator);
        int count = 0;
        for (String[] record : csvReader) {
            String entry = selectEntry(record);
            EntryMetadata metadata = createMetadata(record);
            List<String> tokens = this.tokenizer.tokenize(entry)
                    .stream()
                    .map(textNormalizer::normalize)
                    .collect(Collectors.toList());
            this.tree.addEntry(tokens, metadata);
            count++;
        }
        getLogger().info(String.format("Loaded dictionary from '%s' with %d entries", phraseFileUrl, count));
    } catch (Exception e) {
        throw new ResourceInitializationException(e);
    } finally {
        IOUtils.closeQuietly(is);
    }
}
 
开发者ID:tokenmill,项目名称:dictionary-annotator,代码行数:32,代码来源:DictionaryAnnotator.java


示例9: readSentiChangeFile

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
/**
   * Reads input file containing list of polarity changers and builds a map of these polarity changers
* @param path path of file containing list of polarity changers
* @return a map of polarity changers
   * @throws IOException
*/
  private List<String> readSentiChangeFile(String path)
          throws IOException
      {
          URL stopUrl = ResourceUtils.resolveLocation(path);
          InputStream is = stopUrl.openStream();
          List<String> polarityChangeLines = new ArrayList<String>();
          polarityChangeLines.addAll(IOUtils.readLines(is, "UTF-8"));
          return polarityChangeLines;
      }
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:16,代码来源:SentimentBaseFeatureExtractor.java


示例10: readSentiWSFile

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
private Map<String, String[]> readSentiWSFile(String path)
    throws IOException
{
    URL stopUrl = ResourceUtils.resolveLocation(path);
    InputStream is = stopUrl.openStream();
    List<String> sentimentWordLines = new ArrayList<String>();
    sentimentWordLines.addAll(IOUtils.readLines(is, "UTF-8"));
    Map<String, String[]> sentimentWords = new HashMap<String, String[]>();
    for (String line : sentimentWordLines) {
        String[] splitedWord = line.split("\\|");
        String[] splitedRest = splitedWord[1].split("\t");
        sentimentWords.put(splitedWord[0], splitedRest);
    }
    return sentimentWords;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:16,代码来源:SentimentBaseFeatureExtractor.java


示例11: readSentiChangeFile

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
private List<String> readSentiChangeFile(String path)
    throws IOException
{
    URL stopUrl = ResourceUtils.resolveLocation(path);
    InputStream is = stopUrl.openStream();
    List<String> polarityChangeLines = new ArrayList<String>();
    polarityChangeLines.addAll(IOUtils.readLines(is, "UTF-8"));
    return polarityChangeLines;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:10,代码来源:SentimentBaseFeatureExtractor.java


示例12: initialize

import de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils; //导入依赖的package包/类
@Override
public void initialize(UimaContext aContext)
        throws ResourceInitializationException
{
    super.initialize(aContext);

    if (annotationType == null) {
        annotationType = NGram.class.getName();
    }

    phrases = new PhraseTree();

    InputStream is = null;
    try {
        URL phraseFileUrl = ResourceUtils.resolveLocation(phraseFile, aContext);
        is = phraseFileUrl.openStream();
        for (String inputLine : IOUtils.readLines(is, modelEncoding)) {
            String[] phraseSplit;
            if (extendedMatch.toLowerCase().equals("true")) phraseSplit = inputLine.toLowerCase().split(" ");
            else phraseSplit = inputLine.split(" ");
            phrases.addPhrase(phraseSplit);
        }
    }
    catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
    finally {
        IOUtils.closeQuietly(is);
    }
}
 
开发者ID:uhh-lt,项目名称:lefex,代码行数:31,代码来源:DictionaryAnnotator.java



注:本文中的de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultConverterLookup类代码示例发布时间:2022-05-22
下一篇:
Java MigrationType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap