ruby/did_you_mean

Suggestion not provided if the word to check ends up with a number

coorasse opened this issue · 2 comments

sc = DidYouMean::SpellChecker.new(dictionary: [:emailaddress3])

sc.correct('emailAddress')
=> [:emailaddress3]

sc.correct('emailAddresseswe')
=> [:emailaddress3]

sc.correct('emailAddress3')
=> []

I'd expect did_you_mean to be able to suggest emailaddress3 for emailAddress3

I think it's not about the number at the end. It seems that a suggestion is not provided if you try to correct a correct word (i.e. one that is in the dictionary). Take a look:

sc = DidYouMean::SpellChecker.new(dictionary: [:emailaddress])
# => #<DidYouMean::SpellChecker:0x000055eafbd4cb00 @dictionary=[:emailaddress]>
sc.correct('emailAddress')
# => []
sc.correct('emailAddres')
# => [:emailaddress]

Apologies for way overdue reply here. @mrzasa is right, the exact match is intentionally excluded and this is working as expected. Please let me know if you think suggesting the exact match would he helpful.