Skip to content
Snippets Groups Projects
Commit 0d7d6b81 authored by Aleksandras Kostarevas's avatar Aleksandras Kostarevas
Browse files

Skip loading LM if it has not existed once

parent 43c46da5
No related branches found
No related tags found
No related merge requests found
......@@ -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()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment