I am working on a vocabulary quiz app (French to English / English to French). I need to check if what user types is what is expected. Example : "Une machine à laver" --> Expected answer is "A washing machine". The user can make many different sorts of mistakes such as spelling : "A watching machine", a word order mistake : "A machine washing" or a total mistake "A garden tool".
I have managed to deal with the checking when the expected word is just one word : "un jardin : a garden".
But with compound words, the issue of words order comes up. I split the Strings into two lists : _expectedAnswer contains the different elements of the answer : [washing,machine] _typedAnswer contains the different elements of what the user typed : [machine, washing] or [watching,machine] or [washing,machine], or [a,washing,machine] (Here, the user added an article before the noun, which shouldn't be seen as a mistake).
At the end, the algorithm must tell the user what type of mistakes he has done :
- Word order mistake.
- Word order is correct, but one or all elements contain spelling problems.
- word order mistake + spelling problems
- completely wrong.
For the spelling check I use the levenstein algorithm. And it is satisfactory.
So first I thought I should check if _typedAnswer contains all the elements of _expectedAnswer. -> Should check if the sequence of elements is the same : the order is OK, and no spelling pb.
-> Elements are all present but sequence is not respected : Problem with word order, no spelling mistakes.
-> Elements are not present --> Then we check if "similar elements" are present (which would indicate user made a spelling mistake) .... and check the order of elements too...
Any advice to help me work out this algorithm ?
I have read a lot about all the functions linked to dart lists, but I have to admit, that I kinda got lost on which one would be pertinent to use...