From 80e8bfbbc9e4932d557d016a4f566f40459cb50d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Wed, 4 Nov 2009 22:37:01 +0000 Subject: [PATCH] LUCENE-2031: Move patternanalyzer from memory contrib into analyzers git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@832889 13f79535-47bb-0310-9956-ffa450edef68 --- contrib/CHANGES.txt | 5 ++++- .../analysis/miscellaneous}/PatternAnalyzer.java | 2 +- .../analysis/miscellaneous}/PatternAnalyzerTest.java | 2 +- .../org/apache/lucene/index/memory/MemoryIndex.java | 11 ++++------- .../apache/lucene/index/memory/MemoryIndexTest.java | 1 - 5 files changed, 10 insertions(+), 11 deletions(-) rename contrib/{memory/src/java/org/apache/lucene/index/memory => analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous}/PatternAnalyzer.java (99%) rename contrib/{memory/src/test/org/apache/lucene/index/memory => analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous}/PatternAnalyzerTest.java (99%) diff --git a/contrib/CHANGES.txt b/contrib/CHANGES.txt index 732243932fa..d043587aedf 100644 --- a/contrib/CHANGES.txt +++ b/contrib/CHANGES.txt @@ -96,7 +96,10 @@ Build * LUCENE-1904: Moved wordnet-based synonym support from contrib/memory into contrib/wordnet. (Robert Muir) - + + * LUCENE-2031: Moved PatternAnalyzer from contrib/memory into + contrib/analyzers/common, under miscellaneous. (Robert Muir) + Test Cases ======================= Release 2.9.0 2009-09-23 ======================= diff --git a/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PatternAnalyzer.java similarity index 99% rename from contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java rename to contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PatternAnalyzer.java index 98e23beb893..e32a7eb4355 100644 --- a/contrib/memory/src/java/org/apache/lucene/index/memory/PatternAnalyzer.java +++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/miscellaneous/PatternAnalyzer.java @@ -1,4 +1,4 @@ -package org.apache.lucene.index.memory; +package org.apache.lucene.analysis.miscellaneous; /** * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/PatternAnalyzerTest.java similarity index 99% rename from contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java rename to contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/PatternAnalyzerTest.java index 7761c92b68a..fb2455438d3 100644 --- a/contrib/memory/src/test/org/apache/lucene/index/memory/PatternAnalyzerTest.java +++ b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/miscellaneous/PatternAnalyzerTest.java @@ -1,4 +1,4 @@ -package org.apache.lucene.index.memory; +package org.apache.lucene.analysis.miscellaneous; /** * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java index a9980aab197..8ccda84666b 100644 --- a/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java +++ b/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java @@ -19,6 +19,7 @@ package org.apache.lucene.index.memory; import java.io.IOException; import java.io.Serializable; +import java.io.StringReader; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -249,13 +250,9 @@ public class MemoryIndex implements Serializable { if (analyzer == null) throw new IllegalArgumentException("analyzer must not be null"); - TokenStream stream; - if (analyzer instanceof PatternAnalyzer) { - stream = ((PatternAnalyzer) analyzer).tokenStream(fieldName, text); - } else { - stream = analyzer.tokenStream(fieldName, - new PatternAnalyzer.FastStringReader(text)); - } + TokenStream stream = analyzer.tokenStream(fieldName, + new StringReader(text)); + addField(fieldName, stream); } diff --git a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java index 754d3cb98f7..658cbf3f7d3 100644 --- a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java +++ b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java @@ -280,7 +280,6 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase { new SimpleAnalyzer(), new StopAnalyzer(Version.LUCENE_CURRENT), new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), - PatternAnalyzer.DEFAULT_ANALYZER, // new WhitespaceAnalyzer(), // new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null), // new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, true, stopWords),