Search code examples
pythonmachine-learningartificial-intelligencechatbot

How to categorize unanswered questions of user from a chatbot?


I want to store the unanswered question of user and categorize them into different classes, the unanswered question will be saved in a excel file.


Solution

  • You can create a dictionary of lists with the categories

    categories = {
            "price": [],
            "size": [],
            .
            .
            .
        }
    

    Then go through each categories.keys() and search each key in each question and then append to the list.

    for q in questions: #list of questions
        for k in categories.keys():
            if k in q:
                categories[k].append(q)
    

    It will give you a dictionary of categorised questions. But questions can be repeated in several categories, be careful. (you can pop those questions out)