fixed word pair predicitions not working when one of the words contains capital letters
This commit is contained in:
parent
8ad8f9bd1c
commit
7283b8ae0b
2 changed files with 17 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ import io.github.sspanak.tt9.ime.helpers.TextField;
|
|||
import io.github.sspanak.tt9.languages.EmojiLanguage;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.util.Characters;
|
||||
import io.github.sspanak.tt9.util.TextTools;
|
||||
|
||||
public class WordPredictions extends Predictions {
|
||||
private final TextField textField;
|
||||
|
|
@ -274,14 +275,14 @@ public class WordPredictions extends Predictions {
|
|||
ArrayList<String> rearrangedWords = new ArrayList<>();
|
||||
String penultimateWord = textField.getWordBeforeCursor(language, 1, true);
|
||||
|
||||
String word = DataStore.getWord2(language, penultimateWord, digitSequence);
|
||||
int morePopularIndex = word == null ? -1 : words.indexOf(word);
|
||||
String pairWord = DataStore.getWord2(language, penultimateWord, digitSequence);
|
||||
int morePopularIndex = TextTools.indexOfIgnoreCase(words, pairWord);
|
||||
if (morePopularIndex == -1) {
|
||||
return words;
|
||||
}
|
||||
|
||||
lastEnforcedTopWord = word;
|
||||
rearrangedWords.add(word);
|
||||
lastEnforcedTopWord = words.get(morePopularIndex);
|
||||
rearrangedWords.add(lastEnforcedTopWord);
|
||||
|
||||
for (int i = 0; i < words.size(); i++) {
|
||||
if (i != morePopularIndex) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package io.github.sspanak.tt9.util;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -46,6 +47,17 @@ public class TextTools {
|
|||
}
|
||||
|
||||
|
||||
public static int indexOfIgnoreCase(List<String> list, String str) {
|
||||
for (int i = 0, size = list != null && str != null ? list.size() : 0; i < size; i++) {
|
||||
if (list.get(i).equalsIgnoreCase(str)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isStartOfSentence(String str) {
|
||||
return str != null && startOfSentence.matcher(str).find();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue