Getting error when I am trying to access training_data - Getting Started with Rasa / Tutorials, Resources & Videos - Rasa Community Forum

👋 Introducing the Rasa Playground

Getting error when I am trying to access training_data

post by prithvini04 on Jun 14, 2019

TypeError: ‘TrainingData’ object is not iterable

I am getting the above error when I am doing this in custom component:


def train(self, training_data, cfg, **kwargs):
    print("I am in train")
    for item in training_data:
        print(item)

post by erohmensing on Jun 17, 2019

Hi there @prithvini04! Your training_data parameter is not a list, but rather a TrainingData class of its own found in rasa/nlu/training_data/training_data.py. It’s always good to check the types of the parameters you are using and check out the class in the source code if you run into issues. I believe what you want is


for item in training_data.training_examples:
    print(item)

post by prithvini04 on Jun 19, 2019

hi, Yes I could now able to access from training_data.training_examples.

Couldn’t find the rasa/nlu/training_data/training_data.py in my local system. RASA is installed. where can I find it.

post by erohmensing on Jun 24, 2019

I’m not sure, it depends on your system. If you installed it in a virtual environment, it’s probably in there. You’d have to do a search on your machine for training_data.py.

post by prithvini04 on Jun 25, 2019

got it.

Thank you.