Getting error when I am trying to access training_data

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)

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)

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.

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.

got it.

Thank you.