from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# from rasa_nlu.converters import load_data
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
#from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer, Metadata, Interpreter
from rasa_nlu import config
def train (data, config_file, model_dir):
training_data = load_data(data)
configuration = config.load(config_file)
trainer = Trainer(configuration)
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name = 'chat')
def run():
interpreter = Interpreter.load('./models/nlu/default/chat')
print(interpreter.parse('buy a pendrive from amazon'))
#print(interpreter.parse(u'What is the reivew for the movie Die Hard?'))
if __name__ == '__main__':
#train('./data/testData.json', './config/config.yml', './models/nlu')
run()
为了保留数据,请在训练之前删除注释,然后对run()进行注释,反之亦然 output after running
只想删除意图排名
答案 0 :(得分:0)
也许尝试:
def run():
interpreter = Interpreter.load('./models/nlu/default/chat')
parseResult = interpreter.parse('buy a pendrive from amazon')
parseResult.pop("intent_ranking", None)
print(parseResult)
#print(interpreter.parse(u'What is the reivew for the movie Die Hard?'))
未经测试,但应从他的命令中删除该键。 http://docs.python.org/library/stdtypes.html#dict.pop