Skip to content

Spell checking#1137

Merged
Julow merged 23 commits intomasterfrom
vendor_libcdict
Feb 1, 2026
Merged

Spell checking#1137
Julow merged 23 commits intomasterfrom
vendor_libcdict

Conversation

@Julow
Copy link
Copy Markdown
Owner

@Julow Julow commented Dec 13, 2025

This adds dictionary-based spell checking to the keyboard. The keyboard looks at the word being typed and matches it against a dictionary to either complete the rest of the word or find alternative spellings.

The core of this feature is implemented in cdict, a project that I developed for this purpose.
The dictionaries are hosted in this repository and can be downloaded from within the app. The wordlists used to build the dictionaries are the same ones used by HeliBoard (from this repository).

This is still a work in progress. I plan to improve the interface and add more features:

  • Phonetic-based spell checking
  • Custom dictionary
  • Emoji lookup
  • More customisation

This work was fully funded by the NLnet foundation. I would like to thanks them for giving me the time required to work on this feature.

Closes #343 #716 #745 #596 #571

This is the most requested feature and I hope it will be enjoyed.
I'm eager to receive feedback from anyone willing to test this new feature.

This was referenced Dec 13, 2025
@starlingnia
Copy link
Copy Markdown

Cool, this is what I am looking forward for unexpected keyboard

@Julow Julow mentioned this pull request Dec 28, 2025
@Julow Julow force-pushed the vendor_libcdict branch 2 times, most recently from a01c4e3 to b49a283 Compare December 28, 2025 18:03
@alotbsol555
Copy link
Copy Markdown
Contributor

wow, I just found this and installed the debug build from here, correct?

https://github.com/Julow/Unexpected-Keyboard/actions/runs/20557555689

however, I'm still struggling to test this properly:

  • the launcher app is light themed and not dark like my system theme and the official launcher app.
  • the installation dialog to download dictionaries is almost white on white, see screen shot below
  • after downloading a dictionary, there is still the install button above the keyboard and no suggestions

Screenshot_20251228-212051_1.png

what am I doing wrong?

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Dec 29, 2025

You are not doing anything wrong. This is how the interface is at this stage and that's what I'm working on next.
Make sure to install only one dictionary. Which one doesn't work for you ?

@alotbsol555
Copy link
Copy Markdown
Contributor

ok, with only one dictionary installed, it works. there are max 3 suggestions, which can be chosen. this looks good for the basic functionality!

@PickleHik3
Copy link
Copy Markdown

I've tried the recent builds, Downloaded the dictionary when prompted, but it kept prompting to download it (even though i had it downloaded) and could not get it working.

I'll keep an eye out for future builds!
cheers!

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Jan 17, 2026

Thanks you all for trying :)
With the last few fixes, this should be much more usable.
Can you try again and tell me what you think ? The APK is available at the end of this page: https://github.com/Julow/Unexpected-Keyboard/actions/runs/21093976426?pr=1137

@PickleHik3
Copy link
Copy Markdown

No, thank you for working on it!! you have no idea how much i've wanted this feature.
i am no developer but i'll keep using the build and report back if i find anything, here are the initial impressions;

  • Dictionary list empty on first launch: On the very first launch, the dictionary list was a blank white screen. I fixed this by clearing the app data (this could be just a me problem since there was a pip install running in the background)

  • Once loaded, it correctly detected my system language and showed only that one dictionary .

  • Suggestions are inconsistent based on cursor position. Example: 'dictionarirs' shows suggestions if the cursor is in the middle (dictionari | rs), but not if the cursor is at the end.

  • No auto correction: Typing 'keyblard' shows 'keyboard' in the suggestion strip, but doesn't actually replace the word automatically when i press space.

  • word combos: Compared to other keyboards (like Heliboard), it does not yet handle accidental key presses between words. Example: "thebtent" gets corrected to "the tent".

  • my wishlist;

  • Auto-insert on Space: Automatically insert the top suggestion when the spacebar is pressed.
  • Undo on Backspace: Revert an autocorrected word to the original if backspace is pressed immediately after the correction was made.
  • Visual Spellcheck: Red underlining for misspelled words.

Looking forward to future updates!

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Jan 18, 2026

Thanks for your help :)

Dictionary list empty on first launch: On the very first launch, the dictionary list was a blank white screen.

I could reproduce this bug. It happens when the keyboard was not yet enabled in the settings. Was that the case for you as well ?

Suggestions are inconsistent based on cursor position

This is very annoying! I should fix that.

No auto correction

This is intended, at least for the initial version. I'm trying to come up with a UX that lets the user choose when to correct or not.

word combos

Good idea !

Auto-insert on Space
Undo on Backspace

This is planned :)

Visual Spellcheck

I didn't plan to do that initially but this can be added easily. I'll take a note for future versions.

