且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 rasa nlu 进行训练时 ValueError: Unknown data format for file x.json

更新时间:2023-12-02 21:47:58

我得到了解决方案.因此,当我检查时,我发现我的 data.json 文件在 utf-8 fromat 中,这导致了问题,因此我将编码更改为 ANSI 在记事本中解决了.

I'm training a json file data for intent classification using rasa nlu. When I am doing the training with any .md file it is working but when I tried with .json file it is showing error.

I tried to validate the json file it is in correct format.

from rasa_nlu.training_data import load_data
from rasa_nlu.model import Trainer
from rasa_nlu import config
from rasa_nlu.model import Interpreter


def train_rasa(file_path):
    training_data = load_data(file_path)
    trainer = Trainer(config.load("config.yml"))
    trainer.train(training_data)
    model_directory = trainer.persist('models/')
return model_directory

train_rasa('data/testData.json')

Error :

ValueError: Unknown data format for file 'data/testData.json

I got the solution. So when i checked i found out that my data.json file was in utf-8 fromat which is causing problem so i changed the encoding to ANSI in notepad which worked out.