我用rasa nlu训练数据。根据http://nlu.rasa.ai/python.html中的文档,必须使用以下代码来训练文件demo中存在的数据-rasa.json文件在
from rasa_nlu.converters import load_data
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer
training_data = load_data('data/examples/rasa/demo-rasa.json')
trainer = Trainer(RasaNLUConfig("sample_configs/config_spacy.json"))
trainer.train(training_data)
model_directory = trainer.persist('./projects/default/')
但是我们如何从json对象中读取数据进行训练呢。在
有一种简单的方法可以做到这一点,但是由于RASA的代码文档很差,所以很难找到它。在
您必须按照以下格式创建一个json。在
在这个JSON培训中,示例是一个列表,它应该包含如下所示的数据。在
^{pr2}$有了这个,你就可以这样训练了:)
我做了一个flask应用程序,它从请求体获取JSON对象,而不是从文件中读取它。在
这段代码使用spaCy for entities和sklearn crfsuite转换现有的LUIS json,用于意图识别。在
如果您查看^{} 的实现,它将执行两个步骤:
最简单的解决方案是将json对象写入file或StringIO对象。在
或者,您可以选择所需的特定加载函数,例如^{} ,并将读取的文件与它分开。对于这个例子,您可能只需要获取整个函数并删除^{} 行。在
我有点惊讶地发现,目前还没有办法读取已经加载的json对象。如果您决定让函数适应这种情况,您可以考虑为此编写一个pull请求。在
相关问题 更多 >
编程相关推荐