1
0
Fork 0

more fine-tunning

This commit is contained in:
sspanak 2024-08-31 15:42:54 +03:00 committed by Dimo Karaivanov
parent b0d5fb3af3
commit dbf943d18a
2 changed files with 15 additions and 3 deletions

View file

@ -146,7 +146,7 @@ public class SuggestionsBar {
private void setStem(List<String> newSuggestions, boolean containsGenerated) {
if (newSuggestions == null || newSuggestions.isEmpty()) {
if (newSuggestions == null || newSuggestions.size() < 2) {
stem = "";
return;
}
@ -156,6 +156,18 @@ public class SuggestionsBar {
// Do not modify single letter + punctuation, such as "j'" or "l'". They look better as they are.
stem = (stem.length() == 1 && newSuggestions.get(0).length() == 2 && !Character.isAlphabetic(newSuggestions.get(0).charAt(1))) ? "" : stem;
// If no other suggestion contains the stem, it makes no sense to separate them and display:
// "STEM" + "one-suggestion". It is only useful when there are multiple suggestions with the
// same stem.
boolean onlyOneContainsStem = true;
for (int i = 1; i < newSuggestions.size(); i++) {
if (newSuggestions.get(i).contains(stem)) {
onlyOneContainsStem = false;
break;
}
}
stem = onlyOneContainsStem ? "" : stem;
if (!stem.isEmpty() && !newSuggestions.contains(stem)) {
suggestions.add(stem + STEM_SUFFIX);
selectedIndex++;

View file

@ -18,11 +18,11 @@ public class Characters {
));
final public static ArrayList<Character> CombiningPunctuation = new ArrayList<>(Arrays.asList(
',', '-', '\'', ';', '!', '?', '.'
',', '-', '\'', ':', ';', '!', '?', '.'
));
final public static ArrayList<Character> CombiningPunctuationHebrew = new ArrayList<>(Arrays.asList(
',' , '-', '\'', ';', '!', '?', '.', '"'
',' , '-', '\'', ':', ';', '!', '?', '.', '"'
));
final public static ArrayList<String> PunctuationArabic = new ArrayList<>(Arrays.asList(