Hi! So I am making a Q/A bot and I wanted to know how it is possible to give grades or score to an answer provided by the user (for both subjective and objective type of Q/A). How can we grade them according to how much their answer is matching with our answer? Please help. Thanks
Hi @RDS this is definitely possible, the question-answering logic should happen as part of a custom action. You should have a custom action that is triggered every time the user gives an answer. This custom action will grade the answer, and you can use dispatcher to inform the user of their score.
As for the actual grading, there are several options, ranging in complexity and difficulty to implement. In its simplest form, you could only allow exact matches:
- user: a blue whale - bot: incorrect. the answer is "blue whale"
In your custom action, you would just do:
correct = tracker.latest_message.text == correct_answer
but this may become frustrating for the user. You could also do keywords:
correct = keyword in tracker.latest_message.text
- user: a blue whale - bot: Correct.
More complicated ideas will depend on which kinds of questions you’re asking the user. Some questions, there is only one right answer, and you just need to cover the different ways of writing that answer. A good place to start would be to have a data file (or even database) of the questions you want to ask the user, and the correct answers to them. Then you need to think about what kinds of answers you want to accept (how exact the user needs to be.)