From 99d5fda1705cadbcc067f43d00ca7e8b2ef01e05 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Tue, 7 May 2024 11:31:15 -0500 Subject: [PATCH] Fix incorrect LM results with number row --- ...to_inputmethod_latin_xlm_LanguageModel.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp b/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp index 4337aea3a..6d7954ff1 100644 --- a/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp +++ b/native/jni/org_futo_inputmethod_latin_xlm_LanguageModel.cpp @@ -1016,8 +1016,14 @@ namespace latinime { std::vector mixes; for(int i=0; i= 'a' && wc <= 'z') && !(wc >= 'A' && wc <= 'Z')) continue; - if (xCoordinates[i] == -1 || yCoordinates[i] == -1) continue; + if (!(wc >= 'a' && wc <= 'z') && !(wc >= 'A' && wc <= 'Z')) { + //AKLOGI("%d | Char %c skipped due to not within range", i, wc); + continue; + } + if (xCoordinates[i] == -1 || yCoordinates[i] == -1) { + //AKLOGI("%d | Char %c skipped due to -1", i, wc); + continue; + } std::vector proportions = pInfo->decomposeTapPosition(xCoordinates[i], yCoordinates[i]); for(float &f : proportions) { @@ -1034,14 +1040,15 @@ namespace latinime { bool needs_resorting = false; int num_symbols = 0; - for(int s=0; s<100; s++) { + for(int s=0; s<4; s++) { + num_symbols = 0; for (int j = 0; j < NUM_TOKEN_MIX; j++) { char c = (char) (pInfo->getKeyCodePoint(index_value[j].second)); if (c >= 'a' && c <= 'z') { } else if (c >= 'A' && c <= 'Z') { - } else { - index_value[j].first = -99999.0f; + } else if(index_value[j].first > 0.0f) { + index_value[j].first = 0.0f; needs_resorting = true; num_symbols++; } @@ -1050,7 +1057,10 @@ namespace latinime { if(!needs_resorting) break; sortProbabilityPairVectorDescending(index_value, NUM_TOKEN_MIX); } - if(num_symbols == NUM_TOKEN_MIX) continue; // Skip the symbol character + if(num_symbols == NUM_TOKEN_MIX) { + //AKLOGI("%d | Char %c skipped due to num_symbols == NUM_TOKEN_MIX", i, wc); + continue; + }; // Skip the symbol character float total_sum = 0.0f; for(int j=0; j