You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cm...@apache.org on 2012/03/25 16:34:08 UTC

svn commit: r1305051 - in /lucene/dev/branches/branch_3x: lucene/contrib/ lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/ lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ lucene/contri...

Author: cm
Date: Sun Mar 25 14:34:08 2012
New Revision: 1305051

URL: http://svn.apache.org/viewvc?rev=1305051&view=rev
Log:
Added KuromojiReadingFormFilter (backport of LUCENE-3915)

Added:
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/KuromojiReadingFormFilter.java
      - copied unchanged from r1305046, lucene/dev/trunk/modules/analysis/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/KuromojiReadingFormFilter.java
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiReadingFormFilter.java
      - copied unchanged from r1305046, lucene/dev/trunk/modules/analysis/kuromoji/src/test/org/apache/lucene/analysis/kuromoji/TestKuromojiReadingFormFilter.java
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/analysis/KuromojiReadingFormFilterFactory.java
      - copied unchanged from r1305046, lucene/dev/trunk/solr/core/src/java/org/apache/solr/analysis/KuromojiReadingFormFilterFactory.java
Modified:
    lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java

Modified: lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt?rev=1305051&r1=1305050&r2=1305051&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt Sun Mar 25 14:34:08 2012
@@ -60,6 +60,9 @@ New Features
    with/without trailing long vowel marks. The filter is used in both KuromojiAnalyzer
    and the "text_ja" field type in schema.xml. (Christian Moen)
 
+ * LUCENE-3915: Add Japanese filter to replace a term attribute with its reading.
+   (Koji Sekiguchi, Robert Muir, Christian Moen)
+
  * LUCENE-3685: Add ToChildBlockJoinQuery and renamed previous
    BlockJoinQuery to ToParentBlockJoinQuery, so that you can now do
    joins in both parent to child and child to parent directions.

Modified: lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java?rev=1305051&r1=1305050&r2=1305051&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/src/java/org/apache/lucene/analysis/kuromoji/util/ToStringUtil.java Sun Mar 25 14:34:08 2012
@@ -17,6 +17,7 @@ package org.apache.lucene.analysis.kurom
  * limitations under the License.
  */
 
+import java.io.IOException;
 import java.util.HashMap;
 
 /**
@@ -239,7 +240,19 @@ public class ToStringUtil {
    * Romanize katakana with modified hepburn
    */
   public static String getRomanization(String s) {
-    StringBuilder builder = new StringBuilder();
+    StringBuilder out = new StringBuilder();
+    try {
+      getRomanization(out, s);
+    } catch (IOException bogus) {
+      throw new RuntimeException(bogus);
+    }
+    return out.toString();
+  }
+  
+  /**
+   * Romanize katakana with modified hepburn
+   */
+  public static void getRomanization(Appendable builder, CharSequence s) throws IOException {
     final int len = s.length();
     for (int i = 0; i < len; i++) {
       // maximum lookahead: 3
@@ -1022,6 +1035,5 @@ public class ToStringUtil {
           builder.append(ch);
       }
     }
-    return builder.toString();
   }
 }