Merged revision(s) 1364862-1365482 from lucene/dev/trunk:
........
LUCENE-4044: add spi support to Tokenizer/CharFilter/TokenFilter factory
........
LUCENE-2510: apply movefactories.sh
........
LUCENE-4044: few steps closer to fixing compile
........
LUCENE-4044: add the rest for common/
........
LUCENE-4044: add services for kuromoji
........
LUCENE-4044: more factories and tests
........
LUCENE-4044: fix more compil
........
LUCENE-4044: fix some more tests
........
LUCENE-4197 rename CachedDistanceValueSource
........
LUCENE-4044: get analysis/common tests passing
........
improve zk tests vs blackhole
........
LUCENE-4044: get all lucene tests passing
........
LUCENE-4044: register phonetic factories
........
LUCENE-4245: Make IndexWriter#close() and MergeScheduler#close() non-interruptible
........
LUCENE-4044: port over icu module
........
LUCENE-4044: port over morfologik
........
LUCENE-4044: port over smartcn
........
LUCENE-4245: Addon: handle failures during flushing by enforcing CMS to stop
........
LUCENE-4044: port over stempel/uima
........
LUCENE-4044: port over synfilter
........
LUCENE-4245: better record interruption
........
fix reuse bug
........
simplify + improve test infra
........
LUCENE-4245: use IOUtils to close everything in finally block
........
LUCENE-4044: get solr tests working
........
LUCENE-4044: dont use instances just class names
........
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2510@1365483 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpath
index 0186551..05b1217 100644
--- a/dev-tools/eclipse/dot.classpath
+++ b/dev-tools/eclipse/dot.classpath
@@ -17,25 +17,28 @@
<classpathentry kind="src" path="lucene/test-framework/src/java"/>
<classpathentry kind="src" output="bin.tests-framework" path="lucene/test-framework/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/common/src/java"/>
- <classpathentry kind="src" path="lucene/analysis/common/src/resources"/>
+ <classpathentry kind="src" output="bin.analysis-common" path="lucene/analysis/common/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/common/src/test"/>
<classpathentry kind="src" path="lucene/analysis/icu/src/java"/>
- <classpathentry kind="src" path="lucene/analysis/icu/src/resources"/>
+ <classpathentry kind="src" output="bin.analysis-icu" path="lucene/analysis/icu/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/icu/src/test"/>
<classpathentry kind="src" path="lucene/analysis/kuromoji/src/java"/>
- <classpathentry kind="src" path="lucene/analysis/kuromoji/src/resources"/>
+ <classpathentry kind="src" output="bin.analysis-kuromoji" path="lucene/analysis/kuromoji/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/kuromoji/src/test"/>
<classpathentry kind="src" path="lucene/analysis/phonetic/src/java"/>
+ <classpathentry kind="src" output="bin.analysis-phonetic" path="lucene/analysis/phonetic/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/phonetic/src/test"/>
<classpathentry kind="src" path="lucene/analysis/smartcn/src/java"/>
- <classpathentry kind="src" path="lucene/analysis/smartcn/src/resources"/>
+ <classpathentry kind="src" output="bin.analysis-smartcn" path="lucene/analysis/smartcn/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/smartcn/src/test"/>
<classpathentry kind="src" path="lucene/analysis/stempel/src/java"/>
- <classpathentry kind="src" path="lucene/analysis/stempel/src/resources"/>
+ <classpathentry kind="src" output="bin.analysis-stempel" path="lucene/analysis/stempel/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/stempel/src/test"/>
<classpathentry kind="src" path="lucene/analysis/morfologik/src/java"/>
+ <classpathentry kind="src" output="bin.analysis-morfologik" path="lucene/analysis/morfologik/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/morfologik/src/test"/>
<classpathentry kind="src" path="lucene/analysis/uima/src/java"/>
+ <classpathentry kind="src" output="bin.analysis-uima" path="lucene/analysis/uima/src/resources"/>
<classpathentry kind="src" path="lucene/analysis/uima/src/test"/>
<classpathentry kind="src" path="lucene/benchmark/src/java"/>
<classpathentry kind="src" path="lucene/benchmark/src/test"/>
diff --git a/solr/core/src/java/org/apache/solr/analysis/ArabicNormalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/ArabicNormalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicNormalizationFilterFactory.java
index 97fc662..780d70f 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ArabicNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicNormalizationFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ar;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
diff --git a/solr/core/src/java/org/apache/solr/analysis/ArabicStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/ArabicStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicStemFilterFactory.java
index 0baa6b5..94dda71 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ArabicStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicStemFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ar;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
diff --git a/solr/core/src/java/org/apache/solr/analysis/BulgarianStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/bg/BulgarianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/BulgarianStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/bg/BulgarianStemFilterFactory.java
index 5c91995..fdee644 100644
--- a/solr/core/src/java/org/apache/solr/analysis/BulgarianStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/bg/BulgarianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.bg;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/BrazilianStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/BrazilianStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemFilterFactory.java
index 8928d64..fde9ebe 100644
--- a/solr/core/src/java/org/apache/solr/analysis/BrazilianStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.br;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.br.BrazilianStemFilter;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/HTMLStripCharFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/HTMLStripCharFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/HTMLStripCharFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/HTMLStripCharFilterFactory.java
index 6e91a95..82381b2 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HTMLStripCharFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/HTMLStripCharFilterFactory.java
@@ -1,5 +1,4 @@
-package org.apache.solr.analysis;
-
+package org.apache.lucene.analysis.charfilter;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/MappingCharFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilterFactory.java
similarity index 87%
rename from solr/core/src/java/org/apache/solr/analysis/MappingCharFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilterFactory.java
index a518e4a..27a29de 100644
--- a/solr/core/src/java/org/apache/solr/analysis/MappingCharFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/charfilter/MappingCharFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.charfilter;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.File;
import java.io.IOException;
import java.io.Reader;
@@ -25,11 +25,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.lucene.analysis.CharFilter;
import org.apache.lucene.analysis.charfilter.MappingCharFilter;
import org.apache.lucene.analysis.charfilter.NormalizeCharMap;
import org.apache.lucene.analysis.util.*;
-import org.apache.solr.common.util.StrUtils;
/**
* Factory for {@link MappingCharFilter}.
@@ -62,7 +60,7 @@
wlist = loader.getLines( mapping );
}
else{
- List<String> files = StrUtils.splitFileNames( mapping );
+ List<String> files = splitFileNames( mapping );
wlist = new ArrayList<String>();
for( String file : files ){
List<String> lines = loader.getLines( file.trim() );
@@ -76,11 +74,18 @@
final NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
parseRules( wlist, builder );
normMap = builder.build();
+ if (normMap.map == null) {
+ // if the inner FST is null, it means it accepts nothing (e.g. the file is empty)
+ // so just set the whole map to null
+ normMap = null;
+ }
}
}
- public CharFilter create(Reader input) {
- return new MappingCharFilter(normMap,input);
+ public Reader create(Reader input) {
+ // if the map is null, it means there's actually no mappings... just return the original stream
+ // as there is nothing to do here.
+ return normMap == null ? input : new MappingCharFilter(normMap,input);
}
// "source" => "target"
diff --git a/solr/core/src/java/org/apache/solr/analysis/CJKBigramFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKBigramFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/CJKBigramFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKBigramFilterFactory.java
index bea0bff..ca76956 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CJKBigramFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKBigramFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cjk;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/CJKWidthFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKWidthFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/CJKWidthFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKWidthFilterFactory.java
index 3213b3c..f7a9976 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CJKWidthFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKWidthFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cjk;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsFilterFactory.java
index f32df81..2c2c813 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CommonGramsFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.commongrams;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import java.io.IOException;
diff --git a/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsQueryFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsQueryFilterFactory.java
index 38e407f..23f00cf 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CommonGramsQueryFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/commongrams/CommonGramsQueryFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.commongrams;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import java.io.IOException;
import java.util.Map;
@@ -23,6 +24,7 @@
import org.apache.lucene.analysis.commongrams.CommonGramsFilter;
import org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter;
import org.apache.lucene.analysis.core.StopAnalyzer;
+import org.apache.lucene.analysis.core.StopFilterFactory;
import org.apache.lucene.analysis.util.*;
/**
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilter.java
index e26a03e..e7d697c 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilter.java
@@ -57,6 +57,9 @@
*/
public DictionaryCompoundWordTokenFilter(Version matchVersion, TokenStream input, CharArraySet dictionary) {
super(matchVersion, input, dictionary);
+ if (dictionary == null) {
+ throw new IllegalArgumentException("dictionary cannot be null");
+ }
}
/**
@@ -83,6 +86,9 @@
public DictionaryCompoundWordTokenFilter(Version matchVersion, TokenStream input, CharArraySet dictionary,
int minWordSize, int minSubwordSize, int maxSubwordSize, boolean onlyLongestMatch) {
super(matchVersion, input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
+ if (dictionary == null) {
+ throw new IllegalArgumentException("dictionary cannot be null");
+ }
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/analysis/DictionaryCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java
similarity index 88%
rename from solr/core/src/java/org/apache/solr/analysis/DictionaryCompoundWordTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java
index 4664dc3..8f69d01 100644
--- a/solr/core/src/java/org/apache/solr/analysis/DictionaryCompoundWordTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/DictionaryCompoundWordTokenFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.compound;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-import org.apache.lucene.analysis.compound.*;
import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.TokenStream;
@@ -65,8 +63,9 @@
throw new InitializationException("IOException thrown while loading dictionary", e);
}
}
- public DictionaryCompoundWordTokenFilter create(TokenStream input) {
- return new DictionaryCompoundWordTokenFilter(luceneMatchVersion,input,dictionary,minWordSize,minSubwordSize,maxSubwordSize,onlyLongestMatch);
+ public TokenStream create(TokenStream input) {
+ // if the dictionary is null, it means it was empty
+ return dictionary == null ? input : new DictionaryCompoundWordTokenFilter(luceneMatchVersion,input,dictionary,minWordSize,minSubwordSize,maxSubwordSize,onlyLongestMatch);
}
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/HyphenationCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/HyphenationCompoundWordTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java
index d4a0da3..d05a19b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HyphenationCompoundWordTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/HyphenationCompoundWordTokenFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.compound;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,14 +17,12 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
-import org.apache.commons.io.IOUtils;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.compound.CompoundWordTokenFilterBase;
import org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilter;
import org.apache.lucene.analysis.compound.hyphenation.HyphenationTree;
import org.apache.lucene.analysis.util.*;
+import org.apache.lucene.util.IOUtils;
import java.util.Map;
import java.io.InputStream;
@@ -99,7 +99,7 @@
} catch (Exception e) { // TODO: getHyphenationTree really shouldn't throw "Exception"
throw new InitializationException("Exception thrown while loading dictionary and hyphenation file", e);
} finally {
- IOUtils.closeQuietly(stream);
+ IOUtils.closeWhileHandlingException(stream);
}
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/KeywordTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/KeywordTokenizerFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/KeywordTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/KeywordTokenizerFactory.java
index 678dda5..1a733fc 100644
--- a/solr/core/src/java/org/apache/solr/analysis/KeywordTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/KeywordTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/LetterTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizerFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/LetterTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizerFactory.java
index fcd5691..e304a9e 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LetterTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.core.LetterTokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/LowerCaseFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/LowerCaseFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilterFactory.java
index f49e557..3f7e179 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/LowerCaseTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizerFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/LowerCaseTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizerFactory.java
index 253d1ee..f2d78f1 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LowerCaseTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.core.LowerCaseTokenizer;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
diff --git a/solr/core/src/java/org/apache/solr/analysis/StopFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/StopFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilterFactory.java
index 7e49e39..8118f7c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/StopFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.StopAnalyzer;
diff --git a/solr/core/src/java/org/apache/solr/analysis/TypeTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/TypeTokenFilterFactory.java
similarity index 94%
rename from solr/core/src/java/org/apache/solr/analysis/TypeTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/TypeTokenFilterFactory.java
index 62c7912..c5994fe 100644
--- a/solr/core/src/java/org/apache/solr/analysis/TypeTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/TypeTokenFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.core;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,7 +21,6 @@
import org.apache.lucene.analysis.core.TypeTokenFilter;
import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.common.util.StrUtils;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.lucene.analysis.util.TokenFilterFactory;
@@ -50,7 +49,7 @@
useWhitelist = getBoolean("useWhitelist", false);
if (stopTypesFiles != null) {
try {
- List<String> files = StrUtils.splitFileNames(stopTypesFiles);
+ List<String> files = splitFileNames(stopTypesFiles);
if (files.size() > 0) {
stopTypes = new HashSet<String>();
for (String file : files) {
diff --git a/solr/core/src/java/org/apache/solr/analysis/WhitespaceTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizerFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/WhitespaceTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizerFactory.java
index 47bf213..6844e3c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/WhitespaceTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/CzechStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/CzechStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechStemFilterFactory.java
index fd35534..f177d53 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CzechStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cz;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GermanLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GermanLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemFilterFactory.java
index 60824ce..1bf90f2 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GermanLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GermanMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GermanMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemFilterFactory.java
index 08a89da..c01c33f 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GermanMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GermanNormalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GermanNormalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanNormalizationFilterFactory.java
index 27ac20b..863f578 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GermanNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanNormalizationFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GermanStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GermanStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanStemFilterFactory.java
index 1e7edbd..2ae5770 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GermanStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/de/GermanStemFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.de.GermanStemFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilterFactory.java
index 8889920..94abb20 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GreekLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.el;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/GreekStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GreekStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekStemFilterFactory.java
index d8dae6d..e6b5395 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GreekStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/el/GreekStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.el;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/EnglishMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/EnglishMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishMinimalStemFilterFactory.java
index ed31a86..830b0f9 100644
--- a/solr/core/src/java/org/apache/solr/analysis/EnglishMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/EnglishPossessiveFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishPossessiveFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/EnglishPossessiveFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishPossessiveFilterFactory.java
index 36d153d..e1c7447 100644
--- a/solr/core/src/java/org/apache/solr/analysis/EnglishPossessiveFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishPossessiveFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/KStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/KStemFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/KStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/en/KStemFilterFactory.java
index f8f4057..f8647d3 100644
--- a/solr/core/src/java/org/apache/solr/analysis/KStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/KStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PorterStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/PorterStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PorterStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/en/PorterStemFilterFactory.java
index c6dea10..b04a585 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PorterStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/en/PorterStemFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.en;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.en.PorterStemFilter;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/SpanishLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/SpanishLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemFilterFactory.java
index 61c883b..b0c8542 100644
--- a/solr/core/src/java/org/apache/solr/analysis/SpanishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.es;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PersianCharFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianCharFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PersianCharFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianCharFilterFactory.java
index a0ae871..3eaa355 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PersianCharFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianCharFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fa;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PersianNormalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PersianNormalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianNormalizationFilterFactory.java
index a0ccd43..304aa64 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PersianNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fa/PersianNormalizationFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.fa;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.fa.PersianNormalizationFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/FinnishLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/FinnishLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemFilterFactory.java
index 0e70606..6f9b852 100644
--- a/solr/core/src/java/org/apache/solr/analysis/FinnishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fi;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/ElisionFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/ElisionFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/ElisionFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/ElisionFilterFactory.java
index c522ed4..b9baa55 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ElisionFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/ElisionFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,11 +17,7 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.util.*;
-import org.apache.lucene.analysis.fr.*;
import java.io.IOException;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/FrenchLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/FrenchLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemFilterFactory.java
index 8b50110..37f71a5 100644
--- a/solr/core/src/java/org/apache/solr/analysis/FrenchLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/FrenchMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/FrenchMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemFilterFactory.java
index d3d3bf9..20f51e7 100644
--- a/solr/core/src/java/org/apache/solr/analysis/FrenchMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/IrishLowerCaseFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ga/IrishLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/IrishLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ga/IrishLowerCaseFilterFactory.java
index e5f1d85..87e69c4 100644
--- a/solr/core/src/java/org/apache/solr/analysis/IrishLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ga/IrishLowerCaseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ga;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GalicianMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GalicianMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianMinimalStemFilterFactory.java
index 4f838ab..0a39b07 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GalicianMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.gl;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/GalicianStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/GalicianStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianStemFilterFactory.java
index 824a521..5ad7d3c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/GalicianStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/gl/GalicianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.gl;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/HindiNormalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/HindiNormalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiNormalizationFilterFactory.java
index 6a11b19..1067a05 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HindiNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiNormalizationFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hi;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/HindiStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiStemFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/HindiStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiStemFilterFactory.java
index 2e495e4..db6e352 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HindiStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hi/HindiStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hi;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/HungarianLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/HungarianLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemFilterFactory.java
index 10aea57..35a4719 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HungarianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/HunspellStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilterFactory.java
similarity index 95%
rename from solr/core/src/java/org/apache/solr/analysis/HunspellStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilterFactory.java
index 38f6f59..d62caef 100644
--- a/solr/core/src/java/org/apache/solr/analysis/HunspellStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hunspell;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -68,6 +68,10 @@
*/
public void inform(ResourceLoader loader) {
assureMatchVersion();
+ String dictionaryArg = args.get(PARAM_DICTIONARY);
+ if (dictionaryArg == null) {
+ throw new InitializationException("Parameter " + PARAM_DICTIONARY + " is mandatory.");
+ }
String dictionaryFiles[] = args.get(PARAM_DICTIONARY).split(",");
String affixFile = args.get(PARAM_AFFIX);
String pic = args.get(PARAM_IGNORE_CASE);
diff --git a/solr/core/src/java/org/apache/solr/analysis/IndonesianStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/id/IndonesianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/IndonesianStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/id/IndonesianStemFilterFactory.java
index 92b1d46..966026d 100644
--- a/solr/core/src/java/org/apache/solr/analysis/IndonesianStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/id/IndonesianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.id;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/IndicNormalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/in/IndicNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/IndicNormalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/in/IndicNormalizationFilterFactory.java
index 2709e75..cad729a 100644
--- a/solr/core/src/java/org/apache/solr/analysis/IndicNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/in/IndicNormalizationFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.in;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/ItalianLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/ItalianLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemFilterFactory.java
index 7e79479..1d2c971 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ItalianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.it;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/LatvianStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/lv/LatvianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/LatvianStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/lv/LatvianStemFilterFactory.java
index 3fb4b26..7e3cc1b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LatvianStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/lv/LatvianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.lv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/ASCIIFoldingFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/ASCIIFoldingFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/ASCIIFoldingFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/ASCIIFoldingFilterFactory.java
index da507d9..b575666 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ASCIIFoldingFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/ASCIIFoldingFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java
index e26bac2..4481d7a 100644
--- a/solr/core/src/java/org/apache/solr/analysis/CapitalizationFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/CapitalizationFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.CapitalizationFilter;
import org.apache.lucene.analysis.util.CharArraySet;
diff --git a/solr/core/src/java/org/apache/solr/analysis/HyphenatedWordsFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/HyphenatedWordsFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/HyphenatedWordsFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/HyphenatedWordsFilterFactory.java
index 91faf90..7f24b28 100755
--- a/solr/core/src/java/org/apache/solr/analysis/HyphenatedWordsFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/HyphenatedWordsFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeepWordFilterFactory.java
similarity index 91%
rename from solr/core/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeepWordFilterFactory.java
index 86a5ed1..d2f94d9 100644
--- a/solr/core/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeepWordFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.util.*;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.KeepWordFilter;
@@ -89,7 +89,8 @@
return words;
}
- public KeepWordFilter create(TokenStream input) {
- return new KeepWordFilter(enablePositionIncrements, input, words);
+ public TokenStream create(TokenStream input) {
+ // if the set is null, it means it was empty
+ return words == null ? input : new KeepWordFilter(enablePositionIncrements, input, words);
}
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/KeywordMarkerFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeywordMarkerFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/KeywordMarkerFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeywordMarkerFilterFactory.java
index 3274a43..df98e54 100644
--- a/solr/core/src/java/org/apache/solr/analysis/KeywordMarkerFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/KeywordMarkerFilterFactory.java
@@ -1,10 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.IOException;
-
-import org.apache.lucene.analysis.miscellaneous.KeywordMarkerFilter;
-import org.apache.lucene.analysis.util.*;
-import org.apache.lucene.analysis.TokenStream;
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,6 +17,12 @@
* limitations under the License.
*/
+import java.io.IOException;
+
+import org.apache.lucene.analysis.miscellaneous.KeywordMarkerFilter;
+import org.apache.lucene.analysis.util.*;
+import org.apache.lucene.analysis.TokenStream;
+
/**
* Factory for {@link KeywordMarkerFilter}.
* <pre class="prettyprint" >
diff --git a/solr/core/src/java/org/apache/solr/analysis/LengthFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilterFactory.java
similarity index 82%
rename from solr/core/src/java/org/apache/solr/analysis/LengthFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilterFactory.java
index 756b202..38f3e9b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LengthFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LengthFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,10 +17,9 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.LengthFilter;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import java.util.Map;
@@ -43,8 +44,13 @@
@Override
public void init(Map<String, String> args) {
super.init(args);
- min=Integer.parseInt(args.get(MIN_KEY));
- max=Integer.parseInt(args.get(MAX_KEY));
+ String minKey = args.get(MIN_KEY);
+ String maxKey = args.get(MAX_KEY);
+ if (minKey == null || maxKey == null) {
+ throw new InitializationException("Both " + MIN_KEY + " and " + MAX_KEY + " are mandatory");
+ }
+ min=Integer.parseInt(minKey);
+ max=Integer.parseInt(maxKey);
enablePositionIncrements = getBoolean("enablePositionIncrements",false);
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/LimitTokenCountFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LimitTokenCountFilterFactory.java
similarity index 79%
rename from solr/core/src/java/org/apache/solr/analysis/LimitTokenCountFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LimitTokenCountFilterFactory.java
index 0dfe9f9..8dc85bb 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LimitTokenCountFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/LimitTokenCountFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,12 +17,11 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.LimitTokenCountFilter;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenFilterFactory;
/**
@@ -41,12 +42,16 @@
@Override
public void init(Map<String, String> args) {
super.init( args );
- maxTokenCount = Integer.parseInt( args.get( "maxTokenCount" ) );
+ String maxTokenCountArg = args.get("maxTokenCount");
+ if (maxTokenCountArg == null) {
+ throw new InitializationException("maxTokenCount is mandatory.");
+ }
+ maxTokenCount = Integer.parseInt(args.get(maxTokenCountArg));
}
@Override
public TokenStream create(TokenStream input) {
- return new LimitTokenCountFilter( input, maxTokenCount );
+ return new LimitTokenCountFilter(input, maxTokenCount);
}
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/RemoveDuplicatesTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/RemoveDuplicatesTokenFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/RemoveDuplicatesTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/RemoveDuplicatesTokenFilterFactory.java
index 30d51bb..b5bf8d7 100644
--- a/solr/core/src/java/org/apache/solr/analysis/RemoveDuplicatesTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/RemoveDuplicatesTokenFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilter;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/StemmerOverrideFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java
similarity index 94%
rename from solr/core/src/java/org/apache/solr/analysis/StemmerOverrideFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java
index c9bec3f..2baf35f 100644
--- a/solr/core/src/java/org/apache/solr/analysis/StemmerOverrideFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/StemmerOverrideFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,7 +23,6 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilter;
import org.apache.lucene.analysis.util.*;
-import org.apache.solr.common.util.StrUtils;
/**
* Factory for {@link StemmerOverrideFilter}.
@@ -45,7 +44,7 @@
ignoreCase = getBoolean("ignoreCase", false);
if (dictionaryFiles != null) {
assureMatchVersion();
- List<String> files = StrUtils.splitFileNames(dictionaryFiles);
+ List<String> files = splitFileNames(dictionaryFiles);
try {
if (files.size() > 0) {
dictionary = new CharArrayMap<String>(luceneMatchVersion,
diff --git a/solr/core/src/java/org/apache/solr/analysis/TrimFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/TrimFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/TrimFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/TrimFilterFactory.java
index ef7fbae..2ec9a02 100644
--- a/solr/core/src/java/org/apache/solr/analysis/TrimFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/TrimFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/WordDelimiterFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/WordDelimiterFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java
index 86239eb..40f750b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/WordDelimiterFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/WordDelimiterFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,15 +17,11 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter;
import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator;
import org.apache.lucene.analysis.util.*;
-import org.apache.solr.common.util.StrUtils;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -67,7 +65,7 @@
String types = args.get(TYPES);
if (types != null) {
try {
- List<String> files = StrUtils.splitFileNames( types );
+ List<String> files = splitFileNames( types );
List<String> wlist = new ArrayList<String>();
for( String file : files ){
List<String> lines = loader.getLines( file.trim() );
diff --git a/solr/core/src/java/org/apache/solr/analysis/EdgeNGramFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/EdgeNGramFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramFilterFactory.java
index 5ac1886..78a20ea 100644
--- a/solr/core/src/java/org/apache/solr/analysis/EdgeNGramFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ngram;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/EdgeNGramTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramTokenizerFactory.java
similarity index 63%
rename from solr/core/src/java/org/apache/solr/analysis/EdgeNGramTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramTokenizerFactory.java
index 83f39de..be0be2c 100755
--- a/solr/core/src/java/org/apache/solr/analysis/EdgeNGramTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/EdgeNGramTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ngram;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -34,28 +34,28 @@
*
*/
public class EdgeNGramTokenizerFactory extends TokenizerFactory {
- private int maxGramSize = 0;
-
- private int minGramSize = 0;
-
- private String side;
-
- @Override
- public void init(Map<String, String> args) {
- super.init(args);
- String maxArg = args.get("maxGramSize");
- maxGramSize = (maxArg != null ? Integer.parseInt(maxArg) : EdgeNGramTokenizer.DEFAULT_MAX_GRAM_SIZE);
-
- String minArg = args.get("minGramSize");
- minGramSize = (minArg != null ? Integer.parseInt(minArg) : EdgeNGramTokenizer.DEFAULT_MIN_GRAM_SIZE);
-
- side = args.get("side");
- if (side == null) {
- side = EdgeNGramTokenizer.Side.FRONT.getLabel();
- }
+ private int maxGramSize = 0;
+
+ private int minGramSize = 0;
+
+ private String side;
+
+ @Override
+ public void init(Map<String, String> args) {
+ super.init(args);
+ String maxArg = args.get("maxGramSize");
+ maxGramSize = (maxArg != null ? Integer.parseInt(maxArg) : EdgeNGramTokenizer.DEFAULT_MAX_GRAM_SIZE);
+
+ String minArg = args.get("minGramSize");
+ minGramSize = (minArg != null ? Integer.parseInt(minArg) : EdgeNGramTokenizer.DEFAULT_MIN_GRAM_SIZE);
+
+ side = args.get("side");
+ if (side == null) {
+ side = EdgeNGramTokenizer.Side.FRONT.getLabel();
}
-
- public EdgeNGramTokenizer create(Reader input) {
- return new EdgeNGramTokenizer(input, side, minGramSize, maxGramSize);
- }
+ }
+
+ public EdgeNGramTokenizer create(Reader input) {
+ return new EdgeNGramTokenizer(input, side, minGramSize, maxGramSize);
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/NGramFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/NGramFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramFilterFactory.java
index d21708b..d202fcf 100644
--- a/solr/core/src/java/org/apache/solr/analysis/NGramFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ngram;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/NGramTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramTokenizerFactory.java
similarity index 63%
rename from solr/core/src/java/org/apache/solr/analysis/NGramTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramTokenizerFactory.java
index c2ed40d..0f5c625 100755
--- a/solr/core/src/java/org/apache/solr/analysis/NGramTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ngram/NGramTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ngram;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -35,22 +35,22 @@
*
*/
public class NGramTokenizerFactory extends TokenizerFactory {
- private int maxGramSize = 0;
- private int minGramSize = 0;
+ private int maxGramSize = 0;
+ private int minGramSize = 0;
+
+ /** Initializes the n-gram min and max sizes and the side from which one should start tokenizing. */
+ @Override
+ public void init(Map<String, String> args) {
+ super.init(args);
+ String maxArg = args.get("maxGramSize");
+ maxGramSize = (maxArg != null ? Integer.parseInt(maxArg) : NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
- /** Initializes the n-gram min and max sizes and the side from which one should start tokenizing. */
- @Override
- public void init(Map<String, String> args) {
- super.init(args);
- String maxArg = args.get("maxGramSize");
- maxGramSize = (maxArg != null ? Integer.parseInt(maxArg) : NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
-
- String minArg = args.get("minGramSize");
- minGramSize = (minArg != null ? Integer.parseInt(minArg) : NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
- }
-
- /** Creates the {@link TokenStream} of n-grams from the given {@link Reader}. */
- public NGramTokenizer create(Reader input) {
- return new NGramTokenizer(input, minGramSize, maxGramSize);
- }
+ String minArg = args.get("minGramSize");
+ minGramSize = (minArg != null ? Integer.parseInt(minArg) : NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
+ }
+
+ /** Creates the {@link TokenStream} of n-grams from the given {@link Reader}. */
+ public NGramTokenizer create(Reader input) {
+ return new NGramTokenizer(input, minGramSize, maxGramSize);
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/NorwegianLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/NorwegianLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianLightStemFilterFactory.java
index 840e726..771d37b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/NorwegianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.no;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/NorwegianMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/NorwegianMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianMinimalStemFilterFactory.java
index b8ec071..2ce8a97 100644
--- a/solr/core/src/java/org/apache/solr/analysis/NorwegianMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/no/NorwegianMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.no;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PathHierarchyTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/PathHierarchyTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java
index 6fd7f9e..76e3352 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PathHierarchyTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.path;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -25,7 +26,6 @@
import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenizerFactory;
-
/**
* Factory for {@link PathHierarchyTokenizer}.
* <pre class="prettyprint" >
diff --git a/solr/core/src/java/org/apache/solr/analysis/PatternReplaceCharFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceCharFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PatternReplaceCharFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceCharFilterFactory.java
index ca6fe6a..ce2772b 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PatternReplaceCharFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceCharFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.Reader;
import java.util.Map;
import java.util.regex.Pattern;
diff --git a/solr/core/src/java/org/apache/solr/analysis/PatternReplaceFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PatternReplaceFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceFilterFactory.java
index c71b794..6fc6bc3 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PatternReplaceFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternReplaceFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.pattern.PatternReplaceFilter;
import org.apache.lucene.analysis.util.InitializationException;
diff --git a/solr/core/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternTokenizerFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternTokenizerFactory.java
index a11e9fd..6af60d2 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pattern/PatternTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.IOException;
import java.io.Reader;
import java.util.Map;
@@ -27,7 +27,6 @@
import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenizerFactory;
-
/**
* Factory for {@link PatternTokenizer}.
* This tokenizer uses regex pattern matching to construct distinct tokens
diff --git a/solr/core/src/java/org/apache/solr/analysis/DelimitedPayloadTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilterFactory.java
similarity index 94%
rename from solr/core/src/java/org/apache/solr/analysis/DelimitedPayloadTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilterFactory.java
index 007b83d..6e62647 100644
--- a/solr/core/src/java/org/apache/solr/analysis/DelimitedPayloadTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.payloads;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -29,7 +30,6 @@
import java.util.Map;
-
/**
*
* Factory for {@link DelimitedPayloadTokenFilter}.
@@ -61,6 +61,9 @@
public void inform(ResourceLoader loader) {
String encoderClass = args.get(ENCODER_ATTR);
+ if (encoderClass == null) {
+ throw new InitializationException("Parameter " + ENCODER_ATTR + " is mandatory");
+ }
if (encoderClass.equals("float")){
encoder = new FloatEncoder();
} else if (encoderClass.equals("integer")){
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilter.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilter.java
index f895751..54c356e 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilter.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilter.java
@@ -40,6 +40,9 @@
public NumericPayloadTokenFilter(TokenStream input, float payload, String typeMatch) {
super(input);
+ if (typeMatch == null) {
+ throw new IllegalArgumentException("typeMatch cannot be null");
+ }
//Need to encode the payload
thePayload = new BytesRef(PayloadHelper.encodeFloat(payload));
this.typeMatch = typeMatch;
diff --git a/solr/core/src/java/org/apache/solr/analysis/NumericPayloadTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilterFactory.java
similarity index 83%
rename from solr/core/src/java/org/apache/solr/analysis/NumericPayloadTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilterFactory.java
index 605df3e..0bb92fa 100644
--- a/solr/core/src/java/org/apache/solr/analysis/NumericPayloadTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/NumericPayloadTokenFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.payloads;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,11 +17,9 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.payloads.NumericPayloadTokenFilter;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import java.util.Map;
@@ -41,8 +40,12 @@
@Override
public void init(Map<String, String> args) {
super.init(args);
- payload = Float.parseFloat(args.get("payload"));
+ String payloadArg = args.get("payload");
typeMatch = args.get("typeMatch");
+ if (payloadArg == null || typeMatch == null) {
+ throw new InitializationException("Both payload and typeMatch are required");
+ }
+ payload = Float.parseFloat(payloadArg);
}
public NumericPayloadTokenFilter create(TokenStream input) {
return new NumericPayloadTokenFilter(input,payload,typeMatch);
diff --git a/solr/core/src/java/org/apache/solr/analysis/TokenOffsetPayloadTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TokenOffsetPayloadTokenFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/TokenOffsetPayloadTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TokenOffsetPayloadTokenFilterFactory.java
index 6d866e1..9cf7eaf 100644
--- a/solr/core/src/java/org/apache/solr/analysis/TokenOffsetPayloadTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TokenOffsetPayloadTokenFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.payloads;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.payloads.TokenOffsetPayloadTokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/TypeAsPayloadTokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TypeAsPayloadTokenFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/TypeAsPayloadTokenFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TypeAsPayloadTokenFilterFactory.java
index 9a67fa9..30d03c3 100644
--- a/solr/core/src/java/org/apache/solr/analysis/TypeAsPayloadTokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/payloads/TypeAsPayloadTokenFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.payloads;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.payloads.TypeAsPayloadTokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/PositionFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PositionFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.java
index 1fcc294..a15618c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PositionFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/position/PositionFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.position;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.position.PositionFilter;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/PortugueseLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PortugueseLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemFilterFactory.java
index 63f8902..e1ef9d1 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PortugueseLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PortugueseMinimalStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PortugueseMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseMinimalStemFilterFactory.java
index 9148435..b934b62 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PortugueseMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/PortugueseStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/PortugueseStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseStemFilterFactory.java
index 4ddb7d9..632cef2 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PortugueseStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/ReverseStringFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/reverse/ReverseStringFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/ReverseStringFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/reverse/ReverseStringFilterFactory.java
index f090c9d..4dbea0c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ReverseStringFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/reverse/ReverseStringFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.reverse;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.reverse.ReverseStringFilter;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/RussianLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/RussianLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemFilterFactory.java
index 6b0411b..934c5a9 100644
--- a/solr/core/src/java/org/apache/solr/analysis/RussianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ru;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/ShingleFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/ShingleFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilterFactory.java
index ba329a0..87405c8 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ShingleFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/shingle/ShingleFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.shingle;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,9 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.shingle.ShingleFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.InitializationException;
diff --git a/solr/core/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballPorterFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballPorterFilterFactory.java
index dc897cb..68115dc 100644
--- a/solr/core/src/java/org/apache/solr/analysis/SnowballPorterFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballPorterFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.snowball;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import java.util.Map;
import java.io.IOException;
diff --git a/solr/core/src/java/org/apache/solr/analysis/ClassicFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/ClassicFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicFilterFactory.java
index 12ae66f..68d3318 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ClassicFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.standard;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/ClassicTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicTokenizerFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/ClassicTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicTokenizerFactory.java
index 4efe6e7..1142433 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ClassicTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.standard;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.standard.ClassicTokenizer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
diff --git a/solr/core/src/java/org/apache/solr/analysis/StandardFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardFilterFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/StandardFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardFilterFactory.java
index 965eb08..47868c0 100644
--- a/solr/core/src/java/org/apache/solr/analysis/StandardFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.standard;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/StandardTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/StandardTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerFactory.java
index 4385057..3075fb4 100644
--- a/solr/core/src/java/org/apache/solr/analysis/StandardTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.standard;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/UAX29URLEmailTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizerFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/UAX29URLEmailTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizerFactory.java
index 4c7076f..a83b714 100644
--- a/solr/core/src/java/org/apache/solr/analysis/UAX29URLEmailTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/standard/UAX29URLEmailTokenizerFactory.java
@@ -1,5 +1,4 @@
-package org.apache.solr.analysis;
-
+package org.apache.lucene.analysis.standard;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,8 +17,6 @@
* limitations under the License.
*/
-
-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.standard.UAX29URLEmailTokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
diff --git a/solr/core/src/java/org/apache/solr/analysis/SwedishLightStemFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/SwedishLightStemFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemFilterFactory.java
index 78f65da..122e402 100644
--- a/solr/core/src/java/org/apache/solr/analysis/SwedishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.sv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/SynonymFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java
similarity index 92%
rename from solr/core/src/java/org/apache/solr/analysis/SynonymFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java
index cddaf64..ee2c90a 100644
--- a/solr/core/src/java/org/apache/solr/analysis/SynonymFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.synonym;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -38,9 +38,6 @@
import org.apache.lucene.analysis.synonym.WordnetSynonymParser;
import org.apache.lucene.analysis.util.*;
import org.apache.lucene.util.Version;
-import org.apache.solr.common.util.StrUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Factory for {@link SynonymFilter}.
@@ -55,9 +52,6 @@
* </fieldType></pre>
*/
public class SynonymFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {
-
- public static final Logger log = LoggerFactory.getLogger(SynonymFilterFactory.class);
-
private SynonymMap map;
private boolean ignoreCase;
@@ -100,10 +94,6 @@
} catch (Exception e) {
throw new InitializationException("Exception thrown while loading synonyms", e);
}
-
- if (map.fst == null) {
- log.warn("Synonyms loaded with " + args + " has empty rule set!");
- }
}
/**
@@ -125,7 +115,7 @@
decoder.reset();
parser.add(new InputStreamReader(loader.openResource(synonyms), decoder));
} else {
- List<String> files = StrUtils.splitFileNames(synonyms);
+ List<String> files = splitFileNames(synonyms);
for (String file : files) {
decoder.reset();
parser.add(new InputStreamReader(loader.openResource(file), decoder));
@@ -153,7 +143,7 @@
decoder.reset();
parser.add(new InputStreamReader(loader.openResource(synonyms), decoder));
} else {
- List<String> files = StrUtils.splitFileNames(synonyms);
+ List<String> files = splitFileNames(synonyms);
for (String file : files) {
decoder.reset();
parser.add(new InputStreamReader(loader.openResource(file), decoder));
@@ -162,6 +152,7 @@
return parser.build();
}
+ // (there are no tests for this functionality)
private TokenizerFactory loadTokenizerFactory(ResourceLoader loader, String cname){
TokenizerFactory tokFactory = loader.newInstance(cname, TokenizerFactory.class);
tokFactory.setLuceneMatchVersion(luceneMatchVersion);
diff --git a/solr/core/src/java/org/apache/solr/analysis/ThaiWordFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/ThaiWordFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilterFactory.java
index 22d3953..f08eead 100644
--- a/solr/core/src/java/org/apache/solr/analysis/ThaiWordFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/th/ThaiWordFilterFactory.java
@@ -1,3 +1,4 @@
+package org.apache.lucene.analysis.th;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -16,8 +17,6 @@
* limitations under the License.
*/
-
-package org.apache.solr.analysis;
import org.apache.lucene.analysis.th.ThaiWordFilter;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/java/org/apache/solr/analysis/TurkishLowerCaseFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/TurkishLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilterFactory.java
index 72fa83b..c9cda8c 100644
--- a/solr/core/src/java/org/apache/solr/analysis/TurkishLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/tr/TurkishLowerCaseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.tr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java
new file mode 100644
index 0000000..f45d5d4
--- /dev/null
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java
@@ -0,0 +1,103 @@
+package org.apache.lucene.analysis.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import java.util.ServiceConfigurationError;
+
+import org.apache.lucene.util.SPIClassIterator;
+
+/**
+ * Helper class for loading named SPIs from classpath (e.g. Tokenizers, TokenStreams).
+ * @lucene.internal
+ */
+public final class AnalysisSPILoader<S extends AbstractAnalysisFactory> {
+
+ private final Map<String,Class<? extends S>> services;
+ private final Class<S> clazz;
+
+ public AnalysisSPILoader(Class<S> clazz) {
+ this(clazz, new String[] { clazz.getSimpleName() });
+ }
+
+ public AnalysisSPILoader(Class<S> clazz, ClassLoader loader) {
+ this(clazz, new String[] { clazz.getSimpleName() }, loader);
+ }
+
+ public AnalysisSPILoader(Class<S> clazz, String[] suffixes) {
+ this(clazz, suffixes, Thread.currentThread().getContextClassLoader());
+ }
+
+ public AnalysisSPILoader(Class<S> clazz, String[] suffixes, ClassLoader classloader) {
+ this.clazz = clazz;
+ final SPIClassIterator<S> loader = SPIClassIterator.get(clazz, classloader);
+ final LinkedHashMap<String,Class<? extends S>> services = new LinkedHashMap<String,Class<? extends S>>();
+ while (loader.hasNext()) {
+ final Class<? extends S> service = loader.next();
+ final String clazzName = service.getSimpleName();
+ String name = null;
+ for (String suffix : suffixes) {
+ if (clazzName.endsWith(suffix)) {
+ name = clazzName.substring(0, clazzName.length() - suffix.length()).toLowerCase(Locale.ROOT);
+ break;
+ }
+ }
+ if (name == null) {
+ throw new ServiceConfigurationError("The class name " + service.getName() +
+ " has wrong suffix, allowed are: " + Arrays.toString(suffixes));
+ }
+ // only add the first one for each name, later services will be ignored
+ // this allows to place services before others in classpath to make
+ // them used instead of others
+ if (!services.containsKey(name)) {
+ services.put(name, service);
+ }
+ }
+ this.services = Collections.unmodifiableMap(services);
+ }
+
+ public S newInstance(String name) {
+ final Class<? extends S> service = lookupClass(name);
+ try {
+ return service.newInstance();
+ } catch (Exception e) {
+ throw new IllegalArgumentException("SPI class of type "+clazz.getName()+" with name '"+name+"' cannot be instantiated. " +
+ "This is likely due to a misconfiguration of the java class '" + service.getName() + "': ", e);
+ }
+ }
+
+ public Class<? extends S> lookupClass(String name) {
+ final Class<? extends S> service = services.get(name.toLowerCase(Locale.ROOT));
+ if (service != null) {
+ return service;
+ } else {
+ throw new IllegalArgumentException("A SPI class of type "+clazz.getName()+" with name '"+name+"' does not exist. "+
+ "You need to add the corresponding JAR file supporting this SPI to your classpath."+
+ "The current classpath supports the following names: "+availableServices());
+ }
+ }
+
+ public Set<String> availableServices() {
+ return services.keySet();
+ }
+}
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharFilterFactory.java
index 449c875..489d34f 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/CharFilterFactory.java
@@ -18,6 +18,7 @@
*/
import java.io.Reader;
+import java.util.Set;
import org.apache.lucene.analysis.CharFilter;
@@ -27,5 +28,32 @@
*/
public abstract class CharFilterFactory extends AbstractAnalysisFactory {
- public abstract CharFilter create(Reader input);
+ private static final AnalysisSPILoader<CharFilterFactory> loader =
+ getSPILoader(Thread.currentThread().getContextClassLoader());
+
+ /**
+ * Used by e.g. Apache Solr to get a correctly configured instance
+ * of {@link AnalysisSPILoader} from Solr's classpath.
+ * @lucene.internal
+ */
+ public static AnalysisSPILoader<CharFilterFactory> getSPILoader(ClassLoader classloader) {
+ return new AnalysisSPILoader<CharFilterFactory>(CharFilterFactory.class, classloader);
+ }
+
+ /** looks up a charfilter by name from context classpath */
+ public static CharFilterFactory forName(String name) {
+ return loader.newInstance(name);
+ }
+
+ /** looks up a charfilter class by name from context classpath */
+ public static Class<? extends CharFilterFactory> lookupClass(String name) {
+ return loader.lookupClass(name);
+ }
+
+ /** returns a list of all available charfilter names */
+ public static Set<String> availableCharFilters() {
+ return loader.availableServices();
+ }
+
+ public abstract Reader create(Reader input);
}
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenFilterFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenFilterFactory.java
index 0bced95..8e463aa 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenFilterFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenFilterFactory.java
@@ -17,6 +17,8 @@
* limitations under the License.
*/
+import java.util.Set;
+
import org.apache.lucene.analysis.TokenStream;
/**
@@ -25,6 +27,34 @@
*/
public abstract class TokenFilterFactory extends AbstractAnalysisFactory {
+ private static final AnalysisSPILoader<TokenFilterFactory> loader =
+ getSPILoader(Thread.currentThread().getContextClassLoader());
+
+ /**
+ * Used by e.g. Apache Solr to get a correctly configured instance
+ * of {@link AnalysisSPILoader} from Solr's classpath.
+ * @lucene.internal
+ */
+ public static AnalysisSPILoader<TokenFilterFactory> getSPILoader(ClassLoader classloader) {
+ return new AnalysisSPILoader<TokenFilterFactory>(TokenFilterFactory.class,
+ new String[] { "TokenFilterFactory", "FilterFactory" }, classloader);
+ }
+
+ /** looks up a tokenfilter by name from context classpath */
+ public static TokenFilterFactory forName(String name) {
+ return loader.newInstance(name);
+ }
+
+ /** looks up a tokenfilter class by name from context classpath */
+ public static Class<? extends TokenFilterFactory> lookupClass(String name) {
+ return loader.lookupClass(name);
+ }
+
+ /** returns a list of all available tokenfilter names from context classpath */
+ public static Set<String> availableTokenFilters() {
+ return loader.availableServices();
+ }
+
/** Transform the specified input TokenStream */
public abstract TokenStream create(TokenStream input);
}
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenizerFactory.java
index baeae93..7ac94c7 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/TokenizerFactory.java
@@ -20,6 +20,7 @@
import org.apache.lucene.analysis.Tokenizer;
import java.io.Reader;
+import java.util.Set;
/**
* Abstract parent class for analysis factories that create {@link Tokenizer}
@@ -27,6 +28,33 @@
*/
public abstract class TokenizerFactory extends AbstractAnalysisFactory {
+ private static final AnalysisSPILoader<TokenizerFactory> loader =
+ getSPILoader(Thread.currentThread().getContextClassLoader());
+
+ /**
+ * Used by e.g. Apache Solr to get a correctly configured instance
+ * of {@link AnalysisSPILoader} from Solr's classpath.
+ * @lucene.internal
+ */
+ public static AnalysisSPILoader<TokenizerFactory> getSPILoader(ClassLoader classloader) {
+ return new AnalysisSPILoader<TokenizerFactory>(TokenizerFactory.class, classloader);
+ }
+
+ /** looks up a tokenizer by name from context classpath */
+ public static TokenizerFactory forName(String name) {
+ return loader.newInstance(name);
+ }
+
+ /** looks up a tokenizer class by name from context classpath */
+ public static Class<? extends TokenizerFactory> lookupClass(String name) {
+ return loader.lookupClass(name);
+ }
+
+ /** returns a list of all available tokenizer names from context classpath */
+ public static Set<String> availableTokenizers() {
+ return loader.availableServices();
+ }
+
/** Creates a TokenStream of the specified input */
public abstract Tokenizer create(Reader input);
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/WikipediaTokenizerFactory.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/wikipedia/WikipediaTokenizerFactory.java
similarity index 96%
rename from solr/core/src/java/org/apache/solr/analysis/WikipediaTokenizerFactory.java
rename to lucene/analysis/common/src/java/org/apache/lucene/analysis/wikipedia/WikipediaTokenizerFactory.java
index e77b058..fc7967a 100644
--- a/solr/core/src/java/org/apache/solr/analysis/WikipediaTokenizerFactory.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/wikipedia/WikipediaTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.wikipedia;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory
new file mode 100644
index 0000000..b53db41
--- /dev/null
+++ b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory
+org.apache.lucene.analysis.charfilter.MappingCharFilterFactory
+org.apache.lucene.analysis.fa.PersianCharFilterFactory
+org.apache.lucene.analysis.pattern.PatternReplaceCharFilterFactory
diff --git a/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..0abe4b9
--- /dev/null
+++ b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.ar.ArabicNormalizationFilterFactory
+org.apache.lucene.analysis.ar.ArabicStemFilterFactory
+org.apache.lucene.analysis.bg.BulgarianStemFilterFactory
+org.apache.lucene.analysis.br.BrazilianStemFilterFactory
+org.apache.lucene.analysis.cjk.CJKBigramFilterFactory
+org.apache.lucene.analysis.cjk.CJKWidthFilterFactory
+org.apache.lucene.analysis.commongrams.CommonGramsFilterFactory
+org.apache.lucene.analysis.commongrams.CommonGramsQueryFilterFactory
+org.apache.lucene.analysis.compound.DictionaryCompoundWordTokenFilterFactory
+org.apache.lucene.analysis.compound.HyphenationCompoundWordTokenFilterFactory
+org.apache.lucene.analysis.core.LowerCaseFilterFactory
+org.apache.lucene.analysis.core.StopFilterFactory
+org.apache.lucene.analysis.core.TypeTokenFilterFactory
+org.apache.lucene.analysis.cz.CzechStemFilterFactory
+org.apache.lucene.analysis.de.GermanLightStemFilterFactory
+org.apache.lucene.analysis.de.GermanMinimalStemFilterFactory
+org.apache.lucene.analysis.de.GermanNormalizationFilterFactory
+org.apache.lucene.analysis.de.GermanStemFilterFactory
+org.apache.lucene.analysis.el.GreekLowerCaseFilterFactory
+org.apache.lucene.analysis.el.GreekStemFilterFactory
+org.apache.lucene.analysis.en.EnglishMinimalStemFilterFactory
+org.apache.lucene.analysis.en.EnglishPossessiveFilterFactory
+org.apache.lucene.analysis.en.KStemFilterFactory
+org.apache.lucene.analysis.en.PorterStemFilterFactory
+org.apache.lucene.analysis.es.SpanishLightStemFilterFactory
+org.apache.lucene.analysis.fa.PersianNormalizationFilterFactory
+org.apache.lucene.analysis.fi.FinnishLightStemFilterFactory
+org.apache.lucene.analysis.fr.ElisionFilterFactory
+org.apache.lucene.analysis.fr.FrenchLightStemFilterFactory
+org.apache.lucene.analysis.fr.FrenchMinimalStemFilterFactory
+org.apache.lucene.analysis.ga.IrishLowerCaseFilterFactory
+org.apache.lucene.analysis.gl.GalicianMinimalStemFilterFactory
+org.apache.lucene.analysis.gl.GalicianStemFilterFactory
+org.apache.lucene.analysis.hi.HindiNormalizationFilterFactory
+org.apache.lucene.analysis.hi.HindiStemFilterFactory
+org.apache.lucene.analysis.hu.HungarianLightStemFilterFactory
+org.apache.lucene.analysis.hunspell.HunspellStemFilterFactory
+org.apache.lucene.analysis.id.IndonesianStemFilterFactory
+org.apache.lucene.analysis.in.IndicNormalizationFilterFactory
+org.apache.lucene.analysis.it.ItalianLightStemFilterFactory
+org.apache.lucene.analysis.lv.LatvianStemFilterFactory
+org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory
+org.apache.lucene.analysis.miscellaneous.CapitalizationFilterFactory
+org.apache.lucene.analysis.miscellaneous.HyphenatedWordsFilterFactory
+org.apache.lucene.analysis.miscellaneous.KeepWordFilterFactory
+org.apache.lucene.analysis.miscellaneous.KeywordMarkerFilterFactory
+org.apache.lucene.analysis.miscellaneous.LengthFilterFactory
+org.apache.lucene.analysis.miscellaneous.LimitTokenCountFilterFactory
+org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilterFactory
+org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilterFactory
+org.apache.lucene.analysis.miscellaneous.TrimFilterFactory
+org.apache.lucene.analysis.miscellaneous.WordDelimiterFilterFactory
+org.apache.lucene.analysis.ngram.EdgeNGramFilterFactory
+org.apache.lucene.analysis.ngram.NGramFilterFactory
+org.apache.lucene.analysis.no.NorwegianLightStemFilterFactory
+org.apache.lucene.analysis.no.NorwegianMinimalStemFilterFactory
+org.apache.lucene.analysis.pattern.PatternReplaceFilterFactory
+org.apache.lucene.analysis.payloads.DelimitedPayloadTokenFilterFactory
+org.apache.lucene.analysis.payloads.NumericPayloadTokenFilterFactory
+org.apache.lucene.analysis.payloads.TokenOffsetPayloadTokenFilterFactory
+org.apache.lucene.analysis.payloads.TypeAsPayloadTokenFilterFactory
+org.apache.lucene.analysis.position.PositionFilterFactory
+org.apache.lucene.analysis.pt.PortugueseLightStemFilterFactory
+org.apache.lucene.analysis.pt.PortugueseMinimalStemFilterFactory
+org.apache.lucene.analysis.pt.PortugueseStemFilterFactory
+org.apache.lucene.analysis.reverse.ReverseStringFilterFactory
+org.apache.lucene.analysis.ru.RussianLightStemFilterFactory
+org.apache.lucene.analysis.shingle.ShingleFilterFactory
+org.apache.lucene.analysis.snowball.SnowballPorterFilterFactory
+org.apache.lucene.analysis.standard.ClassicFilterFactory
+org.apache.lucene.analysis.standard.StandardFilterFactory
+org.apache.lucene.analysis.sv.SwedishLightStemFilterFactory
+org.apache.lucene.analysis.synonym.SynonymFilterFactory
+org.apache.lucene.analysis.th.ThaiWordFilterFactory
+org.apache.lucene.analysis.tr.TurkishLowerCaseFilterFactory
diff --git a/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
new file mode 100644
index 0000000..fd8bf88
--- /dev/null
+++ b/lucene/analysis/common/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.core.KeywordTokenizerFactory
+org.apache.lucene.analysis.core.LetterTokenizerFactory
+org.apache.lucene.analysis.core.LowerCaseTokenizerFactory
+org.apache.lucene.analysis.core.WhitespaceTokenizerFactory
+org.apache.lucene.analysis.ngram.EdgeNGramTokenizerFactory
+org.apache.lucene.analysis.ngram.NGramTokenizerFactory
+org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory
+org.apache.lucene.analysis.pattern.PatternTokenizerFactory
+org.apache.lucene.analysis.standard.ClassicTokenizerFactory
+org.apache.lucene.analysis.standard.StandardTokenizerFactory
+org.apache.lucene.analysis.standard.UAX29URLEmailTokenizerFactory
+org.apache.lucene.analysis.wikipedia.WikipediaTokenizerFactory
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestArabicFilters.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ar/TestArabicFilters.java
similarity index 94%
rename from solr/core/src/test/org/apache/solr/analysis/TestArabicFilters.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/ar/TestArabicFilters.java
index 8296b5f..de64b47 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestArabicFilters.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ar/TestArabicFilters.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ar;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +25,8 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.fa.PersianCharFilterFactory;
+import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
/**
* Simple tests to ensure the Arabic filter Factories are working.
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestBulgarianStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/bg/TestBulgarianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestBulgarianStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/bg/TestBulgarianStemFilterFactory.java
index 7be02eb..7bfb2fa 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestBulgarianStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/bg/TestBulgarianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.bg;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestBrazilianStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/br/TestBrazilianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestBrazilianStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/br/TestBrazilianStemFilterFactory.java
index 0511265..883ebc7 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestBrazilianStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/br/TestBrazilianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.br;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilterFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilterFactory.java
index da7f390..082b4fe 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestHTMLStripCharFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.charfilter;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestMappingCharFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestMappingCharFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestMappingCharFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestMappingCharFilterFactory.java
index c9db4aa..9296370 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestMappingCharFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestMappingCharFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.charfilter;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.util.LuceneTestCase;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestCJKBigramFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestCJKBigramFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
index bf48876..316a42a 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestCJKBigramFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cjk;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -29,7 +29,6 @@
/**
* Simple tests to ensure the CJK bigram factory is working.
- * @deprecated
*/
public class TestCJKBigramFilterFactory extends BaseTokenStreamTestCase {
public void testDefaults() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestCJKWidthFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKWidthFilterFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestCJKWidthFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKWidthFilterFactory.java
index 0de6588..84828ef 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestCJKWidthFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKWidthFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cjk;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/CommonGramsFilterFactoryTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsFilterFactory.java
similarity index 90%
rename from solr/core/src/test/org/apache/solr/analysis/CommonGramsFilterFactoryTest.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsFilterFactory.java
index 27841e7..3739f08 100644
--- a/solr/core/src/test/org/apache/solr/analysis/CommonGramsFilterFactoryTest.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.commongrams;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,9 +21,10 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.core.TestStopFilter;
import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
import java.io.StringReader;
import java.util.Collections;
@@ -35,10 +36,10 @@
* used by the StopFilterFactoryTest TODO: consider creating separate test files
* so this won't break if stop filter test files change
**/
-public class CommonGramsFilterFactoryTest extends BaseTokenStreamTestCase {
+public class TestCommonGramsFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(TestStopFilter.class);
assertTrue("loader is null and it shouldn't be", loader != null);
CommonGramsFilterFactory factory = new CommonGramsFilterFactory();
Map<String, String> args = new HashMap<String, String>();
@@ -88,7 +89,7 @@
* If no words are provided, then a set of english default stopwords is used.
*/
public void testDefaults() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(TestStopFilter.class);
assertTrue("loader is null and it shouldn't be", loader != null);
CommonGramsFilterFactory factory = new CommonGramsFilterFactory();
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
diff --git a/solr/core/src/test/org/apache/solr/analysis/CommonGramsQueryFilterFactoryTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsQueryFilterFactory.java
similarity index 90%
rename from solr/core/src/test/org/apache/solr/analysis/CommonGramsQueryFilterFactoryTest.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsQueryFilterFactory.java
index f648432..95de4d4 100644
--- a/solr/core/src/test/org/apache/solr/analysis/CommonGramsQueryFilterFactoryTest.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/commongrams/TestCommonGramsQueryFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.commongrams;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,15 +16,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.core.TestStopFilter;
import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
import java.io.StringReader;
import java.util.Collections;
@@ -34,10 +36,10 @@
* used by the StopFilterFactoryTest TODO: consider creating separate test files
* so this won't break if stop filter test files change
**/
-public class CommonGramsQueryFilterFactoryTest extends BaseTokenStreamTestCase {
+public class TestCommonGramsQueryFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(TestStopFilter.class);
assertTrue("loader is null and it shouldn't be", loader != null);
CommonGramsQueryFilterFactory factory = new CommonGramsQueryFilterFactory();
Map<String, String> args = new HashMap<String, String>();
@@ -87,7 +89,7 @@
* If no words are provided, then a set of english default stopwords is used.
*/
public void testDefaults() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(TestStopFilter.class);
assertTrue("loader is null and it shouldn't be", loader != null);
CommonGramsQueryFilterFactory factory = new CommonGramsQueryFilterFactory();
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestDictionaryCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestDictionaryCompoundWordTokenFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestDictionaryCompoundWordTokenFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestDictionaryCompoundWordTokenFilterFactory.java
index 8b7832d..c3b656a 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestDictionaryCompoundWordTokenFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestDictionaryCompoundWordTokenFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.compound;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,8 +26,8 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
/**
* Simple tests to ensure the Dictionary compound filter factory is working.
@@ -40,7 +40,7 @@
Reader reader = new StringReader("I like to play softball");
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
DictionaryCompoundWordTokenFilterFactory factory = new DictionaryCompoundWordTokenFilterFactory();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
Map<String,String> args = new HashMap<String,String>();
args.put("dictionary", "compoundDictionary.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java
similarity index 92%
rename from solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java
index 30a282c..c5a22f9 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestHyphenationCompoundWordTokenFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.compound;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,8 +26,8 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
/**
* Simple tests to ensure the Hyphenation compound filter factory is working.
@@ -40,7 +40,7 @@
Reader reader = new StringReader("min veninde som er lidt af en læsehest");
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
HyphenationCompoundWordTokenFilterFactory factory = new HyphenationCompoundWordTokenFilterFactory();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
Map<String,String> args = new HashMap<String,String>();
args.put("hyphenator", "da_UTF8.xml");
args.put("dictionary", "da_compoundDictionary.txt");
@@ -64,7 +64,7 @@
Reader reader = new StringReader("basketballkurv");
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
HyphenationCompoundWordTokenFilterFactory factory = new HyphenationCompoundWordTokenFilterFactory();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
Map<String,String> args = new HashMap<String,String>();
args.put("hyphenator", "da_UTF8.xml");
args.put("minSubwordSize", "2");
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/compoundDictionary.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/compoundDictionary.txt
new file mode 100644
index 0000000..f4977b5
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/compoundDictionary.txt
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# A set of words for testing the DictionaryCompound factory
+soft
+ball
+team
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/da_compoundDictionary.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/da_compoundDictionary.txt
new file mode 100644
index 0000000..9a14f40
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/da_compoundDictionary.txt
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# A set of words for testing the HyphenationCompound factory,
+# in conjunction with the danish hyphenation grammar.
+læse
+hest
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
new file mode 100644
index 0000000..a81ea9a
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAllAnalyzersHaveFactories.java
@@ -0,0 +1,127 @@
+package org.apache.lucene.analysis.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.lucene.analysis.CachingTokenFilter;
+import org.apache.lucene.analysis.CharFilter;
+import org.apache.lucene.analysis.EmptyTokenizer;
+import org.apache.lucene.analysis.MockCharFilter;
+import org.apache.lucene.analysis.MockFixedLengthPayloadFilter;
+import org.apache.lucene.analysis.MockGraphTokenFilter;
+import org.apache.lucene.analysis.MockHoleInjectingTokenFilter;
+import org.apache.lucene.analysis.MockRandomLookaheadTokenFilter;
+import org.apache.lucene.analysis.MockTokenFilter;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.MockVariableLengthPayloadFilter;
+import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.ValidatingTokenFilter;
+import org.apache.lucene.analysis.core.TestRandomChains;
+import org.apache.lucene.analysis.path.ReversePathHierarchyTokenizer;
+import org.apache.lucene.analysis.sinks.TeeSinkTokenFilter;
+import org.apache.lucene.analysis.snowball.SnowballFilter;
+import org.apache.lucene.analysis.util.CharFilterFactory;
+import org.apache.lucene.analysis.util.TokenFilterFactory;
+import org.apache.lucene.analysis.util.TokenizerFactory;
+import org.apache.lucene.util.LuceneTestCase;
+
+/**
+ * Tests that any newly added Tokenizers/TokenFilters/CharFilters have a
+ * corresponding factory (and that the SPI configuration is correct)
+ */
+public class TestAllAnalyzersHaveFactories extends LuceneTestCase {
+
+ // these are test-only components (e.g. test-framework)
+ private static final Set<Class<?>> testComponents = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
+ static {
+ Collections.<Class<?>>addAll(testComponents,
+ MockTokenizer.class,
+ MockCharFilter.class,
+ MockFixedLengthPayloadFilter.class,
+ MockGraphTokenFilter.class,
+ MockHoleInjectingTokenFilter.class,
+ MockRandomLookaheadTokenFilter.class,
+ MockTokenFilter.class,
+ MockVariableLengthPayloadFilter.class,
+ EmptyTokenizer.class,
+ ValidatingTokenFilter.class
+ );
+ }
+
+ // these are 'crazy' components like cachingtokenfilter. does it make sense to add factories for these?
+ private static final Set<Class<?>> crazyComponents = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
+ static {
+ Collections.<Class<?>>addAll(crazyComponents,
+ CachingTokenFilter.class,
+ TeeSinkTokenFilter.class
+ );
+ }
+
+ // these are oddly-named (either the actual analyzer, or its factory)
+ // they do actually have factories.
+ // TODO: clean this up!
+ private static final Set<Class<?>> oddlyNamedComponents = Collections.newSetFromMap(new IdentityHashMap<Class<?>,Boolean>());
+ static {
+ Collections.<Class<?>>addAll(oddlyNamedComponents,
+ ReversePathHierarchyTokenizer.class, // this is supported via an option to PathHierarchyTokenizer's factory
+ SnowballFilter.class // this is called SnowballPorterFilterFactory
+ );
+ }
+
+ public void test() throws Exception {
+ List<Class<?>> analysisClasses = new ArrayList<Class<?>>();
+ TestRandomChains.getClassesForPackage("org.apache.lucene.analysis", analysisClasses);
+
+ for (final Class<?> c : analysisClasses) {
+ final int modifiers = c.getModifiers();
+ if (
+ // don't waste time with abstract classes
+ Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers)
+ || c.isSynthetic() || c.isAnonymousClass() || c.isMemberClass() || c.isInterface()
+ || testComponents.contains(c)
+ || crazyComponents.contains(c)
+ || oddlyNamedComponents.contains(c)
+ || !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharFilter.class.isAssignableFrom(c))
+ ) {
+ continue;
+ }
+
+ if (Tokenizer.class.isAssignableFrom(c)) {
+ String clazzName = c.getSimpleName();
+ assertTrue(clazzName.endsWith("Tokenizer"));
+ assertNotNull(TokenizerFactory.forName(clazzName.substring(0, clazzName.length() - 9)));
+ } else if (TokenFilter.class.isAssignableFrom(c)) {
+ String clazzName = c.getSimpleName();
+ assertTrue(clazzName.endsWith("Filter"));
+ String simpleName = clazzName.substring(0, clazzName.length() - (clazzName.endsWith("TokenFilter") ? 11 : 6));
+ assertNotNull(TokenFilterFactory.forName(simpleName));
+ } else if (CharFilter.class.isAssignableFrom(c)) {
+ String clazzName = c.getSimpleName();
+ assertTrue(clazzName.endsWith("CharFilter"));
+ assertNotNull(CharFilterFactory.forName(clazzName.substring(0, clazzName.length() - 10)));
+ }
+ }
+ }
+}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java
new file mode 100644
index 0000000..137eb8e
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestFactories.java
@@ -0,0 +1,179 @@
+package org.apache.lucene.analysis.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Collections;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
+import org.apache.lucene.analysis.util.CharFilterFactory;
+import org.apache.lucene.analysis.util.InitializationException;
+import org.apache.lucene.analysis.util.MultiTermAwareComponent;
+import org.apache.lucene.analysis.util.ResourceLoaderAware;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
+import org.apache.lucene.analysis.util.TokenFilterFactory;
+import org.apache.lucene.analysis.util.TokenizerFactory;
+
+/**
+ * Sanity check some things about all factories,
+ * we do our best to see if we can sanely initialize it with
+ * no parameters and smoke test it, etc.
+ */
+// TODO: move this, TestRandomChains, and TestAllAnalyzersHaveFactories
+// to an integration test module that sucks in all analysis modules.
+// currently the only way to do this is via eclipse etc (LUCENE-3974)
+public class TestFactories extends BaseTokenStreamTestCase {
+ public void test() throws IOException {
+ for (String tokenizer : TokenizerFactory.availableTokenizers()) {
+ doTestTokenizer(tokenizer);
+ }
+
+ for (String tokenFilter : TokenFilterFactory.availableTokenFilters()) {
+ doTestTokenFilter(tokenFilter);
+ }
+
+ for (String charFilter : CharFilterFactory.availableCharFilters()) {
+ doTestCharFilter(charFilter);
+ }
+ }
+
+ private void doTestTokenizer(String tokenizer) throws IOException {
+ TokenizerFactory factory = TokenizerFactory.forName(tokenizer);
+ if (initialize(factory)) {
+ // we managed to fully create an instance. check a few more things:
+
+ // if it implements MultiTermAware, sanity check its impl
+ if (factory instanceof MultiTermAwareComponent) {
+ AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
+ assertNotNull(mtc);
+ // its not ok to return e.g. a charfilter here: but a tokenizer could wrap a filter around it
+ assertFalse(mtc instanceof CharFilterFactory);
+ }
+
+ // beast it just a little, it shouldnt throw exceptions:
+ // (it should have thrown them in initialize)
+ checkRandomData(random(), new FactoryAnalyzer(factory, null, null), 100, 20, false, false);
+ }
+ }
+
+ private void doTestTokenFilter(String tokenfilter) throws IOException {
+ TokenFilterFactory factory = TokenFilterFactory.forName(tokenfilter);
+ if (initialize(factory)) {
+ // we managed to fully create an instance. check a few more things:
+
+ // if it implements MultiTermAware, sanity check its impl
+ if (factory instanceof MultiTermAwareComponent) {
+ AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
+ assertNotNull(mtc);
+ // its not ok to return a charfilter or tokenizer here, this makes no sense
+ assertTrue(mtc instanceof TokenFilterFactory);
+ }
+
+ // beast it just a little, it shouldnt throw exceptions:
+ // (it should have thrown them in initialize)
+ checkRandomData(random(), new FactoryAnalyzer(assertingTokenizer, factory, null), 100, 20, false, false);
+ }
+ }
+
+ private void doTestCharFilter(String charfilter) throws IOException {
+ CharFilterFactory factory = CharFilterFactory.forName(charfilter);
+ if (initialize(factory)) {
+ // we managed to fully create an instance. check a few more things:
+
+ // if it implements MultiTermAware, sanity check its impl
+ if (factory instanceof MultiTermAwareComponent) {
+ AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
+ assertNotNull(mtc);
+ // its not ok to return a tokenizer or tokenfilter here, this makes no sense
+ assertTrue(mtc instanceof CharFilterFactory);
+ }
+
+ // beast it just a little, it shouldnt throw exceptions:
+ // (it should have thrown them in initialize)
+ checkRandomData(random(), new FactoryAnalyzer(assertingTokenizer, null, factory), 100, 20, false, false);
+ }
+ }
+
+ /** tries to initialize a factory with no arguments */
+ private boolean initialize(AbstractAnalysisFactory factory) {
+ boolean success = false;
+ try {
+ factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
+ factory.init(Collections.<String,String>emptyMap());
+ success = true;
+ } catch (InitializationException ignored) {
+ // its ok if we dont provide the right parameters to throw this
+ }
+
+ if (factory instanceof ResourceLoaderAware) {
+ success = false;
+ try {
+ ((ResourceLoaderAware) factory).inform(new StringMockResourceLoader(""));
+ success = true;
+ } catch (InitializationException ignored) {
+ // its ok if the right files arent available or whatever to throw this
+ }
+ }
+ return success;
+ }
+
+ // some silly classes just so we can use checkRandomData
+ private TokenizerFactory assertingTokenizer = new TokenizerFactory() {
+ @Override
+ public Tokenizer create(Reader input) {
+ return new MockTokenizer(input);
+ }
+ };
+
+ private static class FactoryAnalyzer extends Analyzer {
+ final TokenizerFactory tokenizer;
+ final CharFilterFactory charFilter;
+ final TokenFilterFactory tokenfilter;
+
+ FactoryAnalyzer(TokenizerFactory tokenizer, TokenFilterFactory tokenfilter, CharFilterFactory charFilter) {
+ assert tokenizer != null;
+ this.tokenizer = tokenizer;
+ this.charFilter = charFilter;
+ this.tokenfilter = tokenfilter;
+ }
+
+ @Override
+ protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
+ Tokenizer tf = tokenizer.create(reader);
+ if (tokenfilter != null) {
+ return new TokenStreamComponents(tf, tokenfilter.create(tf));
+ } else {
+ return new TokenStreamComponents(tf);
+ }
+ }
+
+ @Override
+ protected Reader initReader(String fieldName, Reader reader) {
+ if (charFilter != null) {
+ return charFilter.create(reader);
+ } else {
+ return reader;
+ }
+ }
+ }
+}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
index 9148672..ff3e9eb 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java
@@ -235,7 +235,7 @@
private static <T> Constructor<T> castConstructor(Class<T> instanceClazz, Constructor<?> ctor) {
return (Constructor<T>) ctor;
}
- private static void getClassesForPackage(String pckgname, List<Class<?>> classes) throws Exception {
+ static void getClassesForPackage(String pckgname, List<Class<?>> classes) throws Exception {
final ClassLoader cld = TestRandomChains.class.getClassLoader();
final String path = pckgname.replace('.', '/');
final Enumeration<URL> resources = cld.getResources(path);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestStopFilterFactory.java
similarity index 93%
rename from solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestStopFilterFactory.java
index 4dc1f9e..dc977c4 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestStopFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestStopFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,11 +17,10 @@
* limitations under the License.
*/
-
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
import java.util.Map;
import java.util.HashMap;
@@ -32,7 +32,7 @@
public class TestStopFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
assertTrue("loader is null and it shouldn't be", loader != null);
StopFilterFactory factory = new StopFilterFactory();
Map<String, String> args = new HashMap<String, String>();
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestTypeTokenFilterFactory.java
similarity index 93%
rename from solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestTypeTokenFilterFactory.java
index e8dee7c..bf4416f 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestTypeTokenFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestTypeTokenFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.core;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -16,12 +17,11 @@
* limitations under the License.
*/
-
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.NumericTokenStream;
import org.apache.lucene.analysis.util.InitializationException;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
import org.junit.Test;
import java.util.HashMap;
@@ -35,7 +35,7 @@
@Test
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
TypeTokenFilterFactory factory = new TypeTokenFilterFactory();
Map<String, String> args = new HashMap<String, String>();
args.put("types", "stoptypes-1.txt");
@@ -95,7 +95,7 @@
args.put("enablePositionIncrements", "false");
typeTokenFilterFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
typeTokenFilterFactory.init(args);
- typeTokenFilterFactory.inform(new SolrResourceLoader(null, null));
+ typeTokenFilterFactory.inform(new ResourceAsStreamResourceLoader(getClass()));
fail("not supplying 'types' parameter should cause an InitializationException");
} catch (InitializationException e) {
// everything ok
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-1.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-1.txt
new file mode 100644
index 0000000..8dfe809
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-1.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+foo
+bar
\ No newline at end of file
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-2.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-2.txt
new file mode 100644
index 0000000..646b7ff
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-2.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+junk
+more
\ No newline at end of file
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-snowball.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-snowball.txt
new file mode 100644
index 0000000..1c0c6f5
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stop-snowball.txt
@@ -0,0 +1,10 @@
+ | This is a file in snowball format, empty lines are ignored, '|' is a comment
+ | Additionally, multiple words can be on the same line, allowing stopwords to be
+ | arranged in tables (useful in some languages where they might inflect)
+
+ | fictitious table below
+
+|third person singular
+|Subject Object Possessive Reflexive
+he him his himself| masculine
+she her hers herself| feminine
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-1.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-1.txt
new file mode 100644
index 0000000..456348e
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-1.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+<NUM>
+<EMAIL>
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-2.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-2.txt
new file mode 100644
index 0000000..d8a3810
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/stoptypes-2.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+<HOST>
+<APOSTROPHE>
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestCzechStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cz/TestCzechStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestCzechStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/cz/TestCzechStemFilterFactory.java
index 2893d46..233dc74 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestCzechStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cz/TestCzechStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cz;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGermanLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGermanLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanLightStemFilterFactory.java
index 6524b36..d8bb63a 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGermanLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGermanMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGermanMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanMinimalStemFilterFactory.java
index 62f8a68..ddb1c67 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGermanMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGermanNormalizationFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGermanNormalizationFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanNormalizationFilterFactory.java
index ecfecc4..da27c89 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGermanNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanNormalizationFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGermanStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGermanStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilterFactory.java
index 39b1d78..47c0ee2 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGermanStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/de/TestGermanStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.de;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGreekLowerCaseFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGreekLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekLowerCaseFilterFactory.java
index b33a6eb..98c2f91 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGreekLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekLowerCaseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.el;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGreekStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGreekStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekStemFilterFactory.java
index 82a7e38..1c5e26f 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGreekStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/el/TestGreekStemFilterFactory.java
@@ -1,13 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.MockTokenizer;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.el.GreekLowerCaseFilter;
+package org.apache.lucene.analysis.el;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,6 +17,15 @@
* limitations under the License.
*/
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.el.GreekLowerCaseFilter;
+
/**
* Simple tests to ensure the Greek stem filter factory is working.
*/
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestEnglishMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestEnglishMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestEnglishMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestEnglishMinimalStemFilterFactory.java
index 806d036..11534c8 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestEnglishMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestEnglishMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestKStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestKStemFilterFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestKStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestKStemFilterFactory.java
index c94fc0f..900bbbd 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestKStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestKStemFilterFactory.java
@@ -1,11 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.MockTokenizer;
-import org.apache.lucene.analysis.TokenStream;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,6 +17,13 @@
* limitations under the License.
*/
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.TokenStream;
+
/**
* Simple tests to ensure the kstem filter factory is working.
*/
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPorterStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestPorterStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPorterStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestPorterStemFilterFactory.java
index bb3be89..9046bc6 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPorterStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/en/TestPorterStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.en;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestSpanishLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/es/TestSpanishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestSpanishLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/es/TestSpanishLightStemFilterFactory.java
index deba80b..db09c56 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestSpanishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/es/TestSpanishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.es;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPersianNormalizationFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fa/TestPersianNormalizationFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPersianNormalizationFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/fa/TestPersianNormalizationFilterFactory.java
index a189d55..2823439 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPersianNormalizationFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fa/TestPersianNormalizationFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fa;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestFinnishLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fi/TestFinnishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestFinnishLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/fi/TestFinnishLightStemFilterFactory.java
index c345f3f..5db0eee 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestFinnishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fi/TestFinnishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fi;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestElisionFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestElisionFilterFactory.java
similarity index 90%
rename from solr/core/src/test/org/apache/solr/analysis/TestElisionFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestElisionFilterFactory.java
index 95c061f..2c48d8e 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestElisionFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestElisionFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,8 +27,8 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
/**
* Simple tests to ensure the French elision filter factory is working.
@@ -42,7 +42,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
ElisionFilterFactory factory = new ElisionFilterFactory();
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
Map<String,String> args = new HashMap<String,String>();
args.put("articles", "frenchArticles.txt");
factory.init(args);
@@ -61,7 +61,7 @@
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Map<String, String> args = Collections.emptyMap();
factory.init(args);
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
factory.inform(loader);
TokenStream stream = factory.create(tokenizer);
assertTokenStreamContents(stream, new String[] { "avion" });
@@ -75,7 +75,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
ElisionFilterFactory factory = new ElisionFilterFactory();
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
Map<String,String> args = new HashMap<String,String>();
args.put("articles", "frenchArticles.txt");
args.put("ignoreCase", "true");
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestFrenchLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestFrenchLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchLightStemFilterFactory.java
index 784bf13..4a7b6d3 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestFrenchLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestFrenchMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestFrenchMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchMinimalStemFilterFactory.java
index db869c2..14b0dd9 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestFrenchMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/TestFrenchMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.fr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/frenchArticles.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/frenchArticles.txt
new file mode 100644
index 0000000..9141611
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/fr/frenchArticles.txt
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# A set of articles for testing the French Elision filter.
+# Requiring a text file is a bit weird here...
+l
+m
+t
+qu
+n
+s
+j
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestIrishLowerCaseFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ga/TestIrishLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestIrishLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/ga/TestIrishLowerCaseFilterFactory.java
index e429d91..71cb190 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestIrishLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ga/TestIrishLowerCaseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ga;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGalicianMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestGalicianMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianMinimalStemFilterFactory.java
index 8cd0933..15231b2 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGalicianMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.gl;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestGalicianStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianStemFilterFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestGalicianStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianStemFilterFactory.java
index 1eafa38..1b42a50 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestGalicianStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/gl/TestGalicianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.gl;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestHindiFilters.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hi/TestHindiFilters.java
similarity index 95%
rename from solr/core/src/test/org/apache/solr/analysis/TestHindiFilters.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/hi/TestHindiFilters.java
index 4c40a6f..14f942f 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestHindiFilters.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hi/TestHindiFilters.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hi;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +25,8 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.in.IndicNormalizationFilterFactory;
+import org.apache.lucene.analysis.standard.StandardTokenizerFactory;
/**
* Simple tests to ensure the Hindi filter Factories are working.
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestHungarianLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hu/TestHungarianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestHungarianLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/hu/TestHungarianLightStemFilterFactory.java
index ae79afc..813b0d6 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestHungarianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hu/TestHungarianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestHunspellStemFilterFactory.java
similarity index 85%
rename from solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestHunspellStemFilterFactory.java
index b5f33b4..32c056a 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestHunspellStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestHunspellStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.hunspell;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,8 +25,7 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.schema.IndexSchema;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
/**
* Simple tests to ensure the Hunspell stemmer loads from factory
@@ -35,11 +34,11 @@
public void testStemming() throws Exception {
HunspellStemFilterFactory factory = new HunspellStemFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- args.put("dictionary", "hunspell-test.dic");
- args.put("affix", "hunspell-test.aff");
+ args.put("dictionary", "test.dic");
+ args.put("affix", "test.aff");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new SolrResourceLoader("solr/collection1"));
+ factory.inform(new ResourceAsStreamResourceLoader(getClass()));
Reader reader = new StringReader("abc");
TokenStream stream = factory.create(new MockTokenizer(reader, MockTokenizer.WHITESPACE, false));
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestIndonesianStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/id/TestIndonesianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestIndonesianStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/id/TestIndonesianStemFilterFactory.java
index 1233d6b..4240bae 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestIndonesianStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/id/TestIndonesianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.id;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestItalianLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/it/TestItalianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestItalianLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/it/TestItalianLightStemFilterFactory.java
index 7787e0b..312759d 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestItalianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/it/TestItalianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.it;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestLatvianStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/lv/TestLatvianStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestLatvianStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/lv/TestLatvianStemFilterFactory.java
index 4415cde..7f2ba26 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestLatvianStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/lv/TestLatvianStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.lv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestCapitalizationFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestCapitalizationFilterFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestCapitalizationFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestCapitalizationFilterFactory.java
index 55f3c9f..e8a9273 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestCapitalizationFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestCapitalizationFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +26,6 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
-
/**
*
*/
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeepFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeepFilterFactory.java
index 1c10041..12da04d 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestKeepFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeepFilterFactory.java
@@ -1,4 +1,5 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,8 +19,8 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
import java.util.Map;
import java.util.HashMap;
@@ -31,7 +32,7 @@
public class TestKeepFilterFactory extends BaseTokenStreamTestCase {
public void testInform() throws Exception {
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new ResourceAsStreamResourceLoader(getClass());
assertTrue("loader is null and it shouldn't be", loader != null);
KeepWordFilterFactory factory = new KeepWordFilterFactory();
Map<String, String> args = new HashMap<String, String>();
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeywordMarkerFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeywordMarkerFilterFactory.java
index 7994f68..bea3bf9 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestKeywordMarkerFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestKeywordMarkerFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -29,7 +29,7 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
/**
* Simple tests to ensure the keyword marker filter factory is working.
@@ -40,7 +40,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
KeywordMarkerFilterFactory factory = new KeywordMarkerFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("cats");
args.put("protected", "protwords.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
@@ -55,7 +55,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
KeywordMarkerFilterFactory factory = new KeywordMarkerFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("cats");
args.put("protected", "protwords.txt");
args.put("ignoreCase", "true");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
diff --git a/solr/core/src/test/org/apache/solr/analysis/LengthFilterTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilterFactory.java
similarity index 93%
rename from solr/core/src/test/org/apache/solr/analysis/LengthFilterTest.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilterFactory.java
index 30f2f12..d1fc925 100644
--- a/solr/core/src/test/org/apache/solr/analysis/LengthFilterTest.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestLengthFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
/**
* Copyright 2004 The Apache Software Foundation
@@ -25,7 +25,7 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
-public class LengthFilterTest extends BaseTokenStreamTestCase {
+public class TestLengthFilterFactory extends BaseTokenStreamTestCase {
public void test() throws IOException {
LengthFilterFactory factory = new LengthFilterFactory();
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestRemoveDuplicatesTokenFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestRemoveDuplicatesTokenFilterFactory.java
index d098b26..dccf6f2 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestRemoveDuplicatesTokenFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestRemoveDuplicatesTokenFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestStemmerOverrideFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestStemmerOverrideFilterFactory.java
index 74de226..b9bd252 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestStemmerOverrideFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestStemmerOverrideFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.miscellaneous;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -29,7 +29,7 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
/**
* Simple tests to ensure the stemmer override filter factory is working.
@@ -41,7 +41,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
StemmerOverrideFilterFactory factory = new StemmerOverrideFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("dogs\tcat");
args.put("dictionary", "stemdict.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
@@ -56,7 +56,7 @@
Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
StemmerOverrideFilterFactory factory = new StemmerOverrideFilterFactory();
Map<String,String> args = new HashMap<String,String>();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("dogs\tcat");
args.put("dictionary", "stemdict.txt");
args.put("ignoreCase", "true");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestTrimFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilterFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestTrimFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilterFactory.java
index 9376422..db879b4 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestTrimFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.miscellaneous;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-1.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-1.txt
new file mode 100644
index 0000000..8dfe809
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-1.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+foo
+bar
\ No newline at end of file
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-2.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-2.txt
new file mode 100644
index 0000000..646b7ff
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/keep-2.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+junk
+more
\ No newline at end of file
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestNGramFilters.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramFilters.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestNGramFilters.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramFilters.java
index 3790250..cac9bc1 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestNGramFilters.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramFilters.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ngram;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestNorwegianLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestNorwegianLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianLightStemFilterFactory.java
index f8cbb53..3147136 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestNorwegianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.no;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestNorwegianMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestNorwegianMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianMinimalStemFilterFactory.java
index fb86cf6..6ff819d 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestNorwegianMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/no/TestNorwegianMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.no;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilterFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilterFactory.java
index 80cac56..a17917b 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceFilterFactory.java
index 0311043..8583137 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPatternReplaceFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternTokenizerFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternTokenizerFactory.java
index afe15d7..c97ec85 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPatternTokenizerFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternTokenizerFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.pattern;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestDelimitedPayloadTokenFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/payloads/TestDelimitedPayloadTokenFilterFactory.java
similarity index 92%
rename from solr/core/src/test/org/apache/solr/analysis/TestDelimitedPayloadTokenFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/payloads/TestDelimitedPayloadTokenFilterFactory.java
index 9644959..9e87d03 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestDelimitedPayloadTokenFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/payloads/TestDelimitedPayloadTokenFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.payloads;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
@@ -29,7 +29,7 @@
import org.apache.lucene.analysis.payloads.PayloadHelper;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
public class TestDelimitedPayloadTokenFilterFactory extends BaseTokenStreamTestCase {
@@ -38,7 +38,7 @@
args.put(DelimitedPayloadTokenFilterFactory.ENCODER_ATTR, "float");
DelimitedPayloadTokenFilterFactory factory = new DelimitedPayloadTokenFilterFactory();
factory.init(args);
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("solr/collection1");
factory.inform(loader);
TokenStream input = new MockTokenizer(new StringReader("the|0.1 quick|0.1 red|0.1"), MockTokenizer.WHITESPACE, false);
@@ -61,7 +61,7 @@
args.put(DelimitedPayloadTokenFilterFactory.DELIMITER_ATTR, "*");
DelimitedPayloadTokenFilterFactory factory = new DelimitedPayloadTokenFilterFactory();
factory.init(args);
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("solr/collection1");
factory.inform(loader);
TokenStream input = new MockTokenizer(new StringReader("the*0.1 quick*0.1 red*0.1"), MockTokenizer.WHITESPACE, false);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPortugueseLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseLightStemFilterFactory.java
index aa5c009..35783c2 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseMinimalStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseMinimalStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPortugueseMinimalStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseMinimalStemFilterFactory.java
index 695b54c..7cf107a 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseMinimalStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseMinimalStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestPortugueseStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseStemFilterFactory.java
index 13e9719..6d3fa44 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPortugueseStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pt/TestPortugueseStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.pt;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestReverseStringFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/reverse/TestReverseStringFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestReverseStringFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/reverse/TestReverseStringFilterFactory.java
index 20c6d4d..5bbdee7 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestReverseStringFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/reverse/TestReverseStringFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.reverse;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestRussianLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ru/TestRussianLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestRussianLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/ru/TestRussianLightStemFilterFactory.java
index 810ffbd..7ef2e69 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestRussianLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ru/TestRussianLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ru;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestShingleFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/TestShingleFilterFactory.java
similarity index 99%
rename from solr/core/src/test/org/apache/solr/analysis/TestShingleFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/TestShingleFilterFactory.java
index ca85836..a8bd5d1 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestShingleFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/shingle/TestShingleFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.shingle;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/SnowballPorterFilterFactoryTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballPorterFilterFactory.java
similarity index 82%
rename from solr/core/src/test/org/apache/solr/analysis/SnowballPorterFilterFactoryTest.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballPorterFilterFactory.java
index c906551..df5c291 100644
--- a/solr/core/src/test/org/apache/solr/analysis/SnowballPorterFilterFactoryTest.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/snowball/TestSnowballPorterFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.snowball;
/**
* Copyright 2004 The Apache Software Foundation
@@ -21,21 +21,18 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.common.util.StrUtils;
-import org.apache.solr.core.SolrResourceLoader;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
import org.tartarus.snowball.ext.EnglishStemmer;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.ArrayList;
-public class SnowballPorterFilterFactoryTest extends BaseTokenStreamTestCase {
+public class TestSnowballPorterFilterFactory extends BaseTokenStreamTestCase {
public void test() throws IOException {
EnglishStemmer stemmer = new EnglishStemmer();
@@ -53,12 +50,23 @@
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new LinesMockSolrResourceLoader(new ArrayList<String>()));
+ factory.inform(new StringMockResourceLoader(""));
Tokenizer tokenizer = new MockTokenizer(
- new StringReader(StrUtils.join(Arrays.asList(test), ' ')), MockTokenizer.WHITESPACE, false);
+ new StringReader(join(test, ' ')), MockTokenizer.WHITESPACE, false);
TokenStream stream = factory.create(tokenizer);
assertTokenStreamContents(stream, gold);
}
+
+ String join(String[] stuff, char sep) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < stuff.length; i++) {
+ if (i > 0) {
+ sb.append(sep);
+ }
+ sb.append(stuff[i]);
+ }
+ return sb.toString();
+ }
class LinesMockSolrResourceLoader implements ResourceLoader {
List<String> lines;
@@ -85,7 +93,7 @@
*/
public void testProtected() throws Exception {
SnowballPorterFilterFactory factory = new SnowballPorterFilterFactory();
- ResourceLoader loader = new SolrResourceLoader("solr/collection1");
+ ResourceLoader loader = new StringMockResourceLoader("ridding");
Map<String,String> args = new HashMap<String,String>();
args.put("protected", "protwords.txt");
args.put("language", "English");
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestStandardFactories.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestStandardFactories.java
similarity index 94%
rename from solr/core/src/test/org/apache/solr/analysis/TestStandardFactories.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestStandardFactories.java
index cd3dcb0..c88abbe 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestStandardFactories.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestStandardFactories.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.standard;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,6 +27,11 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.core.LetterTokenizerFactory;
+import org.apache.lucene.analysis.core.LowerCaseTokenizerFactory;
+import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
+import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
/**
* Simple tests to ensure the standard lucene factories are working.
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestUAX29URLEmailTokenizerFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestUAX29URLEmailTokenizerFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestUAX29URLEmailTokenizerFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestUAX29URLEmailTokenizerFactory.java
index d1a1c1c..e49d2e2 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestUAX29URLEmailTokenizerFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/standard/TestUAX29URLEmailTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.standard;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,7 +25,6 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.util.Version;
/**
* A few tests based on org.apache.lucene.analysis.TestUAX29URLEmailTokenizer
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestSwedishLightStemFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/sv/TestSwedishLightStemFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestSwedishLightStemFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/sv/TestSwedishLightStemFilterFactory.java
index b059fc1..fdc0685 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestSwedishLightStemFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/sv/TestSwedishLightStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.sv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilterFactory.java
similarity index 70%
rename from solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilterFactory.java
index d1521ac..9e9196f 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestSynonymFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.synonym;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,21 +17,16 @@
* limitations under the License.
*/
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.StringReader;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.synonym.SynonymFilter;
-import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.core.SolrResourceLoader;
+import org.apache.lucene.analysis.util.ResourceAsStreamResourceLoader;
+import org.apache.lucene.analysis.util.StringMockResourceLoader;
public class TestSynonymFilterFactory extends BaseTokenStreamTestCase {
/** test that we can parse and use the solr syn file */
@@ -41,7 +36,7 @@
args.put("synonyms", "synonyms.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new SolrResourceLoader("solr/collection1"));
+ factory.inform(new ResourceAsStreamResourceLoader(getClass()));
TokenStream ts = factory.create(new MockTokenizer(new StringReader("GB"), MockTokenizer.WHITESPACE, false));
assertTrue(ts instanceof SynonymFilter);
assertTokenStreamContents(ts,
@@ -56,28 +51,8 @@
args.put("synonyms", "synonyms.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new StringMockSolrResourceLoader("")); // empty file!
+ factory.inform(new StringMockResourceLoader("")); // empty file!
TokenStream ts = factory.create(new MockTokenizer(new StringReader("GB"), MockTokenizer.WHITESPACE, false));
assertTokenStreamContents(ts, new String[] { "GB" });
}
-
- private class StringMockSolrResourceLoader implements ResourceLoader {
- String text;
-
- StringMockSolrResourceLoader(String text) {
- this.text = text;
- }
-
- public List<String> getLines(String resource) throws IOException {
- return Arrays.asList(text.split("\n"));
- }
-
- public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
- return null;
- }
-
- public InputStream openResource(String resource) throws IOException {
- return new ByteArrayInputStream(text.getBytes("UTF-8"));
- }
- }
}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/synonyms.txt b/lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/synonyms.txt
new file mode 100644
index 0000000..b0e31cb
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/synonym/synonyms.txt
@@ -0,0 +1,31 @@
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#-----------------------------------------------------------------------
+#some test synonym mappings unlikely to appear in real input text
+aaa => aaaa
+bbb => bbbb1 bbbb2
+ccc => cccc1,cccc2
+a\=>a => b\=>b
+a\,a => b\,b
+fooaaa,baraaa,bazaaa
+
+# Some synonym groups specific to this example
+GB,gib,gigabyte,gigabytes
+MB,mib,megabyte,megabytes
+Television, Televisions, TV, TVs
+#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming
+#after us won't split it into two words.
+
+# Synonym mappings can be used for spelling correction too
+pixima => pixma
+
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestThaiWordFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiWordFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestThaiWordFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiWordFilterFactory.java
index 006d365..af54aa0 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestThaiWordFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiWordFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.th;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestTurkishLowerCaseFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilterFactory.java
similarity index 97%
rename from solr/core/src/test/org/apache/solr/analysis/TestTurkishLowerCaseFilterFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilterFactory.java
index b3d9305..8348a91 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestTurkishLowerCaseFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/tr/TestTurkishLowerCaseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.tr;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/ResourceAsStreamResourceLoader.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/ResourceAsStreamResourceLoader.java
new file mode 100644
index 0000000..3d06aa4
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/ResourceAsStreamResourceLoader.java
@@ -0,0 +1,84 @@
+package org.apache.lucene.analysis.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.CodingErrorAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.util.IOUtils;
+
+public class ResourceAsStreamResourceLoader implements ResourceLoader {
+ Class<?> clazz;
+
+ public ResourceAsStreamResourceLoader(Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public InputStream openResource(String resource) throws IOException {
+ return clazz.getResourceAsStream(resource);
+ }
+
+ @Override
+ public List<String> getLines(String resource) throws IOException {
+ BufferedReader input = null;
+ ArrayList<String> lines;
+ try {
+ input = new BufferedReader(new InputStreamReader(openResource(resource),
+ IOUtils.CHARSET_UTF_8.newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT)
+ .onUnmappableCharacter(CodingErrorAction.REPORT)));
+
+ lines = new ArrayList<String>();
+ for (String word=null; (word=input.readLine())!=null;) {
+ // skip initial bom marker
+ if (lines.isEmpty() && word.length() > 0 && word.charAt(0) == '\uFEFF')
+ word = word.substring(1);
+ // skip comments
+ if (word.startsWith("#")) continue;
+ word=word.trim();
+ // skip blank lines
+ if (word.length()==0) continue;
+ lines.add(word);
+ }
+ } catch (CharacterCodingException ex) {
+ throw new RuntimeException("Error loading resource (wrong encoding?): " + resource, ex);
+ } finally {
+ if (input != null)
+ input.close();
+ }
+ return lines;
+ }
+
+ // TODO: do this subpackages thing... wtf is that?
+ @Override
+ public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
+ try {
+ Class<? extends T> clazz = Class.forName(cname).asSubclass(expectedType);
+ return clazz.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/StringMockResourceLoader.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/StringMockResourceLoader.java
new file mode 100644
index 0000000..2a73121
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/StringMockResourceLoader.java
@@ -0,0 +1,51 @@
+package org.apache.lucene.analysis.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+
+/** Fake resource loader for tests: works if you want to fake reading a single file */
+public class StringMockResourceLoader implements ResourceLoader {
+ String text;
+
+ public StringMockResourceLoader(String text) {
+ this.text = text;
+ }
+
+ public List<String> getLines(String resource) throws IOException {
+ return Arrays.asList(text.split("\n"));
+ }
+
+ // TODO: do this subpackages thing... wtf is that?
+ public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
+ try {
+ Class<? extends T> clazz = Class.forName(cname).asSubclass(expectedType);
+ return clazz.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public InputStream openResource(String resource) throws IOException {
+ return new ByteArrayInputStream(text.getBytes("UTF-8"));
+ }
+}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/TestAnalysisSPILoader.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/TestAnalysisSPILoader.java
new file mode 100644
index 0000000..6e5c336
--- /dev/null
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/util/TestAnalysisSPILoader.java
@@ -0,0 +1,180 @@
+package org.apache.lucene.analysis.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory;
+import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
+import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
+import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilterFactory;
+import org.apache.lucene.util.LuceneTestCase;
+
+public class TestAnalysisSPILoader extends LuceneTestCase {
+
+ public void testLookupTokenizer() {
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.forName("Whitespace").getClass());
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.forName("WHITESPACE").getClass());
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.forName("whitespace").getClass());
+ }
+
+ public void testBogusLookupTokenizer() {
+ try {
+ TokenizerFactory.forName("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ TokenizerFactory.forName("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testLookupTokenizerClass() {
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.lookupClass("Whitespace"));
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.lookupClass("WHITESPACE"));
+ assertEquals(WhitespaceTokenizerFactory.class, TokenizerFactory.lookupClass("whitespace"));
+ }
+
+ public void testBogusLookupTokenizerClass() {
+ try {
+ TokenizerFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ TokenizerFactory.lookupClass("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testAvailableTokenizers() {
+ assertTrue(TokenizerFactory.availableTokenizers().contains("whitespace"));
+ }
+
+ public void testLookupTokenFilter() {
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.forName("Lowercase").getClass());
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.forName("LOWERCASE").getClass());
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.forName("lowercase").getClass());
+
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.forName("RemoveDuplicates").getClass());
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.forName("REMOVEDUPLICATES").getClass());
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.forName("removeduplicates").getClass());
+ }
+
+ public void testBogusLookupTokenFilter() {
+ try {
+ TokenFilterFactory.forName("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ TokenFilterFactory.forName("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testLookupTokenFilterClass() {
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.lookupClass("Lowercase"));
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.lookupClass("LOWERCASE"));
+ assertEquals(LowerCaseFilterFactory.class, TokenFilterFactory.lookupClass("lowercase"));
+
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.lookupClass("RemoveDuplicates"));
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.lookupClass("REMOVEDUPLICATES"));
+ assertEquals(RemoveDuplicatesTokenFilterFactory.class, TokenFilterFactory.lookupClass("removeduplicates"));
+ }
+
+ public void testBogusLookupTokenFilterClass() {
+ try {
+ TokenFilterFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ TokenFilterFactory.lookupClass("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testAvailableTokenFilters() {
+ assertTrue(TokenFilterFactory.availableTokenFilters().contains("lowercase"));
+ assertTrue(TokenFilterFactory.availableTokenFilters().contains("removeduplicates"));
+ }
+
+ public void testLookupCharFilter() {
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.forName("HTMLStrip").getClass());
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.forName("HTMLSTRIP").getClass());
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.forName("htmlstrip").getClass());
+ }
+
+ public void testBogusLookupCharFilter() {
+ try {
+ CharFilterFactory.forName("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ CharFilterFactory.forName("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testLookupCharFilterClass() {
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.lookupClass("HTMLStrip"));
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.lookupClass("HTMLSTRIP"));
+ assertEquals(HTMLStripCharFilterFactory.class, CharFilterFactory.lookupClass("htmlstrip"));
+ }
+
+ public void testBogusLookupCharFilterClass() {
+ try {
+ CharFilterFactory.lookupClass("sdfsdfsdfdsfsdfsdf");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+
+ try {
+ CharFilterFactory.lookupClass("!(**#$U*#$*");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ //
+ }
+ }
+
+ public void testAvailableCharFilters() {
+ assertTrue(CharFilterFactory.availableCharFilters().contains("htmlstrip"));
+ }
+}
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestWikipediaTokenizerFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
similarity index 96%
rename from solr/core/src/test/org/apache/solr/analysis/TestWikipediaTokenizerFactory.java
rename to lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
index 7dda1e3..8cedacb 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestWikipediaTokenizerFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
@@ -1,12 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.wikipedia.WikipediaTokenizer;
+package org.apache.lucene.analysis.wikipedia;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +17,14 @@
* limitations under the License.
*/
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.wikipedia.WikipediaTokenizer;
+
/**
* Simple tests to ensure the wikipedia tokenizer is working.
*/
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUFoldingFilterFactory.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUFoldingFilterFactory.java
similarity index 96%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUFoldingFilterFactory.java
rename to lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUFoldingFilterFactory.java
index 0fdf711..05b3cd4 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUFoldingFilterFactory.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUFoldingFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUFoldingFilter;
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUNormalizer2FilterFactory.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUNormalizer2FilterFactory.java
similarity index 92%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUNormalizer2FilterFactory.java
rename to lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUNormalizer2FilterFactory.java
index 0aef42f..fdb115c 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUNormalizer2FilterFactory.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUNormalizer2FilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,9 +22,8 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUNormalizer2Filter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import com.ibm.icu.text.FilteredNormalizer2;
@@ -66,7 +65,7 @@
else if (mode.equals("decompose"))
normalizer = Normalizer2.getInstance(null, name, Normalizer2.Mode.DECOMPOSE);
else
- throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid mode: " + mode);
+ throw new InitializationException("Invalid mode: " + mode);
String filter = args.get("filter");
if (filter != null) {
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTransformFilterFactory.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilterFactory.java
similarity index 88%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTransformFilterFactory.java
rename to lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilterFactory.java
index 695c1ba..8b0e3c8 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTransformFilterFactory.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/ICUTransformFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,9 +22,8 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUTransformFilter;
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import com.ibm.icu.text.Transliterator;
@@ -48,7 +47,7 @@
super.init(args);
String id = args.get("id");
if (id == null) {
- throw new SolrException(ErrorCode.SERVER_ERROR, "id is required.");
+ throw new InitializationException("id is required.");
}
int dir;
@@ -58,7 +57,7 @@
else if (direction.equalsIgnoreCase("reverse"))
dir = Transliterator.REVERSE;
else
- throw new SolrException(ErrorCode.SERVER_ERROR, "invalid direction: " + direction);
+ throw new InitializationException("invalid direction: " + direction);
transliterator = Transliterator.getInstance(id, dir);
}
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTokenizerFactory.java b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
similarity index 95%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTokenizerFactory.java
rename to lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
index 061bc3c..d3c39cb 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/ICUTokenizerFactory.java
+++ b/lucene/analysis/icu/src/java/org/apache/lucene/analysis/icu/segmentation/ICUTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu.segmentation;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..cae49ca
--- /dev/null
+++ b/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.icu.ICUFoldingFilterFactory
+org.apache.lucene.analysis.icu.ICUNormalizer2FilterFactory
+org.apache.lucene.analysis.icu.ICUTransformFilterFactory
diff --git a/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory b/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
new file mode 100644
index 0000000..cc90ed5
--- /dev/null
+++ b/lucene/analysis/icu/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.icu.segmentation.ICUTokenizerFactory
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUFoldingFilterFactory.java b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUFoldingFilterFactory.java
similarity index 97%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUFoldingFilterFactory.java
rename to lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUFoldingFilterFactory.java
index dc30038..f43b30d 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUFoldingFilterFactory.java
+++ b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUFoldingFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUNormalizer2FilterFactory.java b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUNormalizer2FilterFactory.java
similarity index 97%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUNormalizer2FilterFactory.java
rename to lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUNormalizer2FilterFactory.java
index 0b1adf2..397afd0 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUNormalizer2FilterFactory.java
+++ b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUNormalizer2FilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTransformFilterFactory.java b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUTransformFilterFactory.java
similarity index 98%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTransformFilterFactory.java
rename to lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUTransformFilterFactory.java
index 6092cdf..52b1973 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTransformFilterFactory.java
+++ b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/TestICUTransformFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTokenizerFactory.java b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestICUTokenizerFactory.java
similarity index 96%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTokenizerFactory.java
rename to lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestICUTokenizerFactory.java
index 21e6afb..1314db6 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestICUTokenizerFactory.java
+++ b/lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/segmentation/TestICUTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.icu.segmentation;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapaneseBaseFormFilterFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseBaseFormFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/JapaneseBaseFormFilterFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseBaseFormFilterFactory.java
index 600991f..dfd3677 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapaneseBaseFormFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseBaseFormFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapaneseIterationMarkCharFilterFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseIterationMarkCharFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/JapaneseIterationMarkCharFilterFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseIterationMarkCharFilterFactory.java
index 68f3b10..ed6b7a3 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapaneseIterationMarkCharFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseIterationMarkCharFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapaneseKatakanaStemFilterFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaStemFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/JapaneseKatakanaStemFilterFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaStemFilterFactory.java
index 602a5f1..8904ce8 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapaneseKatakanaStemFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapanesePartOfSpeechStopFilterFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java
similarity index 82%
rename from solr/core/src/java/org/apache/solr/analysis/JapanesePartOfSpeechStopFilterFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java
index ce91b63..236fbd0 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapanesePartOfSpeechStopFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapanesePartOfSpeechStopFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -45,12 +45,15 @@
public void inform(ResourceLoader loader) {
String stopTagFiles = args.get("tags");
enablePositionIncrements = getBoolean("enablePositionIncrements", false);
+ stopTags = null;
try {
CharArraySet cas = getWordSet(loader, stopTagFiles, false);
- stopTags = new HashSet<String>();
- for (Object element : cas) {
- char chars[] = (char[]) element;
- stopTags.add(new String(chars));
+ if (cas != null) {
+ stopTags = new HashSet<String>();
+ for (Object element : cas) {
+ char chars[] = (char[]) element;
+ stopTags.add(new String(chars));
+ }
}
} catch (IOException e) {
throw new InitializationException("IOException thrown while loading tags", e);
@@ -58,6 +61,7 @@
}
public TokenStream create(TokenStream stream) {
- return new JapanesePartOfSpeechStopFilter(enablePositionIncrements, stream, stopTags);
+ // if stoptags is null, it means the file is empty
+ return stopTags == null ? stream : new JapanesePartOfSpeechStopFilter(enablePositionIncrements, stream, stopTags);
}
}
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapaneseReadingFormFilterFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseReadingFormFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/JapaneseReadingFormFilterFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseReadingFormFilterFactory.java
index ba0c541..2d984d9 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapaneseReadingFormFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseReadingFormFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/JapaneseTokenizerFactory.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/JapaneseTokenizerFactory.java
rename to lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
index 769d304..f5e0c81 100644
--- a/solr/core/src/java/org/apache/solr/analysis/JapaneseTokenizerFactory.java
+++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory
new file mode 100644
index 0000000..ab4764a
--- /dev/null
+++ b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.CharFilterFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.ja.JapaneseIterationMarkCharFilterFactory
diff --git a/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..50a5ec7
--- /dev/null
+++ b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.ja.JapaneseBaseFormFilterFactory
+org.apache.lucene.analysis.ja.JapaneseKatakanaStemFilterFactory
+org.apache.lucene.analysis.ja.JapanesePartOfSpeechStopFilterFactory
+org.apache.lucene.analysis.ja.JapaneseReadingFormFilterFactory
diff --git a/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
new file mode 100644
index 0000000..a7b9fcc
--- /dev/null
+++ b/lucene/analysis/kuromoji/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.ja.JapaneseTokenizerFactory
diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.java
new file mode 100644
index 0000000..1a5d98d
--- /dev/null
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/StringMockResourceLoader.java
@@ -0,0 +1,53 @@
+package org.apache.lucene.analysis.ja;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.lucene.analysis.util.ResourceLoader;
+
+/** Fake resource loader for tests: works if you want to fake reading a single file */
+class StringMockResourceLoader implements ResourceLoader {
+ String text;
+
+ public StringMockResourceLoader(String text) {
+ this.text = text;
+ }
+
+ public List<String> getLines(String resource) throws IOException {
+ return Arrays.asList(text.split("\n"));
+ }
+
+ // TODO: do this subpackages thing... wtf is that?
+ public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
+ try {
+ Class<? extends T> clazz = Class.forName(cname).asSubclass(expectedType);
+ return clazz.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public InputStream openResource(String resource) throws IOException {
+ return new ByteArrayInputStream(text.getBytes("UTF-8"));
+ }
+}
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseBaseFormFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java
similarity index 92%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapaneseBaseFormFilterFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java
index 6bb5c26..0fd28ed 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseBaseFormFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseBaseFormFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,7 +24,6 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
/**
* Simple tests for {@link JapaneseBaseFormFilterFactory}
@@ -35,7 +34,7 @@
tokenizerFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Map<String, String> args = Collections.emptyMap();
tokenizerFactory.init(args);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
TokenStream ts = tokenizerFactory.create(new StringReader("それはまだ実験段階にあります"));
JapaneseBaseFormFilterFactory factory = new JapaneseBaseFormFilterFactory();
ts = factory.create(ts);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseIterationMarkCharFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapaneseIterationMarkCharFilterFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java
index 8bde4c6..8975337 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseIterationMarkCharFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseIterationMarkCharFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,7 +21,6 @@
import org.apache.lucene.analysis.CharFilter;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
import java.io.IOException;
import java.io.StringReader;
@@ -30,7 +29,7 @@
import java.util.Map;
/**
- * Simple tests for {@link org.apache.solr.analysis.JapaneseIterationMarkCharFilterFactory}
+ * Simple tests for {@link JapaneseIterationMarkCharFilterFactory}
*/
public class TestJapaneseIterationMarkCharFilterFactory extends BaseTokenStreamTestCase {
@@ -46,7 +45,7 @@
JapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();
Map<String, String> tokenizerArgs = Collections.emptyMap();
tokenizerFactory.init(tokenizerArgs);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();
Map<String, String> filterArgs = Collections.emptyMap();
@@ -63,7 +62,7 @@
JapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();
Map<String, String> tokenizerArgs = Collections.emptyMap();
tokenizerFactory.init(tokenizerArgs);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();
Map<String, String> filterArgs = new HashMap<String, String>();
@@ -82,7 +81,7 @@
JapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();
Map<String, String> tokenizerArgs = Collections.emptyMap();
tokenizerFactory.init(tokenizerArgs);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
JapaneseIterationMarkCharFilterFactory filterFactory = new JapaneseIterationMarkCharFilterFactory();
Map<String, String> filterArgs = new HashMap<String, String>();
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseKatakanaStemFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java
similarity index 93%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapaneseKatakanaStemFilterFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java
index 020f91f..b3fa8dc 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseKatakanaStemFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseKatakanaStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,7 +19,6 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
import java.io.IOException;
import java.io.StringReader;
@@ -34,7 +33,7 @@
JapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();
Map<String, String> tokenizerArgs = Collections.emptyMap();
tokenizerFactory.init(tokenizerArgs);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
TokenStream tokenStream = tokenizerFactory.create(
new StringReader("明後日パーティーに行く予定がある。図書館で資料をコピーしました。")
);
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapanesePartOfSpeechStopFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java
similarity index 90%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapanesePartOfSpeechStopFilterFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java
index 2338c8c..fdfc901 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapanesePartOfSpeechStopFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapanesePartOfSpeechStopFilterFactory.java
@@ -1,14 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,6 +17,15 @@
* limitations under the License.
*/
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.TokenStream;
+
/**
* Simple tests for {@link JapanesePartOfSpeechStopFilterFactory}
*/
@@ -40,14 +39,14 @@
tokenizerFactory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Map<String, String> tokenizerArgs = Collections.emptyMap();
tokenizerFactory.init(tokenizerArgs);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
TokenStream ts = tokenizerFactory.create(new StringReader("私は制限スピードを超える。"));
JapanesePartOfSpeechStopFilterFactory factory = new JapanesePartOfSpeechStopFilterFactory();
Map<String,String> args = new HashMap<String,String>();
args.put("tags", "stoptags.txt");
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
factory.init(args);
- factory.inform(new StringMockSolrResourceLoader(tags));
+ factory.inform(new StringMockResourceLoader(tags));
ts = factory.create(ts);
assertTokenStreamContents(ts,
new String[] { "私", "は", "制限", "スピード", "を" }
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseReadingFormFilterFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java
similarity index 91%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapaneseReadingFormFilterFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java
index d46f9b1..52dc275 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseReadingFormFilterFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseReadingFormFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,7 +19,6 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
import java.io.IOException;
import java.io.StringReader;
@@ -34,7 +33,7 @@
JapaneseTokenizerFactory tokenizerFactory = new JapaneseTokenizerFactory();
Map<String, String> args = Collections.emptyMap();
tokenizerFactory.init(args);
- tokenizerFactory.inform(new SolrResourceLoader(null, null));
+ tokenizerFactory.inform(new StringMockResourceLoader(""));
TokenStream tokenStream = tokenizerFactory.create(new StringReader("先ほどベルリンから来ました。"));
JapaneseReadingFormFilterFactory filterFactory = new JapaneseReadingFormFilterFactory();
assertTokenStreamContents(filterFactory.create(tokenStream),
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java
similarity index 92%
rename from solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java
rename to lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java
index ae6b40b..3b26dca 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestJapaneseTokenizerFactory.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.ja;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,7 +25,6 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.solr.core.SolrResourceLoader;
/**
* Simple tests for {@link JapaneseTokenizerFactory}
@@ -36,7 +35,7 @@
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Map<String, String> args = Collections.emptyMap();
factory.init(args);
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new StringMockResourceLoader(""));
TokenStream ts = factory.create(new StringReader("これは本ではない"));
assertTokenStreamContents(ts,
new String[] { "これ", "は", "本", "で", "は", "ない" },
@@ -53,7 +52,7 @@
factory.setLuceneMatchVersion(TEST_VERSION_CURRENT);
Map<String, String> args = Collections.emptyMap();
factory.init(args);
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new StringMockResourceLoader(""));
TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));
assertTokenStreamContents(ts,
new String[] { "シニア", "シニアソフトウェアエンジニア", "ソフトウェア", "エンジニア" }
@@ -68,7 +67,7 @@
Map<String,String> args = new HashMap<String,String>();
args.put("mode", "normal");
factory.init(args);
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new StringMockResourceLoader(""));
TokenStream ts = factory.create(new StringReader("シニアソフトウェアエンジニア"));
assertTokenStreamContents(ts,
new String[] { "シニアソフトウェアエンジニア" }
@@ -89,7 +88,7 @@
Map<String,String> args = new HashMap<String,String>();
args.put("userDictionary", "userdict.txt");
factory.init(args);
- factory.inform(new StringMockSolrResourceLoader(userDict));
+ factory.inform(new StringMockResourceLoader(userDict));
TokenStream ts = factory.create(new StringReader("関西国際空港に行った"));
assertTokenStreamContents(ts,
new String[] { "関西", "国際", "空港", "に", "行っ", "た" }
@@ -104,7 +103,7 @@
Map<String,String> args = new HashMap<String,String>();
args.put("discardPunctuation", "false");
factory.init(args);
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new StringMockResourceLoader(""));
TokenStream ts = factory.create(
new StringReader("今ノルウェーにいますが、来週の頭日本に戻ります。楽しみにしています!お寿司が食べたいな。。。")
);
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/MorfologikFilterFactory.java b/lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java
similarity index 97%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/MorfologikFilterFactory.java
rename to lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java
index 4f79f1a..4e3b9e4 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/MorfologikFilterFactory.java
+++ b/lucene/analysis/morfologik/src/java/org/apache/lucene/analysis/morfologik/MorfologikFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.morfologik;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
diff --git a/lucene/analysis/morfologik/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/morfologik/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..804e566
--- /dev/null
+++ b/lucene/analysis/morfologik/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.morfologik.MorfologikFilterFactory
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestMorfologikFilterFactory.java b/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java
similarity index 96%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestMorfologikFilterFactory.java
rename to lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java
index 30b3ba0..7a5d0de 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestMorfologikFilterFactory.java
+++ b/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/morfologik/TestMorfologikFilterFactory.java
@@ -1,12 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.core.WhitespaceTokenizer;
+package org.apache.lucene.analysis.morfologik;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +17,14 @@
* limitations under the License.
*/
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.core.WhitespaceTokenizer;
+
/**
* Test for {@link MorfologikFilterFactory}.
*/
diff --git a/solr/core/src/java/org/apache/solr/analysis/BeiderMorseFilterFactory.java b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/BeiderMorseFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/BeiderMorseFilterFactory.java
rename to lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/BeiderMorseFilterFactory.java
index 82caa4a..6502def 100644
--- a/solr/core/src/java/org/apache/solr/analysis/BeiderMorseFilterFactory.java
+++ b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/BeiderMorseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.phonetic;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/java/org/apache/solr/analysis/DoubleMetaphoneFilterFactory.java b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DoubleMetaphoneFilterFactory.java
similarity index 97%
rename from solr/core/src/java/org/apache/solr/analysis/DoubleMetaphoneFilterFactory.java
rename to lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DoubleMetaphoneFilterFactory.java
index 87042b9..df465c9 100644
--- a/solr/core/src/java/org/apache/solr/analysis/DoubleMetaphoneFilterFactory.java
+++ b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/DoubleMetaphoneFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.phonetic;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import java.util.Map;
diff --git a/solr/core/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilterFactory.java
similarity index 98%
rename from solr/core/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java
rename to lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilterFactory.java
index 4df05a4..a0a4646 100644
--- a/solr/core/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java
+++ b/lucene/analysis/phonetic/src/java/org/apache/lucene/analysis/phonetic/PhoneticFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.phonetic;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
diff --git a/lucene/analysis/phonetic/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/phonetic/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..fe78873
--- /dev/null
+++ b/lucene/analysis/phonetic/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.phonetic.BeiderMorseFilterFactory
+org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilterFactory
+org.apache.lucene.analysis.phonetic.PhoneticFilterFactory
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestBeiderMorseFilterFactory.java b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestBeiderMorseFilterFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestBeiderMorseFilterFactory.java
rename to lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestBeiderMorseFilterFactory.java
index eaff03d..ba01dde 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestBeiderMorseFilterFactory.java
+++ b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestBeiderMorseFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.phonetic;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/core/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestDoubleMetaphoneFilterFactory.java
similarity index 95%
rename from solr/core/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java
rename to lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestDoubleMetaphoneFilterFactory.java
index 7b08dbb..abb3192 100644
--- a/solr/core/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java
+++ b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestDoubleMetaphoneFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.phonetic;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.analysis;
import java.io.StringReader;
import java.util.HashMap;
@@ -26,7 +27,7 @@
import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-public class DoubleMetaphoneFilterFactoryTest extends BaseTokenStreamTestCase {
+public class TestDoubleMetaphoneFilterFactory extends BaseTokenStreamTestCase {
public void testDefaults() throws Exception {
DoubleMetaphoneFilterFactory factory = new DoubleMetaphoneFilterFactory();
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestPhoneticFilterFactory.java
similarity index 98%
rename from solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java
rename to lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestPhoneticFilterFactory.java
index dc7809d..3a13b5e 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestPhoneticFilterFactory.java
+++ b/lucene/analysis/phonetic/src/test/org/apache/lucene/analysis/phonetic/TestPhoneticFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.lucene.analysis.phonetic;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseSentenceTokenizerFactory.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseSentenceTokenizerFactory.java
similarity index 96%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseSentenceTokenizerFactory.java
rename to lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseSentenceTokenizerFactory.java
index 0df634f..f02adc4 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseSentenceTokenizerFactory.java
+++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseSentenceTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cn.smart;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseWordTokenFilterFactory.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseWordTokenFilterFactory.java
similarity index 96%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseWordTokenFilterFactory.java
rename to lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseWordTokenFilterFactory.java
index 3742fec..8fdb73b 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/SmartChineseWordTokenFilterFactory.java
+++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/SmartChineseWordTokenFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cn.smart;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..adf7f77
--- /dev/null
+++ b/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.cn.smart.SmartChineseWordTokenFilterFactory
diff --git a/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory b/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
new file mode 100644
index 0000000..2a8370c
--- /dev/null
+++ b/lucene/analysis/smartcn/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.cn.smart.SmartChineseSentenceTokenizerFactory
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestSmartChineseFactories.java b/lucene/analysis/smartcn/src/test/org/apache/lucene/analysis/cn/smart/TestSmartChineseFactories.java
similarity index 97%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestSmartChineseFactories.java
rename to lucene/analysis/smartcn/src/test/org/apache/lucene/analysis/cn/smart/TestSmartChineseFactories.java
index 35fb947..bd626a5 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestSmartChineseFactories.java
+++ b/lucene/analysis/smartcn/src/test/org/apache/lucene/analysis/cn/smart/TestSmartChineseFactories.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.cn.smart;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/StempelPolishStemFilterFactory.java b/lucene/analysis/stempel/src/java/org/apache/lucene/analysis/stempel/StempelPolishStemFilterFactory.java
similarity index 83%
rename from solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/StempelPolishStemFilterFactory.java
rename to lucene/analysis/stempel/src/java/org/apache/lucene/analysis/stempel/StempelPolishStemFilterFactory.java
index 3340692..8ef0430 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/analysis/StempelPolishStemFilterFactory.java
+++ b/lucene/analysis/stempel/src/java/org/apache/lucene/analysis/stempel/StempelPolishStemFilterFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.analysis;
+package org.apache.lucene.analysis.stempel;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -23,8 +23,7 @@
import org.apache.lucene.analysis.stempel.StempelFilter;
import org.apache.lucene.analysis.stempel.StempelStemmer;
import org.apache.lucene.analysis.util.ResourceLoader;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.egothor.stemmer.Trie;
@@ -34,7 +33,7 @@
*/
public class StempelPolishStemFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {
private Trie stemmer = null;
- private static final String STEMTABLE = "org/apache/lucene/analysis/pl/stemmer_20000.tbl";
+ private static final String STEMTABLE = "/org/apache/lucene/analysis/pl/stemmer_20000.tbl";
public TokenStream create(TokenStream input) {
return new StempelFilter(input, new StempelStemmer(stemmer));
@@ -44,7 +43,7 @@
try {
stemmer = StempelStemmer.load(loader.openResource(STEMTABLE));
} catch (IOException e) {
- throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load stem table: " + STEMTABLE);
+ throw new InitializationException("Could not load stem table: " + STEMTABLE, e);
}
}
}
diff --git a/lucene/analysis/stempel/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory b/lucene/analysis/stempel/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
new file mode 100644
index 0000000..f5e77c3
--- /dev/null
+++ b/lucene/analysis/stempel/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenFilterFactory
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.stempel.StempelPolishStemFilterFactory
diff --git a/lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/ResourceAsStreamResourceLoader.java b/lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/ResourceAsStreamResourceLoader.java
new file mode 100644
index 0000000..d3cf2df
--- /dev/null
+++ b/lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/ResourceAsStreamResourceLoader.java
@@ -0,0 +1,85 @@
+package org.apache.lucene.analysis.stempel;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.CodingErrorAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.util.ResourceLoader;
+import org.apache.lucene.util.IOUtils;
+
+public class ResourceAsStreamResourceLoader implements ResourceLoader {
+ Class<?> clazz;
+
+ public ResourceAsStreamResourceLoader(Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ @Override
+ public InputStream openResource(String resource) throws IOException {
+ return clazz.getResourceAsStream(resource);
+ }
+
+ @Override
+ public List<String> getLines(String resource) throws IOException {
+ BufferedReader input = null;
+ ArrayList<String> lines;
+ try {
+ input = new BufferedReader(new InputStreamReader(openResource(resource),
+ IOUtils.CHARSET_UTF_8.newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT)
+ .onUnmappableCharacter(CodingErrorAction.REPORT)));
+
+ lines = new ArrayList<String>();
+ for (String word=null; (word=input.readLine())!=null;) {
+ // skip initial bom marker
+ if (lines.isEmpty() && word.length() > 0 && word.charAt(0) == '\uFEFF')
+ word = word.substring(1);
+ // skip comments
+ if (word.startsWith("#")) continue;
+ word=word.trim();
+ // skip blank lines
+ if (word.length()==0) continue;
+ lines.add(word);
+ }
+ } catch (CharacterCodingException ex) {
+ throw new RuntimeException("Error loading resource (wrong encoding?): " + resource, ex);
+ } finally {
+ if (input != null)
+ input.close();
+ }
+ return lines;
+ }
+
+ // TODO: do this subpackages thing... wtf is that?
+ @Override
+ public <T> T newInstance(String cname, Class<T> expectedType, String... subpackages) {
+ try {
+ Class<? extends T> clazz = Class.forName(cname).asSubclass(expectedType);
+ return clazz.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestStempelPolishStemFilterFactory.java b/lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/TestStempelPolishStemFilterFactory.java
similarity index 91%
rename from solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestStempelPolishStemFilterFactory.java
rename to lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/TestStempelPolishStemFilterFactory.java
index 46e8308..f37a7bf 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/analysis/TestStempelPolishStemFilterFactory.java
+++ b/lucene/analysis/stempel/src/test/org/apache/lucene/analysis/stempel/TestStempelPolishStemFilterFactory.java
@@ -1,11 +1,4 @@
-package org.apache.solr.analysis;
-
-import java.io.StringReader;
-
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.core.WhitespaceTokenizer;
-import org.apache.solr.core.SolrResourceLoader;
+package org.apache.lucene.analysis.stempel;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,6 +17,12 @@
* limitations under the License.
*/
+import java.io.StringReader;
+
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.core.WhitespaceTokenizer;
+
/**
* Tests for {@link StempelPolishStemFilterFactory}
*/
@@ -31,7 +30,7 @@
public void testBasics() throws Exception {
StringReader document = new StringReader("studenta studenci");
StempelPolishStemFilterFactory factory = new StempelPolishStemFilterFactory();
- factory.inform(new SolrResourceLoader(null, null));
+ factory.inform(new ResourceAsStreamResourceLoader(getClass()));
TokenStream ts = factory.create(new WhitespaceTokenizer(TEST_VERSION_CURRENT, document));
assertTokenStreamContents(ts,
new String[] { "student", "student" });
diff --git a/solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMAAnnotationsTokenizerFactory.java b/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java
similarity index 85%
rename from solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMAAnnotationsTokenizerFactory.java
rename to lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java
index 8467b79..3adb65a 100644
--- a/solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMAAnnotationsTokenizerFactory.java
+++ b/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMAAnnotationsTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.uima.analysis;
+package org.apache.lucene.analysis.uima;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,6 +18,7 @@
*/
import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.analysis.uima.UIMAAnnotationsTokenizer;
@@ -37,6 +38,9 @@
super.init(args);
descriptorPath = args.get("descriptorPath");
tokenType = args.get("tokenType");
+ if (descriptorPath == null || tokenType == null) {
+ throw new InitializationException("Both descriptorPath and tokenType are mandatory");
+ }
}
@Override
diff --git a/solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMATypeAwareAnnotationsTokenizerFactory.java b/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java
similarity index 84%
rename from solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMATypeAwareAnnotationsTokenizerFactory.java
rename to lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java
index 1efda6b..57b5183 100644
--- a/solr/contrib/uima/src/java/org/apache/solr/uima/analysis/UIMATypeAwareAnnotationsTokenizerFactory.java
+++ b/lucene/analysis/uima/src/java/org/apache/lucene/analysis/uima/UIMATypeAwareAnnotationsTokenizerFactory.java
@@ -1,4 +1,4 @@
-package org.apache.solr.uima.analysis;
+package org.apache.lucene.analysis.uima;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,6 +19,7 @@
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.uima.UIMATypeAwareAnnotationsTokenizer;
+import org.apache.lucene.analysis.util.InitializationException;
import org.apache.lucene.analysis.util.TokenizerFactory;
import java.io.Reader;
@@ -39,6 +40,9 @@
descriptorPath = args.get("descriptorPath");
tokenType = args.get("tokenType");
featurePath = args.get("featurePath");
+ if (descriptorPath == null || tokenType == null || featurePath == null) {
+ throw new InitializationException("descriptorPath, tokenType, and featurePath are mandatory");
+ }
}
@Override
diff --git a/lucene/analysis/uima/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory b/lucene/analysis/uima/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
new file mode 100644
index 0000000..eeea38a
--- /dev/null
+++ b/lucene/analysis/uima/src/resources/META-INF/services/org.apache.lucene.analysis.util.TokenizerFactory
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.lucene.analysis.uima.UIMAAnnotationsTokenizerFactory
+org.apache.lucene.analysis.uima.UIMATypeAwareAnnotationsTokenizerFactory
diff --git a/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java b/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java
index eb142dc..54173af 100644
--- a/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java
+++ b/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java
@@ -22,7 +22,7 @@
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.Set;
-import java.util.ServiceLoader;
+import java.util.ServiceConfigurationError;
/**
* Helper class for loading named SPIs from classpath (e.g. Codec, PostingsFormat).
@@ -32,63 +32,52 @@
public final class NamedSPILoader<S extends NamedSPILoader.NamedSPI> implements Iterable<S> {
private final Map<String,S> services;
-
- /** This field is a hack for LuceneTestCase to get access
- * to the modifiable map (to work around bugs in IBM J9) */
- @SuppressWarnings("unused")
- @Deprecated
- // Hackidy-Häck-Hack for bugs in IBM J9 ServiceLoader
- private final Map<String,S> modifiableServices;
-
private final Class<S> clazz;
public NamedSPILoader(Class<S> clazz) {
this.clazz = clazz;
- final ServiceLoader<S> loader = ServiceLoader.load(clazz);
+ final SPIClassIterator<S> loader = SPIClassIterator.get(clazz);
final LinkedHashMap<String,S> services = new LinkedHashMap<String,S>();
- for (final S service : loader) {
- final String name = service.getName();
- // only add the first one for each name, later services will be ignored
- // this allows to place services before others in classpath to make
- // them used instead of others
- if (!services.containsKey(name)) {
- assert checkServiceName(name);
- services.put(name, service);
+ while (loader.hasNext()) {
+ final Class<? extends S> c = loader.next();
+ try {
+ final S service = c.newInstance();
+ final String name = service.getName();
+ // only add the first one for each name, later services will be ignored
+ // this allows to place services before others in classpath to make
+ // them used instead of others
+ if (!services.containsKey(name)) {
+ checkServiceName(name);
+ services.put(name, service);
+ }
+ } catch (Exception e) {
+ throw new ServiceConfigurationError("Cannot instantiate SPI class: " + c.getName(), e);
}
}
- this.modifiableServices = services; // hack, remove when IBM J9 is fixed!
this.services = Collections.unmodifiableMap(services);
}
/**
* Validates that a service name meets the requirements of {@link NamedSPI}
*/
- public static boolean checkServiceName(String name) {
+ public static void checkServiceName(String name) {
// based on harmony charset.java
if (name.length() >= 128) {
throw new IllegalArgumentException("Illegal service name: '" + name + "' is too long (must be < 128 chars).");
}
- for (int i = 0; i < name.length(); i++) {
+ for (int i = 0, len = name.length(); i < len; i++) {
char c = name.charAt(i);
- if (!isLetter(c) && !isDigit(c)) {
+ if (!isLetterOrDigit(c)) {
throw new IllegalArgumentException("Illegal service name: '" + name + "' must be simple ascii alphanumeric.");
}
}
- return true;
}
- /*
- * Checks whether a character is a letter (ascii) which are defined in the spec.
+ /**
+ * Checks whether a character is a letter or digit (ascii) which are defined in the spec.
*/
- private static boolean isLetter(char c) {
- return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
- }
-
- /*
- * Checks whether a character is a digit (ascii) which are defined in the spec.
- */
- private static boolean isDigit(char c) {
- return ('0' <= c && c <= '9');
+ private static boolean isLetterOrDigit(char c) {
+ return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9');
}
public S lookup(String name) {
diff --git a/lucene/core/src/java/org/apache/lucene/util/SPIClassIterator.java b/lucene/core/src/java/org/apache/lucene/util/SPIClassIterator.java
new file mode 100644
index 0000000..b9c136a
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/util/SPIClassIterator.java
@@ -0,0 +1,138 @@
+package org.apache.lucene.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.NoSuchElementException;
+import java.util.ServiceConfigurationError;
+
+/**
+ * Helper class for loading SPI classes from classpath (META-INF files).
+ * This is a light impl of {@link java.util.ServiceLoader} but is guaranteed to
+ * be bug-free regarding classpath order and does not instantiate or initialize
+ * the classes found.
+ *
+ * @lucene.internal
+ */
+public final class SPIClassIterator<S> implements Iterator<Class<? extends S>> {
+ private static final String META_INF_SERVICES = "META-INF/services/";
+
+ private final Class<S> clazz;
+ private final ClassLoader loader;
+ private final Enumeration<URL> profilesEnum;
+ private Iterator<String> linesIterator;
+
+ public static <S> SPIClassIterator<S> get(Class<S> clazz) {
+ return new SPIClassIterator<S>(clazz, Thread.currentThread().getContextClassLoader());
+ }
+
+ public static <S> SPIClassIterator<S> get(Class<S> clazz, ClassLoader loader) {
+ return new SPIClassIterator<S>(clazz, loader);
+ }
+
+ private SPIClassIterator(Class<S> clazz, ClassLoader loader) {
+ if (loader == null)
+ throw new IllegalArgumentException("You must provide a ClassLoader.");
+ this.clazz = clazz;
+ this.loader = loader;
+ try {
+ this.profilesEnum = loader.getResources(META_INF_SERVICES + clazz.getName());
+ } catch (IOException ioe) {
+ throw new ServiceConfigurationError("Error loading SPI profiles for type " + clazz.getName() + " from classpath", ioe);
+ }
+ this.linesIterator = Collections.<String>emptySet().iterator();
+ }
+
+ private boolean loadNextProfile() {
+ ArrayList<String> lines = null;
+ while (profilesEnum.hasMoreElements()) {
+ if (lines != null) {
+ lines.clear();
+ } else {
+ lines = new ArrayList<String>();
+ }
+ final URL url = profilesEnum.nextElement();
+ try {
+ final InputStream in = url.openStream();
+ IOException priorE = null;
+ try {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(in, IOUtils.CHARSET_UTF_8));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ final int pos = line.indexOf('#');
+ if (pos >= 0) {
+ line = line.substring(0, pos);
+ }
+ line = line.trim();
+ if (line.length() > 0) {
+ lines.add(line);
+ }
+ }
+ } catch (IOException ioe) {
+ priorE = ioe;
+ } finally {
+ IOUtils.closeWhileHandlingException(priorE, in);
+ }
+ } catch (IOException ioe) {
+ throw new ServiceConfigurationError("Error loading SPI class list from URL: " + url, ioe);
+ }
+ if (!lines.isEmpty()) {
+ this.linesIterator = lines.iterator();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return linesIterator.hasNext() || loadNextProfile();
+ }
+
+ @Override
+ public Class<? extends S> next() {
+ // hasNext() implicitely loads the next profile, so it is essential to call this here!
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ assert linesIterator.hasNext();
+ final String c = linesIterator.next();
+ try {
+ // don't initialize the class (pass false as 2nd parameter):
+ return Class.forName(c, false, loader).asSubclass(clazz);
+ } catch (ClassNotFoundException cnfe) {
+ throw new ServiceConfigurationError(String.format(Locale.ROOT, "A SPI class of type %s with classname %s does not exist, "+
+ "please fix the file '%s%1$s' in your classpath.", clazz.getName(), c, META_INF_SERVICES));
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
index 9c63a90..236d106 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
@@ -87,33 +87,6 @@
restoreProperties.put("solr.solr.home", System.getProperty("solr.solr.home"));
restoreProperties.put("solr.data.dir", System.getProperty("solr.data.dir"));
- // enable the Lucene 3.x PreflexRW codec explicitly, to work around bugs in IBM J9 / Harmony ServiceLoader:
- try {
- final java.lang.reflect.Field spiLoaderField = Codec.class.getDeclaredField("loader");
- spiLoaderField.setAccessible(true);
- final Object spiLoader = spiLoaderField.get(null);
- final java.lang.reflect.Field modifiableServicesField = NamedSPILoader.class.getDeclaredField("modifiableServices");
- modifiableServicesField.setAccessible(true);
- /* note: re-enable this if we make a Lucene4x impersonator
- @SuppressWarnings({"unchecked","rawtypes"}) final Map<String,Codec> serviceMap =
- (Map) modifiableServicesField.get(spiLoader);
- if (!(Codec.forName("Lucene3x") instanceof PreFlexRWCodec)) {
- if (Constants.JAVA_VENDOR.startsWith("IBM")) {
- // definitely a buggy version
- System.err.println("ERROR: Your VM's java.util.ServiceLoader implementation is buggy"+
- " and does not respect classpath order, please report this to the vendor.");
- } else {
- // could just be a classpath issue
- System.err.println("ERROR: fix your classpath to have tests-framework.jar before lucene-core.jar!"+
- " If you have already done this, then your VM's java.util.ServiceLoader implementation is buggy"+
- " and does not respect classpath order, please report this to the vendor.");
- }
- serviceMap.put("Lucene3x", new PreFlexRWCodec());
- } */
- } catch (Exception e) {
- throw new RuntimeException("Cannot access internals of Codec and NamedSPILoader classes", e);
- }
-
// if verbose: print some debugging stuff about which codecs are loaded.
if (VERBOSE) {
Set<String> codecs = Codec.availableCodecs();
diff --git a/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/SolrStopwordsCarrot2LexicalDataFactory.java b/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/SolrStopwordsCarrot2LexicalDataFactory.java
index 880d232..0628231 100644
--- a/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/SolrStopwordsCarrot2LexicalDataFactory.java
+++ b/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/SolrStopwordsCarrot2LexicalDataFactory.java
@@ -23,8 +23,8 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.analysis.util.TokenFilterFactory;
-import org.apache.solr.analysis.CommonGramsFilterFactory;
-import org.apache.solr.analysis.StopFilterFactory;
+import org.apache.lucene.analysis.commongrams.CommonGramsFilterFactory;
+import org.apache.lucene.analysis.core.StopFilterFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.schema.IndexSchema;
import org.carrot2.core.LanguageCode;
diff --git a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml
index aa279ce..13a9c9f 100644
--- a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml
+++ b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml
@@ -299,14 +299,14 @@
<fieldType name="uima_sentences" class="solr.TextField" positionIncrementGap="100">
<analyzer>
- <tokenizer class="org.apache.solr.uima.analysis.UIMAAnnotationsTokenizerFactory"
+ <tokenizer class="solr.UIMAAnnotationsTokenizerFactory"
descriptorPath="/uima/AggregateSentenceAE.xml" tokenType="org.apache.uima.SentenceAnnotation"/>
</analyzer>
</fieldType>
<fieldType name="uima_nouns" class="solr.TextField" positionIncrementGap="100">
<analyzer>
- <tokenizer class="org.apache.solr.uima.analysis.UIMATypeAwareAnnotationsTokenizerFactory"
+ <tokenizer class="solr.UIMATypeAwareAnnotationsTokenizerFactory"
descriptorPath="/uima/AggregateSentenceAE.xml" tokenType="org.apache.uima.TokenAnnotation"
featurePath="posTag"/>
<filter class="solr.TypeTokenFilterFactory" types="uima/stoptypes.txt" />
diff --git a/solr/core/src/java/org/apache/solr/analysis/LegacyHTMLStripCharFilterFactory.java b/solr/core/src/java/org/apache/solr/analysis/LegacyHTMLStripCharFilterFactory.java
index 4e81778..6be66d0 100644
--- a/solr/core/src/java/org/apache/solr/analysis/LegacyHTMLStripCharFilterFactory.java
+++ b/solr/core/src/java/org/apache/solr/analysis/LegacyHTMLStripCharFilterFactory.java
@@ -20,6 +20,7 @@
import java.io.Reader;
+import org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory;
import org.apache.lucene.analysis.util.CharFilterFactory;
/**
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
index e4df2a0..7fae246 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
@@ -29,11 +29,16 @@
import java.net.URLClassLoader;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;
+import org.apache.lucene.analysis.util.AnalysisSPILoader;
+import org.apache.lucene.util.WeakIdentityMap;
import org.apache.solr.common.ResourceLoader;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.apache.solr.handler.component.ShardHandlerFactory;
@@ -366,8 +371,15 @@
/*
* A static map of short class name to fully qualified class name
*/
- private static Map<String, String> classNameCache = new ConcurrentHashMap<String, String>();
+ private static final Map<String, String> classNameCache = new ConcurrentHashMap<String, String>();
+ // A static map of AnalysisSPILoaders, keyed by ClassLoader used (because it can change during Solr lifetime) and expected base class:
+ private static final WeakIdentityMap<ClassLoader, Map<Class<?>,AnalysisSPILoader<?>>> expectedTypesSPILoaders = WeakIdentityMap.newConcurrentHashMap();
+
+ // Using this pattern, legacy analysis components from previous Solr versions are identified and delegated to SPI loader:
+ private static final Pattern legacyAnalysisPattern =
+ Pattern.compile("((\\Q"+base+".analysis.\\E)|(\\Q"+project+".\\E))([\\p{L}_$][\\p{L}\\p{N}_$]+?)(TokenFilter|Filter|Tokenizer|CharFilter)Factory");
+
/**
* This method loads a class either with it's FQN or a short-name (solr.class-simplename or class-simplename).
* It tries to load the class with the name that is given first and if it fails, it tries all the known
@@ -394,6 +406,32 @@
}
}
Class<? extends T> clazz = null;
+
+ // first try legacy analysis patterns, now replaced by Lucene's Analysis package:
+ final Matcher m = legacyAnalysisPattern.matcher(cname);
+ if (m.matches()) {
+ log.trace("Trying to load class from analysis SPI");
+ // retrieve the map of classLoader -> expectedType -> SPI from cache / regenerate cache
+ Map<Class<?>,AnalysisSPILoader<?>> spiLoaders = expectedTypesSPILoaders.get(classLoader);
+ if (spiLoaders == null) {
+ spiLoaders = new IdentityHashMap<Class<?>,AnalysisSPILoader<?>>(3);
+ spiLoaders.put(CharFilterFactory.class, CharFilterFactory.getSPILoader(classLoader));
+ spiLoaders.put(TokenizerFactory.class, TokenizerFactory.getSPILoader(classLoader));
+ spiLoaders.put(TokenFilterFactory.class, TokenFilterFactory.getSPILoader(classLoader));
+ expectedTypesSPILoaders.put(classLoader, spiLoaders);
+ }
+ @SuppressWarnings("unchecked") final AnalysisSPILoader<? extends T> loader =
+ (AnalysisSPILoader<? extends T>) spiLoaders.get(expectedType);
+ if (loader != null) {
+ // it's a correct expected type for analysis! Let's go on!
+ try {
+ return clazz = loader.lookupClass(m.group(4));
+ } catch (IllegalArgumentException ex) {
+ // ok, we fall back to legacy loading
+ }
+ }
+ }
+
// first try cname == full name
try {
return Class.forName(cname, true, classLoader).asSubclass(expectedType);
diff --git a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
index 0adac8e..5c2073f 100644
--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java
@@ -19,9 +19,9 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
import org.apache.lucene.analysis.util.*;
import org.apache.lucene.util.Version;
-import org.apache.solr.analysis.KeywordTokenizerFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.common.SolrException;
import org.apache.solr.util.DOMUtil;
diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
index 97ec2a0..5c2fcda 100755
--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
@@ -27,6 +27,7 @@
import java.util.Set;
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.core.StopFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.queries.function.BoostedQuery;
import org.apache.lucene.queries.function.FunctionQuery;
@@ -36,7 +37,6 @@
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
-import org.apache.solr.analysis.StopFilterFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.search.SolrQueryParser.MagicFieldName;
import org.apache.solr.common.params.DisMaxParams;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java b/solr/core/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
index c9b4392..c9885ca 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
+++ b/solr/core/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java
@@ -20,6 +20,7 @@
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.synonym.SynonymFilterFactory;
import org.apache.lucene.analysis.util.ResourceLoader;
import java.io.ByteArrayInputStream;
diff --git a/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java b/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java
index ed4d782..b77104c 100644
--- a/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java
+++ b/solr/core/src/test/org/apache/solr/analysis/TestWordDelimiterFilterFactory.java
@@ -1,3 +1,5 @@
+package org.apache.solr.analysis;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +17,6 @@
* limitations under the License.
*/
-package org.apache.solr.analysis;
-
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
@@ -25,6 +25,7 @@
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilterFactory;
import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.core.SolrResourceLoader;
import org.junit.BeforeClass;
@@ -33,6 +34,7 @@
/**
* New WordDelimiterFilter tests... most of the tests are in ConvertedLegacyTest
*/
+// TODO: add a low-level test for this factory
public class TestWordDelimiterFilterFactory extends SolrTestCaseJ4 {
@BeforeClass
diff --git a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
index 8fafab4..f78a1b6 100644
--- a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
@@ -20,8 +20,8 @@
import junit.framework.Assert;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.solr.analysis.KeywordTokenizerFactory;
-import org.apache.solr.analysis.NGramFilterFactory;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.ngram.NGramFilterFactory;
import org.apache.solr.common.SolrException;
import org.apache.solr.handler.admin.LukeRequestHandler;
import org.apache.solr.handler.component.FacetComponent;
diff --git a/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java b/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java
index 0fb48f8..2631b7b 100644
--- a/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java
@@ -18,6 +18,12 @@
*/
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.charfilter.MappingCharFilterFactory;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
+import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
+import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
+import org.apache.lucene.analysis.miscellaneous.TrimFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.analysis.*;