feat: use nouns table for alphabetical autocompletions (#596)#652
Conversation
- Add queryNounAutocompletions(word:) to LanguageDBManager that queries all singular (key) columns from the language data contract numbers section using a UNION ALL across those columns with LIKE prefix% - Update queryAutocompletions(word:) to fall back to noun-based completions when the autocomplete_lexicon returns no results - Results are deduplicated, sorted COLLATE NOCASE ASC, limited to 3 Closes scribe-org#596
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 :) |
|
Looks good to me |
|
Thanks, @henrikth93! Great to have the review support :) |
henrikth93
left a comment
There was a problem hiding this comment.
Looks good to me! I tested it and it works.
andrewtavis
left a comment
There was a problem hiding this comment.
praise: Happy to be able to bring in one of these iOS PRs, @prince-0408 :) Thanks for the review, @henrikth93! Really is great to work with you both here 😊
|
Hmmmm weird, it looks like the tests failed after merging this. See here. @prince-0408, would you want to file an issue and take a look? |
Summary
Implements the noun table fallback for alphabetical autocompletions as described in #596. When the
autocomplete_lexiconreturns no results (e.g. for a new language without a valid Trie structure), the keyboard now falls back to querying the nouns table directly using the language's data contract.Closes #596
Changes
LanguageDBManager.swiftqueryNounAutocompletions(word:)ContractManager, extracts all singular key columns from thenumberssection, builds aUNION ALLSQL query matching rows where the value starts with the typed prefix (case-insensitiveLIKE), and returns up to 3 deduplicated, alphabetically sorted (COLLATE NOCASE ASC) resultsqueryAutocompletions(word:)autocomplete_lexiconas before (existing behaviour preserved) — falls back toqueryNounAutocompletions(word:)when the lexicon returns empty resultsHow It Works Per Language
Each language's YAML contract defines the
numberssection differently:singularnominativeSingularmasculineSingular,feminineSingularnominativeIndefiniteSingular,nominativeDefiniteSingularThe implementation is fully contract-driven — it works automatically for any language that has a valid
numberssection, including future languages.