Node.js 如何让LuisReceigner为每种语言提供单独的模型
我想创建一个多语言机器人,我使用LUIS来处理自然语言,但我想知道如何在同一个机器人中创建两个模型,每种语言一个 我知道这是可能的,因为od: 如果你使用像LUIS这样的系统来执行自然语言 处理您可以使用单独的模型配置您的LuisReceigner 对于bot支持的每种语言,SDK将自动 选择与用户首选区域设置匹配的模型 我怎样才能做到这一点?我试过这个:Node.js 如何让LuisReceigner为每种语言提供单独的模型,node.js,botframework,microsoft-cognitive,azure-language-understanding,Node.js,Botframework,Microsoft Cognitive,Azure Language Understanding,我想创建一个多语言机器人,我使用LUIS来处理自然语言,但我想知道如何在同一个机器人中创建两个模型,每种语言一个 我知道这是可能的,因为od: 如果你使用像LUIS这样的系统来执行自然语言 处理您可以使用单独的模型配置您的LuisReceigner 对于bot支持的每种语言,SDK将自动 选择与用户首选区域设置匹配的模型 我怎样才能做到这一点?我试过这个: // Configure bots default locale and locale folder path. bot.set('loca
// Configure bots default locale and locale folder path.
bot.set('localizerSettings', {
botLocalePath: "./locale",
defaultLocale: "es"
});
// Create LUIS recognizer.
//LUIS English
var model = 'https://api.projectoxford.ai/luis/v2.0/apps/....';
var recognizer = new builder.LuisRecognizer(model);
//LUIS Spanish
var model_es = 'https://api.projectoxford.ai/luis/v2.0/apps/...';
var recognizer_es = new builder.LuisRecognizer(model_es);
var dialog = new builder.IntentDialog({ recognizers: [recognizer, recognizer_es] });
//=========================================================
// Bots Dialogs
//=========================================================
bot.dialog('/', dialog);
谢谢以下是一个机器人程序示例,它使用两种语言,并允许用户在模型之间切换:
var model_en = 'https://api.projectoxford.ai/luis/v2.0/apps/{YOUR ENGLISH MODEL}';
var model_es = 'https://api.projectoxford.ai/luis/v2.0/apps/{YOUR SPANISH MODEL}';
var recognizer = new builder.LuisRecognizer({'en': model_en, 'es' : model_es});
//=========================================================
// Bots Dialogs
//=========================================================
var intents = new builder.IntentDialog({ recognizers: [recognizer] });
intents.matches('hello', function (session) {
session.send('Hello!');
});
intents.matches('goodbye', function (session) {
session.send('Goodbye!');
});
intents.matches('spanish', function (session) {
session.send('Switching to Spanish Model');
session.preferredLocale('es');
});
intents.matches('english', function (session) {
session.send('Switching to English Model');
session.preferredLocale('en');
});
intents.matches('None', function (session) {
if (session.preferredLocale() == 'en')
{
session.send('I do not understand');
}
else
{
session.send('No entiendo');
}
});
bot.dialog('/', intents);
以下是使用两种语言并允许用户在模型之间切换的bot示例:
var model_en = 'https://api.projectoxford.ai/luis/v2.0/apps/{YOUR ENGLISH MODEL}';
var model_es = 'https://api.projectoxford.ai/luis/v2.0/apps/{YOUR SPANISH MODEL}';
var recognizer = new builder.LuisRecognizer({'en': model_en, 'es' : model_es});
//=========================================================
// Bots Dialogs
//=========================================================
var intents = new builder.IntentDialog({ recognizers: [recognizer] });
intents.matches('hello', function (session) {
session.send('Hello!');
});
intents.matches('goodbye', function (session) {
session.send('Goodbye!');
});
intents.matches('spanish', function (session) {
session.send('Switching to Spanish Model');
session.preferredLocale('es');
});
intents.matches('english', function (session) {
session.send('Switching to English Model');
session.preferredLocale('en');
});
intents.matches('None', function (session) {
if (session.preferredLocale() == 'en')
{
session.send('I do not understand');
}
else
{
session.send('No entiendo');
}
});
bot.dialog('/', intents);