mirror of https://github.com/apache/lucene.git
SOLR-616 -- FileBasedSpellChecker does not apply accuracy configuration.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@678306 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ebb0e0dda5
commit
91170a2535
|
@ -482,6 +482,10 @@ Bug Fixes
|
|||
|
||||
41. SOLR-501: Fix admin/analysis.jsp UTF-8 input for some other servlet
|
||||
containers such as Tomcat. (Hiroaki Kawai, Lars Kotthoff via yonik)
|
||||
|
||||
42. SOLR-616: SpellChecker accuracy configuration is not applied for FileBasedSpellChecker.
|
||||
Apply it for FileBasedSpellChecker and IndexBasedSpellChecker both.
|
||||
(shalin)
|
||||
|
||||
Other Changes
|
||||
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
|
||||
|
|
|
@ -47,11 +47,13 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
|
|||
|
||||
public static final int DEFAULT_SUGGESTION_COUNT = 5;
|
||||
protected String indexDir;
|
||||
protected float accuracy = 0.5f;
|
||||
public static final String FIELD = "field";
|
||||
|
||||
public String init(NamedList config, SolrResourceLoader loader) {
|
||||
super.init(config, loader);
|
||||
indexDir = (String) config.get(INDEX_DIR);
|
||||
String accuracy = (String) config.get(ACCURACY);
|
||||
//If indexDir is relative then create index inside core.getDataDir()
|
||||
if (indexDir != null) {
|
||||
if (!new File(indexDir).isAbsolute()) {
|
||||
|
@ -74,6 +76,15 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (accuracy != null) {
|
||||
try {
|
||||
this.accuracy = Float.parseFloat(accuracy);
|
||||
spellChecker.setAccuracy(this.accuracy);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException(
|
||||
"Unparseable accuracy given for dictionary: " + name, e);
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,24 +48,12 @@ public class IndexBasedSpellChecker extends AbstractLuceneSpellChecker {
|
|||
public static final String THRESHOLD_TOKEN_FREQUENCY = "thresholdTokenFrequency";
|
||||
|
||||
protected float threshold;
|
||||
protected float accuracy = 0.5f;
|
||||
protected IndexReader reader;
|
||||
|
||||
public String init(NamedList config, SolrResourceLoader loader) {
|
||||
super.init(config, loader);
|
||||
String accuracy = (String) config.get(ACCURACY);
|
||||
threshold = config.get(THRESHOLD_TOKEN_FREQUENCY) == null ? 0.0f
|
||||
: (Float) config.get(THRESHOLD_TOKEN_FREQUENCY);
|
||||
if (accuracy != null) {
|
||||
try {
|
||||
this.accuracy = Float.parseFloat(accuracy);
|
||||
spellChecker.setAccuracy(this.accuracy);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException(
|
||||
"Unparseable accuracy given for dictionary: " + name, e);
|
||||
}
|
||||
}
|
||||
initSourceReader();
|
||||
return name;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue