1

I'm working on an android project where I need to judge/grade user String entries and compare them to a "correct answer", which is also a String. So for example, if I ask the question 'What do you call items given to children during Christmas meant to spark joy in their hearts?', and set the answer to "gifts". In this case, I'd want my algorithm to accept 'gifts', 'gift', 'present', 'presents', 'Christmas gifts', 'Xmas gifts'...etc as correct answers. Sure, I could create an array with all possible answers, but that's not ideal, especially when I'm dealing with longer prose text.

So the question is..are there any recommended algorithms or libraries I could use for this? If not, what are some good alternatives?

ToxicAbe
  • 173
  • 1
  • 11
  • Does this answer your question? [What are some algorithms for comparing how similar two strings are?](https://stackoverflow.com/questions/15303631/what-are-some-algorithms-for-comparing-how-similar-two-strings-are) – Nicolas Dec 14 '20 at 16:01
  • Perhaps [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) measures might be helpful. – rossum Dec 16 '20 at 16:09

1 Answers1

2

There is no best algorithm in general, only the one that works best in your specific case.

But I found some best string matching algorithm for you

Rabin–Karp algorithm is one of the best string searching algorithm

and some other best String matching algorithms
also if you are not getting the answer to your question yet click here

Monu Rohilla
  • 1,311
  • 5
  • 20