0

I have string called 'fish cakes'. I have an eligible dictionary of words, that contains "lemon", and "fish". I want agrep to match fish cakes to string fish in the eligible dictionary. But it won't work. It'll match fish with fish cakes.

I want it to detect typos of input data, and I have an eligible dictionary of the eligible words. And i want to suggest what was the appropriate word. So if I had lmon I want to say, did you mean 'lemon'. If i had fish cakes, i want to go, did you mean fish?

agrep("fish", c("lemon", "fish cakes"))

Will return index 2, matching it with fish cakes

if I do agrep("fish cakes", c("lemon", "fish"))

It returns nothing, meaning it doesn't match.

Any suggestions? Thanks

  • 3
    Try with `adist` `which.min(adist("fish cakes", v1))# [1] 2` – akrun Feb 13 '20 at 20:58
  • 1
    Sure, I want it to detect typos of input data, and I have an eligible dictionary of the eligible words. And i want to suggest what was the appropriate word. So if I had lmon I want to say, did you mean 'lemon'. If i had fish cakes, i want to go, did you mean fish? – mexicanseafood Feb 13 '20 at 20:58
  • 3
    This works: `max.distance = c(insertions = 6)` but I find it a bit too much :) – Rui Barradas Feb 13 '20 at 21:06

0 Answers0