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
This commit is contained in:
Robert Muir 2010-05-10 17:37:45 +00:00
parent e85c2774f7
commit 26b9faddb2
6 changed files with 17 additions and 13 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License. * 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.Token;
import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenFilter;
@ -38,8 +38,6 @@ import java.util.LinkedList;
* to retain absolute positions after merging with the synonym tokenstream. * to retain absolute positions after merging with the synonym tokenstream.
* <p> * <p>
* Generated synonyms will start at the same position as the first matched source token. * Generated synonyms will start at the same position as the first matched source token.
*
* @version $Id$
*/ */
public final class SynonymFilter extends TokenFilter { public final class SynonymFilter extends TokenFilter {

View File

@ -15,7 +15,7 @@
* limitations under the License. * 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.CharArrayMap;
import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.Token;
@ -23,13 +23,13 @@ import org.apache.lucene.util.Version;
import java.util.*; import java.util.*;
/** Mapping rules for use with {@link org.apache.solr.analysis.SynonymFilter} /** Mapping rules for use with {@link SynonymFilter}
*
* @version $Id$
*/ */
public class SynonymMap { public class SynonymMap {
CharArrayMap<SynonymMap> submap; // recursive: Map<String, SynonymMap> /** @lucene.internal */
Token[] synonyms; public CharArrayMap<SynonymMap> submap; // recursive: Map<String, SynonymMap>
/** @lucene.internal */
public Token[] synonyms;
int flags; int flags;
static final int INCLUDE_ORIG=0x01; static final int INCLUDE_ORIG=0x01;

View File

@ -15,8 +15,9 @@
* limitations under the License. * 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.Token;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.Tokenizer;
@ -38,7 +39,7 @@ import java.util.List;
/** /**
* @version $Id$ * @version $Id$
*/ */
public class TestSynonymFilter extends BaseTokenTestCase { public class TestSynonymFilter extends BaseTokenStreamTestCase {
static List<String> strings(String str) { static List<String> strings(String str) {
String[] arr = str.split(" "); String[] arr = str.split(" ");
@ -47,14 +48,14 @@ public class TestSynonymFilter extends BaseTokenTestCase {
static void assertTokenizesTo(SynonymMap dict, String input, static void assertTokenizesTo(SynonymMap dict, String input,
String expected[]) throws IOException { 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); SynonymFilter stream = new SynonymFilter(tokenizer, dict);
assertTokenStreamContents(stream, expected); assertTokenStreamContents(stream, expected);
} }
static void assertTokenizesTo(SynonymMap dict, String input, static void assertTokenizesTo(SynonymMap dict, String input,
String expected[], int posIncs[]) throws IOException { 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); SynonymFilter stream = new SynonymFilter(tokenizer, dict);
assertTokenStreamContents(stream, expected, posIncs); assertTokenStreamContents(stream, expected, posIncs);
} }

View File

@ -18,6 +18,8 @@
package org.apache.solr.analysis; package org.apache.solr.analysis;
import org.apache.lucene.analysis.TokenStream; 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.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.solr.common.ResourceLoader; import org.apache.solr.common.ResourceLoader;
import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.StrUtils;

View File

@ -1,6 +1,8 @@
package org.apache.solr.analysis; package org.apache.solr.analysis;
import org.apache.lucene.analysis.WhitespaceTokenizer; 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 org.junit.Test;
import java.io.IOException; import java.io.IOException;

View File

@ -25,6 +25,7 @@ import java.util.Map;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.synonym.SynonymMap;
public class TestSynonymMap extends TestCase { public class TestSynonymMap extends TestCase {