【问题标题】:Using regex with enitities in Rasa NLU在 Rasa NLU 中使用正则表达式和实体
【发布时间】:2020-06-26 20:50:30
【问题描述】:

我正在尝试在实体提取中使用正则表达式来扩展训练集。它只识别训练示例中的单词。 对于“检查体式是否有新数据”,它只识别“新”。

Your input ->  check asana for new data                                                                                                                     
Are you asking for new

我在 nlu.md 中的意图和实体:

## regex:task_name
-  [a-zA-Z0-9\\s]*

## intent: check_asana
- check asana for [jobs on linkedin](task_name)
- check asana for [job interviews](task_name)
- check asana for [new opportunities](task_name)
- check asana for [finding job opportunities](task_name)
- check asana for [finding jobs on linkedin](task_name)
- check asana for [handling the rasa example](task_name)
- check asana
  • 更新自
## intent: check_asana
- check asana for [jobs on linkedin](task_name)
- check asana for [job interviews](task_name)
- check asana for [new opportunities](task_name)
- check asana


## regex:task_name
-  [^\\s]*

在 domain.yml 中,实体和槽:


entities:
  - task_name

slots:
  task_name:
    type: text
#    auto_fill: false

在 config.yml 我使用管道:

language: en
pipeline:
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100

【问题讨论】:

  • 那么,如果你需要匹配任何文本,使用.*,为什么使用[^\\s]*
  • 我试过了,还是不行。我认为问题出在我的配置上,而不是正则表达式。

标签: regex rasa-nlu rasa


【解决方案1】:

正则表达式功能适用于具有非常规则模式的实体,例如邮政编码或房间号。在这种情况下使用它们没有意义;您的实体没有明显的模式。

用于实体提取的正则表达式为实体提取器提供了一个特征,即“是的,这个正则表达式在这个句子/这个短语中匹配”。您的正则表达式基本上会匹配每一个句子,因此它对您没有任何用处。

我建议完全删除正则表达式并提供更多实体示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-04
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    • 2017-01-18
    相关资源
    最近更新 更多