hyphenationPoints function
Where word (ASCII letters) may be hyphenated: the number of letters
before each break, ascending.
Implementation
List<int> hyphenationPoints(String word) {
final lower = word.toLowerCase();
if (lower.length < 5 || !RegExp(r'^[a-z]+$').hasMatch(lower)) return const [];
final exception = _exceptions[lower];
if (exception != null) return exception;
final dotted = '.$lower.';
final values = List<int>.filled(dotted.length + 1, 0);
for (var i = 0; i < dotted.length; i++) {
final end = math.min(dotted.length, i + _longestPattern);
for (var j = i + 1; j <= end; j++) {
final p = _patterns[dotted.substring(i, j)];
if (p == null) continue;
for (var k = 0; k < p.length; k++) {
if (p[k] > values[i + k]) values[i + k] = p[k];
}
}
}
// values[i + 1] is the value between letters i - 1 and i of the word.
return [
for (var i = 2; i <= lower.length - 3; i++)
if (values[i + 1].isOdd) i,
];
}