【问题标题】:!!python/str doesn't work for RasaCore's domain.yml!!python/str 不适用于 RasaCore 的 domain.yml
【发布时间】:2018-08-22 16:29:37
【问题描述】:

我正在研究 Rasa,但在运行对话模型时遇到了一些问题。

python3 -m rasa_core.train -s data/stories.md -d domain.yml -o models/dialogue --epochs 300

错误!

ruamel.yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/str'
in "/my/app/path/venv/lib/python3.6/site-packages/rasa_core/schemas/domain.yml", line 4, column 11

Rasa 核心

从rasa_core查看domain.yml,似乎问题出在双感叹号!!

domain.yml

allowempty: True
mapping:
  intents:
    type: !!python/str "seq"

阅读,来自here 的另一篇关于双感叹号的帖子。

【问题讨论】:

    标签: python yaml


    【解决方案1】:

    您应该考虑自己想做什么,而不是随意尝试。 !!python/str 是表示 Python 字符串类型的标记。所以你当前的 YAML 说“seq is a Python string`”。

    现在您的更改将改为“将以下值加载为您认为合适的任何类型:!!python/str seq”。那是完全不同的事情。

    让我们弄清楚为什么 ruamel 无法识别您的标签。 A quick look in the source 显示 !!python/str 已在标准 Constructor 中注册,但未在 SafeConstructor 中注册。那只有 YAML 的标准标签 !!str 可用。所以很有可能您使用的是SafeConstructor,它根本不知道!!python/str。因此,一个可能的解决方法是使用!!str,而不是在标量上调用相同的构造函数(正如我们在源代码中看到的那样)。

    或者,您可以直接删除标签。标量 seq 无论如何都会被加载到一个字符串中,除非 RasaCore 做了一些意想不到的事情(我实际上对此一无所知)。

    【讨论】:

    • 感谢 flyx 的全面回复。它确实使用您的解决方案工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-05
    • 1970-01-01
    • 2016-04-26
    • 2022-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多