Bot Composer,如何使用 lg 语言遍历字符串的字符?
BotComposer, how to iterate through the characters of a string using lg language?
我们需要从短语中提取数字。例如:
"hey, 1234" -> “1234”
"ok, 4567" -> “4567”
"b3456f" -> “3456”
但是我们没有找到如何仅使用 Bot Composer 的语言生成器来遍历字符串。
我们尝试这样的事情:
join(foreach(createArray("ab c"), x, concat(x, '-')), '')
但是没有结果...是否有任何预构建函数可以将简单的字符串转换为字符数组,以便我们可以使用 foreach 逐个字符地迭代?
谢谢!
如果您知道格式将得到很好的控制,您可以考虑使用 Regex 来执行此操作,但另一种选择是查看 LUIS language understanding services from Microsoft, which are built exactly for understanding different parts of a text message, especially in a bot context. Here's a link to getting started,对于 C#(在菜单上link 下面是一个 Node 示例,如果您需要的话)。
还有一个 tag here on Stack Overflow 专注于 LUIS,如果您 运行 遇到麻烦或需要更多帮助。
希望对您有所帮助
[更新] 我重新阅读了您的问题,现在我发现它是关于 BotComposer,而不是定制开发的机器人。因此,我 link 编辑的示例无效,但 LUIS 肯定有效。我自己没有使用过 Bot Composer,但 LUIS 已集成为其中的一部分 - 请参阅 here。
据我所知,这目前是不可能的,因为无法遍历字符串或按字符将字符串拆分为新数组。 I've opened a GitHub issue to request it as an enhancement。
对于:
- "hey, 1234" -> “1234”
- "ok, 4567" -> “4567”
您可以使用 split()
.
不幸的是,您的 "b3456f" -> "3456" 示例不走运,除非您知道它将以那种确切的格式出现,在这种情况下,您可以使用 substring()
.
我们需要从短语中提取数字。例如:
"hey, 1234" -> “1234”
"ok, 4567" -> “4567”
"b3456f" -> “3456”
但是我们没有找到如何仅使用 Bot Composer 的语言生成器来遍历字符串。
我们尝试这样的事情:
join(foreach(createArray("ab c"), x, concat(x, '-')), '')
但是没有结果...是否有任何预构建函数可以将简单的字符串转换为字符数组,以便我们可以使用 foreach 逐个字符地迭代?
谢谢!
如果您知道格式将得到很好的控制,您可以考虑使用 Regex 来执行此操作,但另一种选择是查看 LUIS language understanding services from Microsoft, which are built exactly for understanding different parts of a text message, especially in a bot context. Here's a link to getting started,对于 C#(在菜单上link 下面是一个 Node 示例,如果您需要的话)。
还有一个 tag here on Stack Overflow 专注于 LUIS,如果您 运行 遇到麻烦或需要更多帮助。
希望对您有所帮助
[更新] 我重新阅读了您的问题,现在我发现它是关于 BotComposer,而不是定制开发的机器人。因此,我 link 编辑的示例无效,但 LUIS 肯定有效。我自己没有使用过 Bot Composer,但 LUIS 已集成为其中的一部分 - 请参阅 here。
据我所知,这目前是不可能的,因为无法遍历字符串或按字符将字符串拆分为新数组。 I've opened a GitHub issue to request it as an enhancement。
对于:
- "hey, 1234" -> “1234”
- "ok, 4567" -> “4567”
您可以使用 split()
.
不幸的是,您的 "b3456f" -> "3456" 示例不走运,除非您知道它将以那种确切的格式出现,在这种情况下,您可以使用 substring()
.