-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bug with rejecting correct value in spell checker. Fixed #121 #134
Conversation
Thanks for the PR! Overall this looks great, and I think we can merge with a few minor changes. |
|
||
private | ||
|
||
def similar_keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this method exact_matches
as it describes what it does better.
@@ -8,7 +8,13 @@ def initialize(key_error) | |||
end | |||
|
|||
def corrections | |||
@corrections ||= SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) | |||
@corrections ||= similar_keys + SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to only suggest exact matches if they are present, then fall back to the typical spell checking approach. That should by design prevent inaccurate suggestions from creeping into the final results.
@corrections ||= similar_keys + SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) | |
@corrections ||= exact_matches.empty? ? SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) : exact_matches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 👍
Thanks! |
No description provided.