Search code examples
pythonjsontags

how to prefer json tag over other tags


{"intents": [
      {"tag": "name",
        "patterns": ["Hi", "How are you", "Is anyone there?", "Hello", "yes", "yeah", "can you help 
                      me"],
        "responses": ["hello! i am bot here to help you, whats your name"],
        "context_set": ""
      },

    {"tag": "age",
        "patterns": ["name is",],
        "responses": ["what is your age?"],
        "context_set": ""
      },

    {"tag": "dept",
        "patterns": ["age is"],
        "responses": ["which department you're looking for?"],
        "context_set": ""
      }
]}

hey, i am new to python and wanted to make a bot. I am using one json intent file to save response and patterns and the problem is i wanted to ask only 3 question 1.name 2.age 3.department, but i want my json file to have every other detail like timing and other stuff relevant, but i want to prefer these 3 questions over other questions how can i do that? second question is what kind of neural network will helps this bot to learn while running.


Solution

  • There is no preference in JSON. You must do the order.

    Did you mean the preference in the dictionary/key pair used to generate the JSON?

    If yes, you could refer to this link to find out how to enforce mandatory keys in a python dictionary using a custom function: Dictionary with some mandatory keys as function input