enabled single Latin letters in Ideographic modes, when there is no dictionary loaded
This commit is contained in:
parent
f5d0c6e12a
commit
82cac3153e
3 changed files with 31 additions and 1 deletions
|
|
@ -122,7 +122,7 @@ public class ModeIdeograms extends ModeWords {
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldAcceptPreviousSuggestion(String s) {
|
public boolean shouldAcceptPreviousSuggestion(String s) {
|
||||||
return
|
return
|
||||||
!digitSequence.isEmpty()
|
digitSequence.length() > 1
|
||||||
&& predictions.noDbWords()
|
&& predictions.noDbWords()
|
||||||
&& !digitSequence.equals(EMOJI_SEQUENCE)
|
&& !digitSequence.equals(EMOJI_SEQUENCE)
|
||||||
&& !digitSequence.equals(PUNCTUATION_SEQUENCE)
|
&& !digitSequence.equals(PUNCTUATION_SEQUENCE)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ public class IdeogramPredictions extends WordPredictions {
|
||||||
transcriptions = onlyExactMatches ? reduceFuzzyMatches(dbWords, SettingsStore.SUGGESTIONS_MAX) : dbWords;
|
transcriptions = onlyExactMatches ? reduceFuzzyMatches(dbWords, SettingsStore.SUGGESTIONS_MAX) : dbWords;
|
||||||
words = new ArrayList<>(transcriptions);
|
words = new ArrayList<>(transcriptions);
|
||||||
areThereDbWords = !words.isEmpty();
|
areThereDbWords = !words.isEmpty();
|
||||||
|
if (!areThereDbWords) {
|
||||||
|
onNoWords();
|
||||||
|
}
|
||||||
|
|
||||||
onWordsChanged.run();
|
onWordsChanged.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +64,14 @@ public class IdeogramPredictions extends WordPredictions {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void onNoWords() {
|
||||||
|
if (digitSequence.length() == 1) {
|
||||||
|
transcriptions = generateWordVariations(null);
|
||||||
|
words = new ArrayList<>(transcriptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
protected String getPenultimateWord(@NonNull String currentWord) {
|
protected String getPenultimateWord(@NonNull String currentWord) {
|
||||||
|
|
@ -164,6 +176,10 @@ public class IdeogramPredictions extends WordPredictions {
|
||||||
* Example operation: [SHIWU食物, SHIWU事物, SHIWU事务, SHIZU十足] -> [SHIWU, SHIZU]
|
* Example operation: [SHIWU食物, SHIWU事物, SHIWU事务, SHIZU十足] -> [SHIWU, SHIZU]
|
||||||
*/
|
*/
|
||||||
public void stripNativeWords() {
|
public void stripNativeWords() {
|
||||||
|
if (!areThereDbWords) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HashSet<String> uniqueTranscriptions = new HashSet<>();
|
HashSet<String> uniqueTranscriptions = new HashSet<>();
|
||||||
|
|
||||||
for (int i = 0; i < transcriptions.size(); i++) {
|
for (int i = 0; i < transcriptions.size(); i++) {
|
||||||
|
|
@ -191,6 +207,10 @@ public class IdeogramPredictions extends WordPredictions {
|
||||||
* Example operation: [SHIWU食物, SHIZU十足] -> [食物, 十足]
|
* Example operation: [SHIWU食物, SHIZU十足] -> [食物, 十足]
|
||||||
*/
|
*/
|
||||||
public void stripTranscriptions() {
|
public void stripTranscriptions() {
|
||||||
|
if (!areThereDbWords) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
words.clear();
|
words.clear();
|
||||||
for (int i = 0; i < transcriptions.size(); i++) {
|
for (int i = 0; i < transcriptions.size(); i++) {
|
||||||
String transcription = transcriptions.get(i);
|
String transcription = transcriptions.get(i);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package io.github.sspanak.tt9.ime.modes.predictions;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.ime.helpers.TextField;
|
import io.github.sspanak.tt9.ime.helpers.TextField;
|
||||||
import io.github.sspanak.tt9.languages.exceptions.InvalidLanguageCharactersException;
|
import io.github.sspanak.tt9.languages.exceptions.InvalidLanguageCharactersException;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
|
@ -51,4 +53,12 @@ public class KanaPredictions extends IdeogramPredictions {
|
||||||
String sequence = SEQUENCE_PREFIX + language.getDigitSequenceForWord(stripStemPrefix(transcription));
|
String sequence = SEQUENCE_PREFIX + language.getDigitSequenceForWord(stripStemPrefix(transcription));
|
||||||
super.onAccept(transcription + word, sequence);
|
super.onAccept(transcription + word, sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNoWords() {
|
||||||
|
if (digitSequence.length() == 2) {
|
||||||
|
transcriptions = generateWordVariations(null);
|
||||||
|
words = new ArrayList<>(transcriptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue