MycroftAI / adapt

Adapt Intent Parser
Apache License 2.0
711 stars 155 forks source link

How to implement IntentBuilder() in for loop? #63

Closed amol4141 closed 3 years ago

amol4141 commented 7 years ago

Hi, I want to implement logic for IntentBuilder() in for loop. I tried following logic but it didn't work. Also my category & subcategory are stored in array.

list=[['category', ['energy', 'equipment']], ['subcategory', [ 'consumption']],['datetime', ['one month data', 'two month data']], ['greet', ['hi', 'hello', 'hey']]]

e.g.: weather_intent = IntentBuilder("WeatherIntent") for i in range(0,len(list)): weather_intent.optionally(list[i][0]) engine.register_intent_parser(weather_intent) .build()

Please help.

clusterfudge commented 3 years ago

Hi @amol4141 , are you still seeing this issue? The formatting on your code makes it a little difficult to diagnose what's happening here, but there are a couple of typos at least. I would probably write the following:

data=[['category', ['energy', 'equipment']], ['subcategory', [ 'consumption']],['datetime', ['one month data', 'two month data']], ['greet', ['hi', 'hello', 'hey']]]
weather_intent = IntentBuilder("WeatherIntent")

for i in range(0,len(data)):
    weather_intent.optionally(data[i][0])
    for value in data[i][1]:
        engine.register_entity(value, data[i][0])

engine.register_intent_parser(weather_intent.build())

Hopefully this helps, I'm going to close as the issue is pretty old.