无法加载python模型

时间:2019-08-12 11:10:09

标签: python rasa-nlu

我有问题。我正在遵循此指南: https://medium.com/@itsromiljain/build-a-conversational-chatbot-with-rasa-stack-and-python-rasa-nlu-b79dfbe59491

安装过程一切正常,所以我想运行最终代码:

import logging
import pprint
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.model import Interpreter
from rasa_nlu.test import run_evaluation


logfile = 'nlu_model.log'


def train_nlu(data_path, configs, model_path):
    logging.basicConfig(filename=logfile, level=logging.DEBUG)
    training_data = load_data(data_path)
    trainer = Trainer(config.load(configs))
    trainer.train(training_data)
    model_directory = trainer.persist(model_path, project_name='current', fixed_model_name='nlu')
    run_evaluation(data_path, model_directory)


def run_nlu(nlu_path):
    logging.basicConfig(filename=logfile, level=logging.DEBUG)
    interpreter = Interpreter.load(nlu_path)
    pprint.pprint(interpreter.parse("Share some latest news around the world?"))
    pprint.pprint(interpreter.parse("What is going on in technology?"))
    pprint.pprint(interpreter.parse("What is going on in education?"))


if __name__ == '__main__':
    train_nlu('./data/nlu.md', 'nlu_config.yml', './models')
    run_nlu('./models/current/nlu')

但这在这条线上给了我一个错误:

train_nlu('./data/nlu.md', 'nlu_config.yml', './models')

,显示错误:

  

OSError:[E050]找不到型号'en'。这似乎不是一个   快捷方式链接,Python包或数据目录的有效路径。

但是我已将en模型与此命令链接:

python3 -m spacy link en_core_web_md en

有人知道我在做什么错吗?

0 个答案:

没有答案