Julow added 16 commits January 18, 2026 17:36
Build cdict's C library and Java bindings and link them into the app.
Uses libcdict to query a dictionary each time the word before the cursor
changes. The candidates view is updated.

The dictionary is embedded into the app for now.
The main package is getting big.
Add an activity accessible from the launcher app that lists available
dictionaries with a download button.

The Dictionaries class manages installed dictionaries. Dictionaries are
installed as individual files into the app's private directory.

The DictionaryListView view shows the list of available dictionaries and
handles downloading and installing them.
The message is updated when the config is refreshed.
This is an important information that users might want to know before
clicking download.
Disables automatic compression, which doesn't always work, and instead
compress statically the dictionaries on the server. Compression is
disabled in the request and then forced on the client side.
Update the CI to work with the new vendor/cdict submodule.
The checkout action is upgraded to v6.
`dictionaries.xml` replaces the generated `SupportedDictionaries.java`
and `dict_names.xml`. It is generated from the
Unexpected-Keyboard-dictionaries project and contains the list of
available dictionaries.

This file is easier to update when the dictionaries are re-built and can
be parsed by gen_method_xml.py later to assign dictionaries to locales.
`gen_method_xml.py` reads `res/values/dictionaries.xml` and assign a
dictionary to each subtypes.

The script is rewritten to avoid using large format strings.
Instead of the full list of the supported dictionaries.
Use the information in DeviceLocales to select the right dictionary. A
cache is added into Dictionaries to avoid unecessary loads when
switching locale.
Julow added 5 commits January 18, 2026 17:45
The bug was caused by having two instances of Dictionaries.
This was an attempt at making the icons adapt to the app theme but
wasn't working as intended.
@PickleHik3
Copy link
Copy Markdown

I could reproduce this bug. It happens when the keyboard was not yet enabled in the settings. Was that the case for you as well ?

yes, i just confirmed this.

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Jan 18, 2026

Thanks :) For this bug, I think it's not useful to add code and handle this case. Perhaps the "enable" button should be redesigned and be the only thing on the screen in this case.

@Julow Julow mentioned this pull request Jan 25, 2026
@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Feb 1, 2026

I've added some improvements and I'll merge now. Thanks everyone for your help debugging this :)

A few things that I'll do soon are:

  • Auto-complete when typing space (with an option)
  • Undo clicking on a suggestion with the delete key
  • Detecting concatenated words like "thetent" or "theptent" detected as "the tent"
  • Searching through emoji names
  • and more !

@Julow Julow merged commit 77c4a27 into master Feb 1, 2026
6 checks passed
pashol pushed a commit to pashol/Unexpected-Keyboard that referenced this pull request Mar 25, 2026
This adds dictionary-based spell checking to the keyboard. The keyboard looks at the word being typed and matches it against a dictionary to either complete the rest of the word or find alternative spellings.

The core of this feature is implemented in cdict, which is included as a
submodule in vendor/cidct.

Cdict is developped at https://github.com/Julow/cdict
The dictionaries are hosted at https://github.com/Julow/Unexpected-Keyboard-dictionaries/
The wordlists used to build the dictionaries are the same ones used by
HeliBoard from https://codeberg.org/Helium314/aosp-dictionaries

- Add an activity accessible from the launcher app that lists available
  dictionaries with a download button.
  The DictionaryListView view shows the list of available dictionaries and
  handles downloading and installing them.

- The Dictionaries class manages installed dictionaries. Dictionaries are
  installed as individual files into the app's private directory.

- Available dictionaries are listed in dictionaries.xml, which is generated
  when building Unexpected-Keyboard-dictionaries.
  method.xml mentions the dictionary name for each locales.
@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Apr 7, 2026

I improved the suggestions for words with diacritics in #1223
Feedback welcome!

@PickleHik3
Copy link
Copy Markdown

I improved the suggestions for words with diacritics in #1223 Feedback welcome!

Hello my dear — I did some testing and wrote down my feedback below.

Also, I may be over-reporting or going off on tangents a bit, so if possible, could you let me know which areas would be most useful to focus on in future builds? I’m not a developer myself, so I’d really appreciate some guidance on where targeted testing would help you most. That way I can hopefully give feedback that is more meaningful and easier to act on, Thank you :)

Undo / autocorrect behavior

  • Undo on backspace usually does not stick: after undoing an autocorrection, pressing space again usually re-applies the correction.
  • Exception: "dictionarirs" → "dictionaries" is the only case I found where undo actually sticks. After undoing, pressing space again does not re-trigger autocorrection.
  • Undo restores the wrong suggestion: backspace-to-undo always seems to restore the middle suggestion, even if I had manually tapped the third suggestion from the strip.

Suggestion logic

  • Suggestions still depend on cursor position.
  • This looks like the earlier cursor-position issue is still present.

Termux-specific issues

