mirror of https://github.com/apache/lucene.git
LUCENE-9786: Hunspell suggestions: try moving the last character into the middle (#2399)
This commit is contained in:
parent
3ddc3c04a5
commit
5325d2e6f4
|
@ -245,11 +245,14 @@ class ModifyingSuggester {
|
||||||
|
|
||||||
private void tryMovingChar(String word) {
|
private void tryMovingChar(String word) {
|
||||||
for (int i = 0; i < word.length(); i++) {
|
for (int i = 0; i < word.length(); i++) {
|
||||||
for (int j = i + 2; j < word.length() && j <= i + MAX_CHAR_DISTANCE; j++) {
|
|
||||||
String prefix = word.substring(0, i);
|
String prefix = word.substring(0, i);
|
||||||
|
for (int j = i + 2; j < word.length() && j <= i + MAX_CHAR_DISTANCE; j++) {
|
||||||
trySuggestion(prefix + word.substring(i + 1, j) + word.charAt(i) + word.substring(j));
|
trySuggestion(prefix + word.substring(i + 1, j) + word.charAt(i) + word.substring(j));
|
||||||
trySuggestion(prefix + word.charAt(j) + word.substring(i, j) + word.substring(j + 1));
|
trySuggestion(prefix + word.charAt(j) + word.substring(i, j) + word.substring(j + 1));
|
||||||
}
|
}
|
||||||
|
if (i < word.length() - 1) {
|
||||||
|
trySuggestion(prefix + word.substring(i + 1) + word.charAt(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
# switch off ngram suggestion for testing
|
# switch off ngram suggestion for testing
|
||||||
MAXNGRAMSUGS 0
|
MAXNGRAMSUGS 0
|
||||||
TRY -
|
TRY -b
|
||||||
REP 2
|
REP 2
|
||||||
REP alot a_lot
|
REP alot a_lot
|
||||||
REP inspite in_spite
|
REP inspite in_spite
|
||||||
|
|
|
@ -13,3 +13,6 @@ permanent-vacation/?
|
||||||
in
|
in
|
||||||
spite
|
spite
|
||||||
inspire
|
inspire
|
||||||
|
Saiph
|
||||||
|
sahib
|
||||||
|
ship
|
|
@ -12,4 +12,4 @@ Gandhi
|
||||||
McDonald
|
McDonald
|
||||||
permanent
|
permanent
|
||||||
in, in a
|
in, in a
|
||||||
|
Saiph, Ship, Sahib
|
||||||
|
|
|
@ -14,3 +14,4 @@ permqnent
|
||||||
permanent-vacation
|
permanent-vacation
|
||||||
permqnent-vacation
|
permqnent-vacation
|
||||||
ina
|
ina
|
||||||
|
Sahip
|
Loading…
Reference in New Issue