feat(keyboard): show closest word suggestion on invalid command #640#642
Open
prince-0408 wants to merge 1 commit intoscribe-org:mainfrom
Open
feat(keyboard): show closest word suggestion on invalid command #640#642prince-0408 wants to merge 1 commit intoscribe-org:mainfrom
prince-0408 wants to merge 1 commit intoscribe-org:mainfrom
Conversation
…e-org#640 Add didYouMeanSuggestion(for:) helper in CommandVariables that progressively shortens the input word to find the closest prefix match in autocomplete_lexicon (minimum 2 chars). Update all 4 invalid command blocks in KeyboardViewController: - Return key: translate (uses wordToTranslate global) - Return key: conjugate (uses verbToConjugate global) - Translate key with selected text - Conjugate key with selected text - Plural key with selected text Each block shows 'Did you mean: X?' when a close match is found, falls back to existing invalidCommandMsg when no match exists. Existing alreadyPlural behavior is untouched. Closes scribe-org#640
Thank you for the pull request! 💙🩵The Scribe-iOS team will do our best to address your contribution as soon as we can. The following are some important points:
Note Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible. |
Maintainer ChecklistThe following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When a translate, conjugate, or plural command returns no result, instead of showing a generic "Not in Wikidata/Wiktionary" error, the command bar now shows "Did you mean: X?" using the closest match from the autocomplete lexicon.
Closes #640
Problem & Solution
Changes
CommandVariables.swiftdidYouMeanSuggestion(for:)— progressively shortens input to find closest prefix match (min 2 chars)KeyboardViewController.swiftNotes
invalidCommandMsgwhen no match found — zero regression