當前位置: 首頁>>代碼示例>>Java>>正文


Java HunspellDictionary類代碼示例

本文整理匯總了Java中org.apache.lucene.analysis.hunspell.HunspellDictionary的典型用法代碼示例。如果您正苦於以下問題:Java HunspellDictionary類的具體用法?Java HunspellDictionary怎麽用?Java HunspellDictionary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HunspellDictionary類屬於org.apache.lucene.analysis.hunspell包,在下文中一共展示了HunspellDictionary類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import org.apache.lucene.analysis.hunspell.HunspellDictionary; //導入依賴的package包/類
@Override public Object create(Random random) {
  // TODO: make nastier
  InputStream affixStream = HunspellDictionaryTest.class.getResourceAsStream("test.aff");
  InputStream dictStream = HunspellDictionaryTest.class.getResourceAsStream("test.dic");
  try {
   return new HunspellDictionary(affixStream, dictStream, TEST_VERSION_CURRENT);
  } catch (Exception ex) {
    Rethrow.rethrow(ex);
    return null; // unreachable code
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:12,代碼來源:TestRandomChains.java

示例2: inform

import org.apache.lucene.analysis.hunspell.HunspellDictionary; //導入依賴的package包/類
/**
 * Loads the hunspell dictionary and affix files defined in the configuration
 *  
 * @param loader ResourceLoader used to load the files
 */
@Override
public void inform(ResourceLoader loader) throws IOException {
  assureMatchVersion();
  String dictionaryArg = args.get(PARAM_DICTIONARY);
  if (dictionaryArg == null) {
    throw new IllegalArgumentException("Parameter " + PARAM_DICTIONARY + " is mandatory.");
  }
  String dictionaryFiles[] = args.get(PARAM_DICTIONARY).split(",");
  String affixFile = args.get(PARAM_AFFIX);
  String pic = args.get(PARAM_IGNORE_CASE);
  if(pic != null) {
    if(pic.equalsIgnoreCase(TRUE)) ignoreCase = true;
    else if(pic.equalsIgnoreCase(FALSE)) ignoreCase = false;
    else throw new IllegalArgumentException("Unknown value for " + PARAM_IGNORE_CASE + ": " + pic + ". Must be true or false");
  }

  String strictAffixParsingParam = args.get(PARAM_STRICT_AFFIX_PARSING);
  boolean strictAffixParsing = true;
  if(strictAffixParsingParam != null) {
    if(strictAffixParsingParam.equalsIgnoreCase(FALSE)) strictAffixParsing = false;
    else if(strictAffixParsingParam.equalsIgnoreCase(TRUE)) strictAffixParsing = true;
    else throw new IllegalArgumentException("Unknown value for " + PARAM_STRICT_AFFIX_PARSING + ": " + strictAffixParsingParam + ". Must be true or false");
  }

  InputStream affix = null;
  List<InputStream> dictionaries = new ArrayList<InputStream>();

  try {
    dictionaries = new ArrayList<InputStream>();
    for (String file : dictionaryFiles) {
      dictionaries.add(loader.openResource(file));
    }
    affix = loader.openResource(affixFile);

    this.dictionary = new HunspellDictionary(affix, dictionaries, luceneMatchVersion, ignoreCase, strictAffixParsing);
  } catch (ParseException e) {
    throw new IOException("Unable to load hunspell data! [dictionary=" + args.get("dictionary") + ",affix=" + affixFile + "]", e);
  } finally {
    IOUtils.closeWhileHandlingException(affix);
    IOUtils.closeWhileHandlingException(dictionaries);
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:48,代碼來源:HunspellStemFilterFactory.java


注:本文中的org.apache.lucene.analysis.hunspell.HunspellDictionary類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。