lucene-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [lucene-solr] magibney commented on a change in pull request #892: LUCENE-8972: Add ICUTransformCharFilter, to support pre-tokenizer ICU text transformation
Date Fri, 01 Nov 2019 15:57:34 GMT
magibney commented on a change in pull request #892: LUCENE-8972: Add ICUTransformCharFilter,
to support pre-tokenizer ICU text transformation

 File path: lucene/analysis/icu/src/test/org/apache/lucene/analysis/icu/
 @@ -0,0 +1,153 @@
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.core.KeywordTokenizer;
+ * Test the ICUTransformCharFilter with some basic examples.
+ */
+public class TestICUTransformCharFilter extends BaseTokenStreamTestCase {
+  public void testBasicFunctionality() throws Exception {
+    checkToken(Transliterator.getInstance("Traditional-Simplified"), 
+        "簡化字", "简化字"); 
+    checkToken(Transliterator.getInstance("Katakana-Hiragana"), 
+        "ヒラガナ", "ひらがな");
+    checkToken(Transliterator.getInstance("Fullwidth-Halfwidth"), 
+        "アルアノリウ", "アルアノリウ");
+    checkToken(Transliterator.getInstance("Any-Latin"), 
+        "Αλφαβητικός Κατάλογος", "Alphabētikós Katálogos");
+    checkToken(Transliterator.getInstance("NFD; [:Nonspacing Mark:] Remove"), 
+        "Alphabētikós Katálogos", "Alphabetikos Katalogos");
+    checkToken(Transliterator.getInstance("Han-Latin"),
+        "中国", "zhōng guó");
+  }
+  public void testRollbackBuffer() throws Exception {
+    checkToken(Transliterator.getInstance("Cyrillic-Latin"),
+        "яяяяя", "âââââ"); // final NFC transform applied
+    checkToken(Transliterator.getInstance("Cyrillic-Latin"), 0,
+        "яяяяя", "a\u0302a\u0302a\u0302a\u0302a\u0302"); // final NFC transform never
+    checkToken(Transliterator.getInstance("Cyrillic-Latin"), 2,
 Review comment:
   This happens because "Cyrillic-Latin" is a compound transliterator, composed of child transliterators
"NFD, [main Cyrillic-Latin tranliteration], NFC". After the inner child transliterator changes
a single "я" into "â" (decomposed), the final NFC transformation sees the two-character
decomposition of "â", but doesn't do anything "yet" because it's not sure whether it will
see more combining diacritics. But NFC never sees those input characters again, because on
subsequent invocation, they are excluded by the toplevel filters on the main "Cyrillic-Latin"
transliterator (which only pays attention to Cyrillic input characters). So the partially-transliterated,
decomposed characters are passed through to the output. There's a solid, more general explanation
in the code for ICU [Transliterator](

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message