diff --git a/Keyboards/KeyboardsBase/KeyboardViewController.swift b/Keyboards/KeyboardsBase/KeyboardViewController.swift index 61dfee62..5947c5e8 100644 --- a/Keyboards/KeyboardsBase/KeyboardViewController.swift +++ b/Keyboards/KeyboardsBase/KeyboardViewController.swift @@ -2069,7 +2069,11 @@ class KeyboardViewController: UIInputViewController { autoCapAtStartOfProxy() if commandState == .invalid { - commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata + if !didYouMeanWord.isEmpty { + commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?" + } else { + commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata + } commandBar.isShowingInfoButton = true } else { commandBar.isShowingInfoButton = false @@ -2078,6 +2082,7 @@ class KeyboardViewController: UIInputViewController { } } commandBar.textColor = keyCharColor + didYouMeanWord = "" return } else if [.translate, .plural].contains(commandState) { // functional commands above autoActionState = .suggest @@ -2096,9 +2101,14 @@ class KeyboardViewController: UIInputViewController { loadKeys() proxy.insertText(selectedText) autoCapAtStartOfProxy() - commandBar.text = commandPromptSpacing + invalidCommandMsgWiktionary + if !didYouMeanWord.isEmpty { + commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?" + } else { + commandBar.text = commandPromptSpacing + invalidCommandMsgWiktionary + } commandBar.isShowingInfoButton = true commandBar.textColor = keyCharColor + didYouMeanWord = "" return } else { // functional commands above autoActionState = .suggest @@ -2130,9 +2140,14 @@ class KeyboardViewController: UIInputViewController { loadKeys() proxy.insertText(selectedText) autoCapAtStartOfProxy() - commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata + if !didYouMeanWord.isEmpty { + commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?" + } else { + commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata + } commandBar.isShowingInfoButton = true commandBar.textColor = keyCharColor + didYouMeanWord = "" return } } else { diff --git a/Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swift b/Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swift index 43778e4f..25026c50 100644 --- a/Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swift +++ b/Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swift @@ -49,6 +49,7 @@ var commandPromptSpacing = "" var inputWordIsCapitalized = false var wordToReturn = "" var potentialWordsToReturn = [String]() +var didYouMeanWord = "" var invalidCommandMsgWikidata = "" var invalidCommandTextWikidata1 = "" diff --git a/Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift b/Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift index ce16003a..d0eb00a3 100644 --- a/Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift +++ b/Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift @@ -41,5 +41,11 @@ func isVerbInConjugationTable(queriedVerbToConjugate: String) -> Bool { let columnName = (controllerLanguage == "Swedish") ? "verb" : "infinitive" let results = LanguageDBManager.shared.queryVerb(of: verbToConjugate, with: [columnName]) - return !results.isEmpty && !results[0].isEmpty + let verbExists = !results.isEmpty && !results[0].isEmpty + if !verbExists { + let suggestions = LanguageDBManager.shared.queryAutocompletions(word: verbToConjugate) + didYouMeanWord = suggestions.first ?? "" + } + + return verbExists } diff --git a/Keyboards/KeyboardsBase/ScribeFunctionality/Translate.swift b/Keyboards/KeyboardsBase/ScribeFunctionality/Translate.swift index 8672e868..5b32097c 100644 --- a/Keyboards/KeyboardsBase/ScribeFunctionality/Translate.swift +++ b/Keyboards/KeyboardsBase/ScribeFunctionality/Translate.swift @@ -42,6 +42,8 @@ func queryWordToTranslate(queriedWordToTranslate: String) { wordToReturn = LanguageDBManager.translations.queryTranslation(of: wordToTranslate)[0] guard !wordToReturn.isEmpty else { + let suggestions = LanguageDBManager.shared.queryAutocompletions(word: wordToTranslate.lowercased()) + didYouMeanWord = suggestions.first ?? "" commandState = .invalid return }