mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Skip loading LM if it has not existed once
This commit is contained in:
parent
43c46da519
commit
0d7d6b816e
@ -181,11 +181,13 @@ public class LanguageModelFacilitator(
|
||||
}
|
||||
}
|
||||
|
||||
private var skipLanguage: String? = null
|
||||
private suspend fun runLanguageModel(values: PredictionInputValues): ArrayList<SuggestedWordInfo>? {
|
||||
if(transformerDisabled) return null
|
||||
|
||||
val locale = dictionaryFacilitator.locale ?: return null
|
||||
if (languageModel == null || (languageModel?.locale?.language != locale.language)) {
|
||||
if ((languageModel == null && locale.language != skipLanguage) || (languageModel?.locale?.language != locale.language)) {
|
||||
skipLanguage = null
|
||||
Log.d(
|
||||
"LanguageModelFacilitator",
|
||||
"Calling closeInternalLocked on model due to seeming locale change"
|
||||
@ -200,6 +202,7 @@ public class LanguageModelFacilitator(
|
||||
languageModel = LanguageModel(context, lifecycleScope, model, locale)
|
||||
} else {
|
||||
Log.d("LanguageModelFacilitator", "no model for ${locale.language}")
|
||||
skipLanguage = locale.language
|
||||
return null
|
||||
}
|
||||
}
|
||||
@ -448,6 +451,7 @@ public class LanguageModelFacilitator(
|
||||
withContext(Dispatchers.Default) {
|
||||
ModelPaths.modelOptionsUpdated.collect {
|
||||
Log.d("LanguageModelFacilitator", "ModelPaths options updated, destroying model")
|
||||
skipLanguage = null
|
||||
destroyModel()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user