1
0
Fork 0

fixed word frequencies not updating when manually selecting a word that is only typed partially

This commit is contained in:
sspanak 2024-12-16 15:41:59 +02:00 committed by Dimo Karaivanov
parent ac4e5c597c
commit 55038c4719

View file

@ -252,19 +252,22 @@ public class WordPredictions extends Predictions {
*/ */
public void onAccept(String word, String sequence) { public void onAccept(String word, String sequence) {
if ( if (
!settings.getPredictWordPairs() word == null
// If the accepted word is longer than the sequence, it is some different word, not a textonym
// of the fist suggestion. We don't need to store it.
|| word == null
|| word.length() != digitSequence.length()
// If the word is the first suggestion, we have already guessed it right, and it makes no // If the word is the first suggestion, we have already guessed it right, and it makes no
// sense to store it as a popular pair. // sense to store it as a popular pair or increase its priority.
|| (!words.isEmpty() && words.get(0).equals(word)) || (!words.isEmpty() && words.get(0).equals(word))
) { ) {
return; return;
} }
// Second condition note: If the accepted word is longer than the sequence, it is some different word,
// not a textonym of the fist suggestion. We don't need to store it.
if (settings.getPredictWordPairs() && word.length() == digitSequence.length()) {
DataStore.addWordPair(language, textField.getWordBeforeCursor(language, 1, true), word, sequence); DataStore.addWordPair(language, textField.getWordBeforeCursor(language, 1, true), word, sequence);
}
// Update the priority only if the user has selected the word, not when we have enforced it
// because it is in a popular word pair.
if (!word.equals(lastEnforcedTopWord)) { if (!word.equals(lastEnforcedTopWord)) {
DataStore.makeTopWord(language, word, sequence); DataStore.makeTopWord(language, word, sequence);
} }