如何使Microsoft LUIS区分大小写?

问题描述 投票:1回答:2

我有一个用于NLP的Azure LUIS实例,尝试使用RegEx表达式提取字母数字值。它运行良好,但是输出以小写字母输出。

例如:

案例1 *

我的输入:“为AE0002运行作业” RegExCode = [a-zA-Z]{2}\d+

输出:

{
  "query": " run job for AE0002",
  "topScoringIntent": {
    "intent": "Run Job",
    "score": 0.7897274
  },
  "intents": [
    {
      "intent": "Run Job",
      "score": 0.7897274
    },
    {
      "intent": "None",
      "score": 0.00434472738
    }
  ],
  "entities": [
    {
      "entity": "ae0002",
      "type": "Alpha Number",
      "startIndex": 15,
      "endIndex": 20
    }
  ]
} 

我需要保持输入的大小写。

案例2] >>

我的输入:“仅提取诸如HP和IBM之类的缩写” RegExCode = [A-Z]{2,}

输出:

{
  "query": "extract only abreaviations like hp and ibm", // Query accepted by LUIS test window
  "query": "extract only abreaviations like HP and IBM", // Query accepted as an endpoint url
  "prediction": {
    "normalizedQuery": "extract only abreaviations like hp and ibm",
    "topIntent": "None",
    "intents": {
      "None": {
        "score": 0.09844558
      }
    },
    "entities": {
      "Abbre": [
        "extract",
        "only",
        "abreaviations",
        "like",
        "hp",
        "and",
        "ibm"
      ],
      "$instance": {
        "Abbre": [
          {
            "type": "Abbre",
            "text": "extract",
            "startIndex": 0,
            "length": 7,
            "modelTypeId": 8,
            "modelType": "Regex Entity Extractor",
            "recognitionSources": [
              "model"
            ]
          },
          {
            "type": "Abbre",
            "text": "only",
            "startIndex": 8,
            "length": 4,
            "modelTypeId": 8,
            "modelType": "Regex Entity Extractor",
            "recognitionSources": [
              "model"
            ]
          },....          
          {
            "type": "Abbre",
            "text": "ibm",
            "startIndex": 39,
            "length": 3,
            "modelTypeId": 8,
            "modelType": "Regex Entity Extractor",
            "recognitionSources": [
              "model"
            ]
          }
        ]
      }
    }
  }
}

这使我怀疑整个培训是否都以小写形式进行,令我震惊的是,最初针对其各自实体训练的所有单词都被重新培训为Abbre] >>] >>

任何输入都会有很大的帮助:)

谢谢

我有一个用于NLP的Azure LUIS实例,尝试使用RegEx表达式提取字母数字值。它运行良好,但是输出以小写字母输出。例如:案例1 *我的输入:...

您可以简单地使用输出中提供的单词索引从输入字符串中获取与提供的值完全相同的值。

{
  "query": " run job for AE0002",
  ...
  "entities": [
    {
      "entity": "ae0002",
      "type": "Alpha Number",
      "startIndex": 15,
      "endIndex": 20
    }
  ]
} 

[得到此回复后,请在查询中使用substring方法,并使用startIndexendIndex(如果您的方法需要长度而不是结束索引,则使用endIndex - startIndex),以获取值您正在寻找。

对于案例1,是否需要保留案例以查询系统上的作业?只要工作标识符始终具有大写字符,您就可以使用toUpperCase(),例如var jobName = step._info.options.entities.Alpha_Number.toUpperCase()(不确定字母数字的下划线,我之前从未有过带空格的实体)。

对于情况2,这是LUIS应用程序的缺点。您可以使用(?-i)(例如/(?-i)[A-Z]{2,}/g)在正则表达式中强制区分大小写。但是,LUIS似乎首先将所有内容都转换为小写,因此您永远都不会在该语句中找到任何匹配项(这比匹配每个单词要好,但这并不多说!)。我不知道以任何方式让LUIS识别您所请求的实体。

您可以使用期望的所有缩写创建一个列表实体,但是根据期望的输入,可能难以维护。加上也是单词的缩写将被当作假阳性(例如CAT和cat)。您也可以在LUIS之外编写一个函数为您完成此任务,基本上是建立自己的手动实体检测。在确定缩写词之后,可能还会根据您要执行的操作提供一些其他解决方案。

nlp botframework microsoft-cognitive luis
2个回答
1
投票

您可以简单地使用输出中提供的单词索引从输入字符串中获取与提供的值完全相同的值。

{
  "query": " run job for AE0002",
  ...
  "entities": [
    {
      "entity": "ae0002",
      "type": "Alpha Number",
      "startIndex": 15,
      "endIndex": 20
    }
  ]
} 

0
投票

对于案例1,是否需要保留案例以查询系统上的作业?只要工作标识符始终具有大写字符,您就可以使用toUpperCase(),例如var jobName = step._info.options.entities.Alpha_Number.toUpperCase()(不确定字母数字的下划线,我之前从未有过带空格的实体)。

对于情况2,这是LUIS应用程序的缺点。您可以使用(?-i)(例如/(?-i)[A-Z]{2,}/g)在正则表达式中强制区分大小写。但是,LUIS似乎首先将所有内容都转换为小写,因此您永远都不会在该语句中找到任何匹配项(这比匹配每个单词要好,但这并不多说!)。我不知道以任何方式让LUIS识别您所请求的实体。

您可以使用期望的所有缩写创建一个列表实体,但是根据期望的输入,可能难以维护。加上也是单词的缩写将被当作假阳性(例如CAT和cat)。您也可以在LUIS之外编写一个函数为您完成此任务,基本上是建立自己的手动实体检测。在确定缩写词之后,可能还会根据您要执行的操作提供一些其他解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.