What is the strategy to identify a correct answer, without an exact comparison of String?

0

I have a program in C # that is like a QUESTIONNAIRE, however instead of alternatives there are times when the user must enter a response. The answer to the question is stored in a database and at that time the program only considers the response containing the exact STRING saved in the database to be correct.

How could I change this? I would like to use the same answers as the bank, but I need a margin of acceptance in the responses typed.

    
asked by anonymous 03.05.2015 / 17:47

2 answers

2

The algorithm that the @bruno indicated in the comments (Levenshtein distance) is a good algorithm to determine the similarity of two strings. There is a somewhat more robust one, called Damerau-Levenshtein which also considers the transposition of two characters adjacent - that is, it takes into account some simple spelling errors.

But I suggest rethinking the questionnaire design.

Fuzzy search, and calculation of similarity of strings, cause bad user experience in this case. Let's say we use Levenshtein's algorithm and we determine that the response given by the user may differ from the response in the database by 10 characters, maximum.

What if my answer has 11 different characters? Is it necessarily wrong? Why is a response with 10 different characters correct, and my answer is not?

Furthermore, these algorithms only tell us how many characters are different - but they do not tell us what, or what they mean. I can add 15 characters to an answer without changing its meaning - but I can also add only a comma, and radically change its meaning.

It is for these reasons that most computerized questionnaires are of multiple choice - and the questionnaires with open answer questions are usually hand-scanned by a human.

    
03.05.2015 / 18:35
0

It depends on how flexible you want the answers to be. This is a design issue that depends on your product. Some ideas:

You can try more advanced solutions, such as check the similarity between strings and set a certain threshold of acceptance.

Again, this depends on your project.

    
03.05.2015 / 17:59