从rasa模型的输出中删除意图排名

时间:2018-08-22 14:16:28

标签: python machine-learning nlp rasa-nlu

我已经开发了一个rasa意图分类模型,该模型可以从训练数据中显示正确的意图和实体,但是除此之外,它还显示了与其他所有意图的意图排名,我不希望被显示出来,有人可以帮助我删除该意图吗?从我的输出感谢您的帮助。 该模型的代码是.......

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

只想删除意图排名

1 个答案:

答案 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