Analysis: When specifying empty array for stopwords, use an empty list for stopwords, closes #230.

This commit is contained in:
kimchy 2010-06-18 00:34:18 +03:00
parent 8e4c139c8b
commit 22926f0026
14 changed files with 34 additions and 26 deletions

View File

@ -221,6 +221,14 @@ public interface Settings {
*/
String[] getAsArray(String settingPrefix, String[] defaultArray) throws SettingsException;
/**
* The values associated with a setting prefix as an array. The settings array is in the format of:
* <tt>settingPrefix.[index]</tt>.
*
* @param settingPrefix The setting prefix to load the array by
* @return The setting array values
* @throws SettingsException
*/
String[] getAsArray(String settingPrefix) throws SettingsException;
/**

View File

@ -42,8 +42,8 @@ public class ArabicAnalyzerProvider extends AbstractIndexAnalyzerProvider<Arabic
@Inject public ArabicAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = ArabicAnalyzer.getDefaultStopSet();

View File

@ -44,8 +44,8 @@ public class BrazilianAnalyzerProvider extends AbstractIndexAnalyzerProvider<Bra
@Inject public BrazilianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = BrazilianAnalyzer.getDefaultStopSet();

View File

@ -42,8 +42,8 @@ public class CjkAnalyzerProvider extends AbstractIndexAnalyzerProvider<CJKAnalyz
@Inject public CjkAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = CJKAnalyzer.getDefaultStopSet();

View File

@ -42,8 +42,8 @@ public class CzechAnalyzerProvider extends AbstractIndexAnalyzerProvider<CzechAn
@Inject public CzechAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = CzechAnalyzer.getDefaultStopSet();

View File

@ -44,8 +44,8 @@ public class DutchAnalyzerProvider extends AbstractIndexAnalyzerProvider<DutchAn
@Inject public DutchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = DutchAnalyzer.getDefaultStopSet();

View File

@ -44,8 +44,8 @@ public class FrenchAnalyzerProvider extends AbstractIndexAnalyzerProvider<French
@Inject public FrenchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = FrenchAnalyzer.getDefaultStopSet();

View File

@ -44,8 +44,8 @@ public class GermanAnalyzerProvider extends AbstractIndexAnalyzerProvider<German
@Inject public GermanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = GermanAnalyzer.getDefaultStopSet();

View File

@ -42,8 +42,8 @@ public class GreekAnalyzerProvider extends AbstractIndexAnalyzerProvider<GreekAn
@Inject public GreekAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = GreekAnalyzer.getDefaultStopSet();

View File

@ -42,8 +42,8 @@ public class PersianAnalyzerProvider extends AbstractIndexAnalyzerProvider<Persi
@Inject public PersianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = PersianAnalyzer.getDefaultStopSet();

View File

@ -38,8 +38,8 @@ public class RussianAnalyzerProvider extends AbstractIndexAnalyzerProvider<Russi
@Inject public RussianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
analyzer = new RussianAnalyzer(Lucene.ANALYZER_VERSION, ImmutableSet.copyOf(Iterators.forArray(stopWords)));
} else {
analyzer = new RussianAnalyzer(Lucene.ANALYZER_VERSION);

View File

@ -45,8 +45,8 @@ public class StandardAnalyzerProvider extends AbstractIndexAnalyzerProvider<Stan
@Inject public StandardAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = ImmutableSet.copyOf((Iterable<? extends String>) StopAnalyzer.ENGLISH_STOP_WORDS_SET);

View File

@ -42,8 +42,8 @@ public class StopAnalyzerProvider extends AbstractIndexAnalyzerProvider<StopAnal
@Inject public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = ImmutableSet.copyOf((Iterable<? extends String>) StopAnalyzer.ENGLISH_STOP_WORDS_SET);

View File

@ -45,8 +45,8 @@ public class StopTokenFilterFactory extends AbstractTokenFilterFactory {
@Inject public StopTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings, name);
String[] stopWords = settings.getAsArray("stopwords");
if (stopWords.length > 0) {
String[] stopWords = settings.getAsArray("stopwords", null);
if (stopWords != null) {
this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
} else {
this.stopWords = ImmutableSet.copyOf((Iterable<? extends String>) StopAnalyzer.ENGLISH_STOP_WORDS_SET);