From 26b9faddb20f00e9ef642a63d236e744d936b042 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 10 May 2010 17:37:45 +0000 Subject: [PATCH] LUCENE-2413: consolidate SynonymFilter into analyzers module git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@942827 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/analysis/synonym}/SynonymFilter.java | 4 +--- .../apache/lucene/analysis/synonym}/SynonymMap.java | 12 ++++++------ .../lucene/analysis/synonym}/TestSynonymFilter.java | 9 +++++---- .../apache/solr/analysis/SynonymFilterFactory.java | 2 ++ .../apache/solr/analysis/TestMultiWordSynonyms.java | 2 ++ .../org/apache/solr/analysis/TestSynonymMap.java | 1 + 6 files changed, 17 insertions(+), 13 deletions(-) rename {solr/src/java/org/apache/solr/analysis => modules/analysis/common/src/java/org/apache/lucene/analysis/synonym}/SynonymFilter.java (99%) rename {solr/src/java/org/apache/solr/analysis => modules/analysis/common/src/java/org/apache/lucene/analysis/synonym}/SynonymMap.java (95%) rename {solr/src/test/org/apache/solr/analysis => modules/analysis/common/src/test/org/apache/lucene/analysis/synonym}/TestSynonymFilter.java (97%) diff --git a/solr/src/java/org/apache/solr/analysis/SynonymFilter.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilter.java similarity index 99% rename from solr/src/java/org/apache/solr/analysis/SynonymFilter.java rename to modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilter.java index 376fad329d9..4dcc21178b3 100644 --- a/solr/src/java/org/apache/solr/analysis/SynonymFilter.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymFilter.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.solr.analysis; +package org.apache.lucene.analysis.synonym; import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenFilter; @@ -38,8 +38,6 @@ import java.util.LinkedList; * to retain absolute positions after merging with the synonym tokenstream. *

* Generated synonyms will start at the same position as the first matched source token. - * - * @version $Id$ */ public final class SynonymFilter extends TokenFilter { diff --git a/solr/src/java/org/apache/solr/analysis/SynonymMap.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java similarity index 95% rename from solr/src/java/org/apache/solr/analysis/SynonymMap.java rename to modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java index b72763378ad..0cd94c2e8eb 100644 --- a/solr/src/java/org/apache/solr/analysis/SynonymMap.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.solr.analysis; +package org.apache.lucene.analysis.synonym; import org.apache.lucene.analysis.CharArrayMap; import org.apache.lucene.analysis.Token; @@ -23,13 +23,13 @@ import org.apache.lucene.util.Version; import java.util.*; -/** Mapping rules for use with {@link org.apache.solr.analysis.SynonymFilter} - * - * @version $Id$ +/** Mapping rules for use with {@link SynonymFilter} */ public class SynonymMap { - CharArrayMap submap; // recursive: Map - Token[] synonyms; + /** @lucene.internal */ + public CharArrayMap submap; // recursive: Map + /** @lucene.internal */ + public Token[] synonyms; int flags; static final int INCLUDE_ORIG=0x01; diff --git a/solr/src/test/org/apache/solr/analysis/TestSynonymFilter.java b/modules/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilter.java similarity index 97% rename from solr/src/test/org/apache/solr/analysis/TestSynonymFilter.java rename to modules/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilter.java index e724a837a53..25e23cdb698 100644 --- a/solr/src/test/org/apache/solr/analysis/TestSynonymFilter.java +++ b/modules/analysis/common/src/test/org/apache/lucene/analysis/synonym/TestSynonymFilter.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.solr.analysis; +package org.apache.lucene.analysis.synonym; +import org.apache.lucene.analysis.BaseTokenStreamTestCase; import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; @@ -38,7 +39,7 @@ import java.util.List; /** * @version $Id$ */ -public class TestSynonymFilter extends BaseTokenTestCase { +public class TestSynonymFilter extends BaseTokenStreamTestCase { static List strings(String str) { String[] arr = str.split(" "); @@ -47,14 +48,14 @@ public class TestSynonymFilter extends BaseTokenTestCase { static void assertTokenizesTo(SynonymMap dict, String input, String expected[]) throws IOException { - Tokenizer tokenizer = new WhitespaceTokenizer(DEFAULT_VERSION, new StringReader(input)); + Tokenizer tokenizer = new WhitespaceTokenizer(TEST_VERSION_CURRENT, new StringReader(input)); SynonymFilter stream = new SynonymFilter(tokenizer, dict); assertTokenStreamContents(stream, expected); } static void assertTokenizesTo(SynonymMap dict, String input, String expected[], int posIncs[]) throws IOException { - Tokenizer tokenizer = new WhitespaceTokenizer(DEFAULT_VERSION, new StringReader(input)); + Tokenizer tokenizer = new WhitespaceTokenizer(TEST_VERSION_CURRENT, new StringReader(input)); SynonymFilter stream = new SynonymFilter(tokenizer, dict); assertTokenStreamContents(stream, expected, posIncs); } diff --git a/solr/src/java/org/apache/solr/analysis/SynonymFilterFactory.java b/solr/src/java/org/apache/solr/analysis/SynonymFilterFactory.java index c6ae83271bc..d0d094bc2f4 100644 --- a/solr/src/java/org/apache/solr/analysis/SynonymFilterFactory.java +++ b/solr/src/java/org/apache/solr/analysis/SynonymFilterFactory.java @@ -18,6 +18,8 @@ package org.apache.solr.analysis; import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.synonym.SynonymFilter; +import org.apache.lucene.analysis.synonym.SynonymMap; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.solr.common.ResourceLoader; import org.apache.solr.common.util.StrUtils; diff --git a/solr/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java b/solr/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java index 54032490611..77f3e5b3afa 100644 --- a/solr/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java +++ b/solr/src/test/org/apache/solr/analysis/TestMultiWordSynonyms.java @@ -1,6 +1,8 @@ package org.apache.solr.analysis; import org.apache.lucene.analysis.WhitespaceTokenizer; +import org.apache.lucene.analysis.synonym.SynonymFilter; +import org.apache.lucene.analysis.synonym.SynonymMap; import org.junit.Test; import java.io.IOException; diff --git a/solr/src/test/org/apache/solr/analysis/TestSynonymMap.java b/solr/src/test/org/apache/solr/analysis/TestSynonymMap.java index 2cc3519231c..27b4103bf46 100644 --- a/solr/src/test/org/apache/solr/analysis/TestSynonymMap.java +++ b/solr/src/test/org/apache/solr/analysis/TestSynonymMap.java @@ -25,6 +25,7 @@ import java.util.Map; import junit.framework.TestCase; import org.apache.lucene.analysis.Token; +import org.apache.lucene.analysis.synonym.SynonymMap; public class TestSynonymMap extends TestCase {