KeyboardKit / KeyboardKitPro

KeyboardKit Pro helps you create custom keyboards for iOS and iPadOS.
https://keyboardkit.com
Other
103 stars 8 forks source link

User-Specific Dictionary Support Guidance #6

Closed evilutioner closed 9 months ago

evilutioner commented 1 year ago

I am trying to implement support user local dictionary support. I want to learn some words that user inputed or he reverted after autocorrection. My first approach was is inherit class LocalAutocompleteProvider. In this case the suggestion quality is dramatically makes worse. I also tried to use func learnWord(_ word: String) but it looks like doesn't affect it. Could you follow me up how to use pro version of autocomplete provider and enrich his logic? My last approach based on using custom KeyboardActionHandler but it is not fit all my intents.

I am in the process of incorporating a feature for user-specific dictionary support. The aim is to keep comprehend words inputted by the user, including those that were reverted following autocorrection. Initially, I attempted to use inheritance with the LocalAutocompleteProvider class. However, this approach resulted in a significant degradation in suggestion quality. Additionally, I attempted to utilize the function 'learnWord(_ word: String)', but it did not seem to have any discernible impact.

Could you possibly provide guidance on the use of the pro version of the autocomplete provider, particularly in terms of enhancing its logic? My most recent attempt involved using a custom KeyboardActionHandler, but this method did not fully accommodate my requirements. Any assistance you could provide would be greatly appreciated.

final class CustomAutocompleteProvider: LocalAutocompleteProvider {}

final class KeyboardViewController: KeyboardInputViewController {

    override func viewWillSetupKeyboard() {
        super.viewWillSetupKeyboard()

        do {
            try setupPro(
                withLicenseKey: "[Key]",
                view: { controller in KeyboardView(controller: controller) },
                licenseConfiguration: setupKeyboardWithLicense
            )
        } catch {
            os_log("license error \(error)")
        }
    }

    func setupKeyboardWithLicense(_ license: License) {
        autocompleteProvider = try! CustomAutocompleteProvider()
    }
}
danielsaidi commented 1 year ago

Hi @evilutioner

Do you have another autocomplete provider as well? I'm curious to how inheriting LocalAutocompleteProvider makes things worse, since that IS the type that is used by default.

I will take a look at learning and ignoring words, but it should work. You can also check the docs, since one of the two requires that you insert a list every time, while the other will remember the words you insert.

I will try to come up with a way to make both persistent, since that would improve the usability quite a bit.