feat: add word suggestions and auto-correct (#58) #346
+100,432
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change(s)
What changed and why
Tests performed
Preview
demo1.mp4
demo2.mp4
Closes the following issue(s)
Checklist
CHANGELOG.md(if applicable).Discussion
The embedded dictionary in this solution adds about 920KB in assets and this is only for English. For now this was the simplest solution I could think that works offline and works at least decently. If using the same approach for other languages, would need to download dictionaries for each and this would bloat the APK size even more.
Other better approach could be adding the option for users to select dictionaries to download. This would keep the base APK small and let users download only what they need for their language. What do you think?
Also, the correction algorithm in this version is the Levenshtein algorithm so it treats all character substitutions equally, which isn't always accurate. For example, typing "hrllo" instead of "hello" is likely a fat-finger error since r and e are right next to each other on at least QWERTY keyboards, but the algorithm doesn't know this. A future improvement could be to add keyboard proximity weighting so adjacent-key typos score higher than distant-key errors which would make suggestions more relevant.