neoremind commented on code in PR #16371:
URL: https://github.com/apache/lucene/pull/16371#discussion_r3681147749


##########
lucene/core/src/java/org/apache/lucene/analysis/CaseFoldingFilter.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+package org.apache.lucene.analysis;
+
+import java.io.IOException;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+
+/**
+ * Normalizes token text by applying Unicode simple case folding, which erases 
case distinctions
+ * more thoroughly than {@link LowerCaseFilter} for non-ASCII scripts.

Review Comment:
   Interesting PR! Happen to look at `SimpleCaseFolding`'s first lines, my 
first instinct was that 0x0130 -> 0x0130 maybe incorrect? But it turns out to 
be correct, by looking up the mapping in 
https://www.unicode.org/Public/17.0.0/ucd/CaseFolding.txt, U+0130 has no 
Common/Simple mapping (only Full and Turkic ones), so the default simple case 
fold makes it unchanged. This is different from `Character.toLowerCase()`, 
which turns "İ" into "i". I do a quick scan over all codepoints, this is the 
only char where `Character.toLowerCase` is different from input char but simple 
folding is the same to the input char.
   
   So, two minor comments: 
   1. would it be better to modify the javadoc "erases case distinctions more 
thoroughly than LowerCaseFilter" to be more precise? Something like: Normalizes 
token text by applying Unicode simple case folding, which erases case 
distinctions that LowerCaseFilter misses for non-ASCII characters. One notable 
difference, U+0130 is unchanged, this mapping is Turkic-specific. OR simply 
claim - Normalizes token text by applying Unicode simple case folding (removing 
the ambiguous part)
   
   2. maybe add https://www.unicode.org/Public/17.0.0/ucd/CaseFolding.txt as a 
@ see in javadoc, either here or in SimpleCaseFolding? since it's the ground 
truth for these mappings.
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to