You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by sh...@apache.org on 2008/07/20 21:06:02 UTC
svn commit: r678306 - in /lucene/solr/trunk: CHANGES.txt
src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
Author: shalin
Date: Sun Jul 20 12:06:02 2008
New Revision: 678306
URL: http://svn.apache.org/viewvc?rev=678306&view=rev
Log:
SOLR-616 -- FileBasedSpellChecker does not apply accuracy configuration.
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=678306&r1=678305&r2=678306&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sun Jul 20 12:06:02 2008
@@ -482,6 +482,10 @@
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
Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java?rev=678306&r1=678305&r2=678306&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java Sun Jul 20 12:06:02 2008
@@ -47,11 +47,13 @@
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 @@
} 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;
}
Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java?rev=678306&r1=678305&r2=678306&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java Sun Jul 20 12:06:02 2008
@@ -48,24 +48,12 @@
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;
}