Autocorrection behaves differently inside Termux compared to normal text fields.

  • "ls" becomes "lsLS"
  • Since undo does not work properly there, there is no easy way to recover

Another example:

  • I tried to type "what's a"
  • Steps:
    • type "whats"
    • inside Termux it autocorrects to "what's"
    • press space
    • type "a"
    • press space again
  • Result:
    • "Wha" gets inserted
    • pressing space again inserts another "Wha"
    • final text becomes: "what's aWhaWha"

Also, in a normal text field, "whats" does not get corrected to "What's", which feels inconsistent because other contractions like "what're", "you're", and "hasn't" do get corrected properly.

Dictionary installation / availability

  • Dictionaries are not listed for install unless the keyboard is already enabled.
  • Once the keyboard is enabled, dictionaries appear correctly for the system languages I added.
  • I tested with two languages, and that part seems to work.

Language switching / mixed-language autocorrect

There seems to be some autocorrect contamination after switching languages.

  • I switched from English UK → French → back to English UK
  • After switching back, autocorrection seems to get confused

Example:

  • Typing "seems" does not autocorrect the first time.
  • If I then type another "seems" on the same line, it gets autocorrected to "Sées".
  • The next "seems" stays unchanged again.
  • The one after that gets autocorrected to "Sées" again.
  • So it alternates consistently within the same line: one stays as "seems", the next gets changed to "Sées", and so on.

This issue goes away if I switch to another keyboard and then switch back to Unexpected Keyboard.

Extra note:

  • While this was happening, I checked the same case in Gboard.
  • Gboard showed "Sées" as the middle suggestion.
  • However, Gboard did not autocorrect "seems" to "Sées" automatically.
  • After switching keyboards away and back again, Gboard also stopped showing the incorrect suggestion.

App-specific behavior

  • In Google Keep, the suggestion bar does not appear
  • However, autocorrect is still working there

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Apr 10, 2026

Thanks for your detailed feedback :) Your testing work is impressive!

I've fixed the easiest issues and I'll work on the more complex ones soon.

The latest debug build is here if you want to see the keyboard improved thanks to you: https://github.com/Julow/Unexpected-Keyboard/actions/runs/24254534547

could you let me know which areas would be most useful to focus on in future builds?

It's most useful to try out things that you do usually with the keyboard. Your feedback is especially useful because you do things that I don't usually do.

Undo on backspace usually does not stick

Noted!

Exception: "dictionarirs" → "dictionaries" is the only case I found where undo actually sticks. After undoing, pressing space again does not re-trigger autocorrection.

Fixed in #1226

Undo restores the wrong suggestion: backspace-to-undo always seems to restore the middle suggestion, even if I had manually tapped the third suggestion from the strip.

I can't reproduce this. Can you share more ?

Suggestions still depend on cursor position.

Noted!

Termux-specific issues

That's a silly bug! Fixed: #1227

Dictionaries are not listed for install unless the keyboard is already enabled.

This is unavoidable as Android avoids sharing information with a keyboard that was not enabled.
Improved with a message: #1228

There seems to be some autocorrect contamination after switching languages.

Fixed in #1229

However, Gboard did not autocorrect "seems" to "Sées" automatically.

I think Gboard avoids doing autocorrect when the word is too different from what was typed while Unexpected just use the middle suggestion.

In Google Keep, the suggestion bar does not appear

This seems to be a bug in Google Keep but we can work around it: #1230

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Apr 10, 2026

The debug build with the above fixes and the improved suggestions is here: https://github.com/Julow/Unexpected-Keyboard/actions/runs/24254705134

@PickleHik3
Copy link
Copy Markdown

Glad to be of help!

I confirm the oddities with google keep, termux and multi languages is not appearing anymore.

Undo restores the wrong suggestion: backspace-to-undo always seems to restore the middle suggestion, even if I had manually tapped the third suggestion from the strip.

Please disregard my comment on this, it was actually working as intended.

Exception: "dictionarirs" → "dictionaries" is the only case I found where undo actually sticks. After undoing, pressing space again does not re-trigger autocorrection.

Just to clarify on this, "dictionarirs" was the one word where undo on backspace showed the intended behavior, if i undo its autocorrection and then press space again, it would stay as "dictionarirs". Whereas every other word would have been replaced by the middle suggestion on the space press after undo.

let me know when you fix the undo on backspace, once its fixed i can use the keyboard daily and give feedback.

Cheers!

@Julow
Copy link
Copy Markdown
Owner Author

Julow commented Apr 12, 2026

I've added a space character after the completed word (#1232). This doesn't look like much but for me it makes autocorrect usable.
And handled when the cursor is in the middle of a word (#1233).

Thanks again for your help :)

if i undo its autocorrection and then press space again, it would stay as "dictionarirs".

That was because of a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Word predicion and correcting

4 participants