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:

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: [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]