当前位置: 首页>>代码示例>>Java>>正文


Java StringDistance类代码示例

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


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

示例1: resolveDistance

import org.apache.lucene.search.spell.StringDistance; //导入依赖的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: fallbackResolve

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
/**
 * Resolves terms that could not be resolved with the lucene approach. This
 * brute-force function is significantly slower, but always works
 *
 * @param needles the URIs that produced errors in lucene
 * @param possibles the set of all possible solutions
 * @param hits populate this multimap with matches
 * @param levy the string distance object to use to measure hits
 * @param minDistance the minimum similarity measure
 */
private void fallbackResolve( Collection<URI> needles, Map<URI, String> possibles,
		MultiMap<URI, Hit> hits, StringDistance levy, float minDistance ) {
	log.debug( "falling back to resolve " + needles.size() + " items" );

	for ( URI needle : needles ) {
		String needlelabel = labels.get( needle );

		for ( Map.Entry<URI, String> en : possibles.entrySet() ) {
			URI match = en.getKey();
			String matchlabel = en.getValue();

			float distance = levy.getDistance( needlelabel, matchlabel );
			if ( distance >= minDistance && !match.equals( needle ) ) {
				hits.add( needle,
						new Hit( match, matchlabel, uriToTypeLkp.get( match ), distance ) );
			}
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:30,代码来源:EngineConsistencyChecker.java

示例3: CheckConsistencyPanel

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
public CheckConsistencyPanel() {
	initComponents();
	conceptList.setCellRenderer( crenderer );
	relationList.setCellRenderer( rrenderer );
	LabeledPairRenderer<StringDistance> arend = new LabeledPairRenderer<>();
	algorithm.setRenderer( arend );

	Map<StringDistance, String> dists = new LinkedHashMap<>();
	dists.put( new LevensteinDistance(), "Levenstein" );
	dists.put( new DoubleMetaphoneDistance(), "Double Metaphone" );
	dists.put( new MetaphoneDistance(), "Metaphone" );
	dists.put( new SoundexDistance(), "Soundex" );
	arend.cache( dists );
	
	for( StringDistance s : dists.keySet() ){
		algorithm.addItem( s );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:CheckConsistencyPanel.java

示例4: getStringDistance

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
@Override
protected StringDistance getStringDistance() {
  if (stringDistance == null) {
    return super.getStringDistance();
  }
  return stringDistance;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:ConjunctionSolrSpellChecker.java

示例5: testAlternateDistance

import org.apache.lucene.search.spell.StringDistance; //导入依赖的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

示例6: testAlternateDistance

import org.apache.lucene.search.spell.StringDistance; //导入依赖的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

示例7: check

import org.apache.lucene.search.spell.StringDistance; //导入依赖的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

示例8: stringDistance

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

示例9: toLucene

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

示例10: EngineConsistencyChecker

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
public EngineConsistencyChecker( IEngine eng, boolean across, StringDistance dist ) {
	this.engine = eng;
	this.across = across;
	this.strdist = dist;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:6,代码来源:EngineConsistencyChecker.java

示例11: getDistanceAlg

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
public StringDistance getDistanceAlg() {
	return algorithm.getItemAt( algorithm.getSelectedIndex() );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:4,代码来源:CheckConsistencyPanel.java

示例12: MemoryAwareSpellChecker

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
private MemoryAwareSpellChecker(Directory spellIndex,
                       StringDistance sd) throws IOException {
    super(spellIndex, sd);
    _spellIndex = spellIndex;
}
 
开发者ID:andreymoser,项目名称:jspellchecker,代码行数:6,代码来源:LuceneSpellCheckerServlet.java

示例13: getStringDistance

import org.apache.lucene.search.spell.StringDistance; //导入依赖的package包/类
/**
 * Get the distance implementation used by this spellchecker, or NULL if not applicable.
 */
protected StringDistance getStringDistance()  {
  throw new UnsupportedOperationException();
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:SolrSpellChecker.java

示例14: getStringDistance

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

示例15: getStringDistance

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


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