Skip to content

Show closest word suggestion on invalid Translate or Conjugate#655

Open
garvitkaushik-123 wants to merge 1 commit into
scribe-org:mainfrom
garvitkaushik-123:feat/did-you-mean-suggestion
Open

Show closest word suggestion on invalid Translate or Conjugate#655
garvitkaushik-123 wants to merge 1 commit into
scribe-org:mainfrom
garvitkaushik-123:feat/did-you-mean-suggestion

Conversation

@garvitkaushik-123

Copy link
Copy Markdown

Summary

  • When a Translate or Conjugate command returns invalid, the command bar now shows "Did you mean: X?" using the closest match from the existing queryAutocompletions infrastructure
  • Falls back to the existing "Not in Wikidata/Wiktionary" error message when no suggestion is available
  • Covers all three invalid paths: typed command via return key, and selected-text Translate/Conjugate via the Scribe key menu

Changes

File Change
CommandVariables.swift Added didYouMeanWord variable to hold the suggestion
Translate.swift Query autocompletions for closest match when translation fails
Conjugate.swift Query autocompletions for closest match when verb not found
KeyboardViewController.swift Display "Did you mean: X?" in command bar when suggestion exists

Notes

  • No new DB queries needed — reuses LanguageDBManager.shared.queryAutocompletions(word:)
  • Purely additive — no existing logic removed
  • "Did you mean" strings are hard-coded for now pending i18n entry

Fixes #640

Test plan

  • Type an invalid/misspelled word in Translate mode → verify "Did you mean: X?" appears
  • Type an invalid/misspelled verb in Conjugate mode → verify "Did you mean: X?" appears
  • Select text and use Translate with an invalid word → verify suggestion appears
  • Select text and use Conjugate with an invalid verb → verify suggestion appears
  • Enter complete nonsense with no close matches → verify fallback to "Not in Wikidata/Wiktionary"
  • Verify Plural command still shows original error (not affected)

…command

When a user enters a word that isn't found during Translate or Conjugate,
the command bar now shows "Did you mean: X?" using the closest match from
the autocomplete lexicon, instead of a generic error message. Falls back
to the existing "Not in Wikidata/Wiktionary" message when no suggestion
is available.

Fixes scribe-org#640
@github-actions

Copy link
Copy Markdown

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:

  • Those interested in developing their skills and expanding their role in the community should read the mentorship and growth section of the contribution guide
  • If you're not already a member of our public Matrix community, please consider joining!
    • We'd suggest that you use the Element client as well as Element X for a mobile app
    • Join the General and iOS rooms once you're in
  • Also consider attending our bi-weekly Saturday developer syncs!
    • Details are shared in the General room on Matrix each Wednesday before the sync
    • It would be great to meet you 😊

Note

Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible.

@github-actions

Copy link
Copy Markdown

Maintainer Checklist

The 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 :)

  • Tests for changes have been written and the CI unit test, linting and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First PR Commit Check

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution
    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local Scribe-iOS repo (can be set with git config --global user.email "GITHUB_EMAIL")

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.

Show closest word suggestion when translation or conjugation is invalid

1 participant