1
0
Fork 0

fixed typing non-dictionary words using the "word... +a, +b, +c" method not possible in Hebrew, Yiddish and Ukrainian

This commit is contained in:
sspanak 2025-01-17 17:07:00 +02:00
parent cde3292774
commit fde8b6ca0f
3 changed files with 25 additions and 10 deletions

View file

@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import io.github.sspanak.tt9.hacks.InputType;
import io.github.sspanak.tt9.ime.helpers.TextField;
@ -416,8 +417,8 @@ class ModeWords extends ModeCheonjiin {
return false;
}
if (shouldAcceptHebrewOrUkrainianWord(unacceptedText)) {
return true;
if (shouldContinueHebrewOrUkrainianWord(unacceptedText)) {
return false;
}
// punctuation breaks words, unless there are database matches ('s, qu', по-, etc...)
@ -434,15 +435,17 @@ class ModeWords extends ModeCheonjiin {
* Apostrophes never break Ukrainian and Hebrew words because they are used as letters. Same for
* the quotation marks in Hebrew.
*/
private boolean shouldAcceptHebrewOrUkrainianWord(String unacceptedText) {
char penultimateChar = unacceptedText.length() > 1 ? unacceptedText.charAt(unacceptedText.length() - 2) : 0;
if (LanguageKind.isHebrew(language) && predictions.noDbWords()) {
return penultimateChar != '\'' && penultimateChar != '"';
private boolean shouldContinueHebrewOrUkrainianWord(String unacceptedText) {
if (unacceptedText.length() <= 1 || !predictions.noDbWords()) {
return false;
}
if (LanguageKind.isUkrainian(language) && predictions.noDbWords()) {
return penultimateChar != '\'';
if (LanguageKind.isHebrew(language)) {
return new Text(language, unacceptedText).isValidWordWithPunctuation(List.of('"', '\''));
}
if (LanguageKind.isUkrainian(language)) {
return new Text(language, unacceptedText).isValidWordWithPunctuation(List.of('\''));
}
return false;

View file

@ -2,6 +2,7 @@ package io.github.sspanak.tt9.util;
import androidx.annotation.NonNull;
import java.util.List;
import java.util.Locale;
import io.github.sspanak.tt9.ime.modes.InputMode;
@ -36,6 +37,17 @@ public class Text extends TextTools {
}
public boolean isValidWordWithPunctuation(List<Character> punctuation) {
for (int i = 0, end = text != null ? text.length() : 0; i < end; i++) {
if (!Character.isAlphabetic(text.charAt(i)) && !punctuation.contains(text.charAt(i))) {
return false;
}
}
return true;
}
public boolean endsWithGraphic() {
return text != null && !text.isEmpty() && Characters.isGraphic(text.charAt(text.length() - 1));
}

View file

@ -20,11 +20,11 @@ public class TextTools {
private static final Pattern startOfSentence = Pattern.compile("(?<!\\.)(^|[.?!؟¿¡])\\s+$");
public static boolean containsOtherThan1(String str) {
return str != null && containsOtherThan1.matcher(str).find();
}
public static boolean isCombining(String str) {
return str != null && combiningString.matcher(str).find();
}