python - 从 rasa 模型的输出中删除意图排名
问题描述
我已经开发了一个 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() 之前删除数据,反之亦然 ,在运行后输出
只想删除意图排名
解决方案
也许尝试:
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?'))
这是未经测试的,但应该从他的 dict 中删除该密钥。http://docs.python.org/library/stdtypes.html#dict.pop
推荐阅读
- c# - C#-SQL 到 C#-MongoDB 的转换。没有 C#-MongoDB 的 DataAdapter?
- sql - Hive 根据第二列值不同的第二列选择列
- python - 指向外部文件的属性的 shacl 验证错误
- python - 使用 Pandas 从 Excel 获取特定数据并将所有内容转换为字符串以及 NaN
- google-apps-script - 我想写一个谷歌表格程序,当我在今天的某个日期范围内时会发送一封电子邮件
- bash - 编写一个脚本,对于作为参数给出的任何名称,打印具有该名称的人的主目录的路径列表
- reactjs - React Js解析错误:严格模式下不允许遗留八进制文字
- python - 改变硬币的方法数
- swift - 在 Swift 中遵循具有相同变量名的协议时如何避免无限循环?
- r - 使用 R Markdown 在文档中交叉引用