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

Java JaroWinklerDistance类代码示例

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

本文整理汇总了Java中org.apache.lucene.search.spell.JaroWinklerDistance的典型用法代码示例。如果您正苦于以下问题:Java JaroWinklerDistance类的具体用法?Java JaroWinklerDistance怎么用?Java JaroWinklerDistance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JaroWinklerDistance类属于org.apache.lucene.search.spell包,在下文中一共展示了JaroWinklerDistance类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveDistance

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
private static StringDistance resolveDistance(String distanceVal) {
    distanceVal = distanceVal.toLowerCase(Locale.US);
    if ("internal".equals(distanceVal)) {
        return DirectSpellChecker.INTERNAL_LEVENSHTEIN;
    } else if ("damerau_levenshtein".equals(distanceVal) || "damerauLevenshtein".equals(distanceVal)) {
        return new LuceneLevenshteinDistance();
    } else if ("levenstein".equals(distanceVal)) {
        return new LevensteinDistance();
        // TODO Jaro and Winkler are 2 people - so apply same naming logic
        // as damerau_levenshtein
    } else if ("jarowinkler".equals(distanceVal)) {
        return new JaroWinklerDistance();
    } else if ("ngram".equals(distanceVal)) {
        return new NGramDistance();
    } else {
        throw new IllegalArgumentException("Illegal distance option " + distanceVal);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:DirectCandidateGeneratorBuilder.java


示例2: reset

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
@PostConstruct
public void reset() {
    String indexDir = appConfig.getAllSpellCheckerDir();
    try {
        Directory spellcheckDir = FSDirectory.open(new File(indexDir));
        if (!IndexReader.indexExists(spellcheckDir)) {
            logger.info("Please reset index firstly!");
            return;
        }
        SpellChecker newSpellChecker = new SpellChecker(spellcheckDir);
        newSpellChecker.setStringDistance(new JaroWinklerDistance());
        newSpellChecker.setAccuracy(0.7f);
        if (spellChecker == null) {
            spellChecker = newSpellChecker;
        } else {
            final Closeable preSpellChecker = spellChecker;
            spellChecker = newSpellChecker;
            IOUtils.closeQuietly(preSpellChecker);
        }
    } catch (Exception e) {
        logger.error("Exception", e);
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:24,代码来源:SpellCheckerServiceImpl.java


示例3: spellChecker

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
/**
 * 拼写错误的提示修正
 * 
 * @param keyword
 * @return
 */
@Override
public List<String> spellChecker(Integer typeId, String sword) {
    try {
        List<String> strList = new ArrayList<String>();
        SpellChecker sp = new SpellChecker(FSDirectory.getDirectory(typeId == appConfig.getGameTypeId() ? appConfig
                .getGameSpellIndexDir() : appConfig.getSoftSpellIndexDir()), new JaroWinklerDistance());
        String[] suggestions = sp.suggestSimilar(sword, appConfig.getSuggestNum());
        for (int i = 0; i < suggestions.length; i++)
            strList.add(suggestions[i]);
        return strList;
    } catch (IOException e) {
        logger.error("Exception", e);

        return null;
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:23,代码来源:SearchServiceImpl.java


示例4: testAlternateDistance

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
@Test
public void testAlternateDistance() throws Exception {
  TestSpellChecker checker = new TestSpellChecker();
  NamedList spellchecker = new NamedList();
  spellchecker.add("classname", IndexBasedSpellChecker.class.getName());

  File indexDir = createTempDir();
  spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
  spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
  spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
  spellchecker.add(AbstractLuceneSpellChecker.STRING_DISTANCE, JaroWinklerDistance.class.getName());
  SolrCore core = h.getCore();
  String dictName = checker.init(spellchecker, core);
  assertTrue(dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
          dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
  RefCounted<SolrIndexSearcher> holder = core.getSearcher();
  SolrIndexSearcher searcher = holder.get();
  try {
  checker.build(core, searcher);
  SpellChecker sc = checker.getSpellChecker();
  assertTrue("sc is null and it shouldn't be", sc != null);
  StringDistance sd = sc.getStringDistance();
  assertTrue("sd is null and it shouldn't be", sd != null);
  assertTrue("sd is not an instance of " + JaroWinklerDistance.class.getName(), sd instanceof JaroWinklerDistance);
  } finally {
    holder.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:IndexBasedSpellCheckerTest.java


示例5: testAlternateDistance

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
@Test
public void testAlternateDistance() throws Exception {
  TestSpellChecker checker = new TestSpellChecker();
  NamedList spellchecker = new NamedList();
  spellchecker.add("classname", IndexBasedSpellChecker.class.getName());

  File indexDir = new File(TEMP_DIR, "spellingIdx" + new Date().getTime());
  indexDir.mkdirs();
  spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
  spellchecker.add(AbstractLuceneSpellChecker.FIELD, "title");
  spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
  spellchecker.add(AbstractLuceneSpellChecker.STRING_DISTANCE, JaroWinklerDistance.class.getName());
  SolrCore core = h.getCore();
  String dictName = checker.init(spellchecker, core);
  assertTrue(dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
          dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
  RefCounted<SolrIndexSearcher> holder = core.getSearcher();
  SolrIndexSearcher searcher = holder.get();
  try {
  checker.build(core, searcher);
  SpellChecker sc = checker.getSpellChecker();
  assertTrue("sc is null and it shouldn't be", sc != null);
  StringDistance sd = sc.getStringDistance();
  assertTrue("sd is null and it shouldn't be", sd != null);
  assertTrue("sd is not an instance of " + JaroWinklerDistance.class.getName(), sd instanceof JaroWinklerDistance);
  } finally {
    holder.decref();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:30,代码来源:IndexBasedSpellCheckerTest.java


示例6: check

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
private static void check() {
    try {
        Class.forName(JaroWinklerDistance.class.getName());
        Class.forName(LevensteinDistance.class.getName());
        Class.forName(StringDistance.class.getName());
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:brightgenerous,项目名称:brigen-base,代码行数:10,代码来源:LuceneDelegaterImpl.java


示例7: toLucene

import org.apache.lucene.search.spell.JaroWinklerDistance; //导入依赖的package包/类
@Override
public StringDistance toLucene() {
    return new JaroWinklerDistance();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TermSuggestionBuilder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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