msfroh commented on PR #14350:
URL: https://github.com/apache/lucene/pull/14350#issuecomment-2725709282

   This is kind of what I had in mind:
   
   ```java
     private static int canonicalize(int codePoint) {
       int[] alternatives = CaseFolding.lookupAlternates(codePoint);
       if (alternatives != null) {
         for (int cp : alternatives) {
           codePoint = Math.min(codePoint, cp);
         }
       } else {
         int altCase = Character.isLowerCase(codePoint) ? 
Character.toUpperCase(codePoint) : Character.toLowerCase(codePoint);
         codePoint = Math.min(codePoint, altCase);
       }
       return codePoint;
     }
   
     public void testCornerCase() throws Exception {
       List<BytesRef> terms = Stream.of(
                       "aIb", "aıc")
               .map(s -> {
                 int[] lowercased = 
s.codePoints().map(TestStringsToAutomaton::canonicalize).toArray();
                 return new String(lowercased, 0, lowercased.length);
               })
               .map(LuceneTestCase::newBytesRef)
               .sorted()
               .collect(Collectors.toCollection(ArrayList::new));
       Automaton a = build(terms, false, true);
       System.out.println(a.toDot());
       assertTrue(a.isDeterministic());
     }
   ```
   
   That produces this automaton, which is minimal and deterministic:
   
![automaton](https://github.com/user-attachments/assets/ad4d6779-dafa-470d-aaf2-09292ab179b6)
   
   I don't know if that `canonicalize` method is a good idea, though.


-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to