lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r922277 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java
Date Fri, 12 Mar 2010 14:34:28 GMT
Author: rmuir
Date: Fri Mar 12 14:34:28 2010
New Revision: 922277

URL: http://svn.apache.org/viewvc?rev=922277&view=rev
Log:
LUCENE-2015: add a static foldToASCII method to ASCIIFoldingFilter

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=922277&r1=922276&r2=922277&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Mar 12 14:34:28 2010
@@ -83,6 +83,9 @@ API Changes
   with FuzzyQuery to ensure that exact matches are always scored higher, 
   because only the boost will be used in scoring.  (Robert Muir)
   
+* LUCENE-2015: Add a static method foldToASCII to ASCIIFoldingFilter to 
+  expose its folding logic.  (Cédrik Lime via Robert Muir)
+  
 Bug fixes
 
 * LUCENE-2119: Don't throw NegativeArraySizeException if you pass

Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java?rev=922277&r1=922276&r2=922277&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/ASCIIFoldingFilter.java Fri Mar
12 14:34:28 2010
@@ -105,9 +105,24 @@ public final class ASCIIFoldingFilter ex
       output = new char[ArrayUtil.oversize(maxSizeNeeded, RamUsageEstimator.NUM_BYTES_CHAR)];
     }
 
-    outputPos = 0;
+    outputPos = foldToASCII(input, 0, output, 0, length);
+  }
 
-    for (int pos = 0 ; pos < length ; ++pos) {
+  /**
+   * Converts characters above ASCII to their ASCII equivalents.  For example,
+   * accents are removed from accented characters.
+   * @param input     The characters to fold
+   * @param inputPos  Index of the first character to fold
+   * @param output    The result of the folding. Should be of size >= {@code length *
4}.
+   * @param outputPos Index of output where to put the result of the folding
+   * @param length    The number of characters to fold
+   * @return length of output
+   * @lucene.internal
+   */
+  public static final int foldToASCII(char input[], int inputPos, char output[], int outputPos,
int length)
+  {
+    final int end = inputPos + length;
+    for (int pos = inputPos; pos < end ; ++pos) {
       final char c = input[pos];
 
       // Quick test: if it's not in range then just keep current character
@@ -2028,5 +2043,6 @@ public final class ASCIIFoldingFilter ex
         }
       }
     }
+    return outputPos;
   }
 }



Mime
View raw message