Multilingual typing: committed words are learned in the user history of the wrong language
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- internationalization, mobile
Direzione di ricerca
Start in DictionaryFacilitatorImpl, where addToUserHistory() reads currentlyPreferredDictionaryGroup before adjustConfidences() and then calls addWordToUserHistory with that group. Check unlearnFromUserHistory() as well, since it only touches the preferred group's history. Done when a German word typed after English words is stored in the de_DE history, and unlearnFromUserHistory() clears the word from every group that holds it. The reporter's groupForLearning idea is a starting point to verify, not a finished patch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
With multilingual typing, DictionaryFacilitatorImpl.addToUserHistory() always adds the word to the user history of currentlyPreferredDictionaryGroup. It even reads that group before adjustConfidences() runs for the word:
val preferredGroup = currentlyPreferredDictionaryGroup // read here
...
adjustConfidences(suggestion, wasAutoCapitalized) // confidence changes afterwards
...
// add to history for preferred dictionary group, to avoid mixing languages in history
addWordToUserHistory(preferredGroup, ngramContextForCurrentWord, currentWord, ...)
So after a few English words, a German word, typed or picked from the suggestions, goes into the English user history. There:
- the English main dictionary doesn't know it (
mainFreq = -1), so it is stored as an invalid word and needs several uses before it's suggested; - it is scored with the English locale weight;
- the bigram (previous word → German word) is stored in the English history too.
This is the opposite of what the comment intends ("to avoid mixing languages in history"). It also means that correcting a wrongly swiped word (e.g. German "hier" that came out as English "hitter") barely helps next time.
unlearnFromUserHistory() has the same issue: it only removes the word from the preferred group's history.
Log from our build (German main, English (US) secondary, with a temporary debug line in addToUserHistory). After "the weather is good and I think that", the user types "hier":
learn 'that' -> en_US, preferred en_US, confidences [de_DE=0, en_US=8]
learn 'hier' -> de_DE, preferred en_US, confidences [de_DE=1, en_US=2]
With the current LeanType code, "hier" goes to en_US, because that group is preferred. With our fix it goes to de_DE.
Fix that works for us
Pick the history by the word's language: the preferred group if the word belongs to it (or to no language), otherwise the group whose main/apps/personal dictionary contains it:
private fun groupForLearning(word: String): DictionaryGroup {
val preferred = currentlyPreferredDictionaryGroup
if (dictionaryGroups.size == 1) return preferred
fun belongsTo(group: DictionaryGroup) = isValidWord(word, DICTIONARY_TYPES_EXCLUDING_HISTORY, group)
|| isValidWord(word.lowercase(group.locale), DICTIONARY_TYPES_EXCLUDING_HISTORY, group)
if (belongsTo(preferred)) return preferred
return dictionaryGroups.filter { it !== preferred && belongsTo(it) }.maxByOrNull { it.confidence } ?: preferred
}
Use it in addToUserHistory() (per word, after adjustConfidences()), and let unlearnFromUserHistory() remove the word from the history of all groups. I can send a PR once we've tested it a bit longer.
To Reproduce
- Languages & Layouts → German → Multilingual typing → add English (US). Main dictionaries for both, personalized suggestions on.
- Type a few English words, then a German word that is not English (e.g. "hier").
- The word is added to the English user history (visible with a debug log, or via the dictionary dump in the debug settings).
Expected behavior
Words are learned in the user history of their own language.
App version & Flavor
Found in GlassType, my fork, now based on LeanType 4.3.1 (0e673e1). The code is unchanged in current main.
Device Info
- Model: Samsung Galaxy Z Fold 3 (SM-F926B)
- OS version: Android 15
- Lingua principale
- Kotlin
- Stelle
- 1k
- Fork
- 59
- Merge medio
- 14h 9m
- PR unite (30g)
- 56
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di LeanBitLab/LeanType
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
LeanBitLab/LeanType#766 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Silence timeout doesn't close interface and start transcription; causes silent loss of dictated speech.Forse già presa @LeanBitLab l’ha presa oggi. Apertabug
LeanBitLab/LeanType#765 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[issue] Tamil Keyboard issueApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
LeanBitLab/LeanType#764 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
LeanBitLab/LeanType#757 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
More suggestions based on version 1.0.1 of the CJK pluginForse già presa @LeanBitLab l’ha presa 2 giorni fa. Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
LeanBitLab/LeanType#754 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di LeanBitLab/LeanType
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
JetBrains/klibs-io#606 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Python: zadd stringifies bytes/bytearray/memoryview members (silent data corruption), including in BatchForse già presa @prateek-kumar-improving l’ha presa oggi. Apertabug 🐞 python 🐍
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
valkey-io/valkey-glide#7521 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
open-telemetry/opentelemetry-android#2183 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
Droid-Deck/DroidDeck#2058 ·
I maintainer di solito rispondono entro 1 giorno
-
bug core p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
I maintainer di solito rispondono entro 1 giorno