本文整理汇总了TypeScript中botbuilder.EntityRecognizer.findEntity方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EntityRecognizer.findEntity方法的具体用法?TypeScript EntityRecognizer.findEntity怎么用?TypeScript EntityRecognizer.findEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botbuilder.EntityRecognizer
的用法示例。
在下文中一共展示了EntityRecognizer.findEntity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
(session: builder.Session, args: any, next?: (results?: builder.IDialogResult<any>) => void) => {
let place: IStoredData;
let heathplace: boolean = false
if (args && args.intent) {
let intent = args.intent;
// Get Place.Type and Place.Location entities
let typeEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Place.Type') as IEntityEx;
let locationEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Place.Location') as IEntityEx;
place = session.dialogData.place = {
type: typeEntity ? typeEntity.resolution.values[0] : undefined,
location: locationEntity ? locationEntity.entity : undefined,
};
// We want to manage only medical places
heathplace = place.type == 'hospital' || place.type == 'pharmacy';
}
if (!heathplace) {
builder.Prompts.choice(session, "choice_prompt", "hospital|pharmacy", { listStyle: ListStyle.button });
}
else {
if (next) return next();
}
},
示例2: processLanguage
private processLanguage(session: Session, args, next) {
console.log('processing language');
var name = EntityRecognizer.findEntity(args.entities, 'CharacterName');
var realm = EntityRecognizer.findEntity(args.entities, 'RealmName');
var charData = session.dialogData.character = {
name: name && name.entity,
realm: realm && realm.entity
};
if (!charData.name) {
Prompts.text(session, "What is the name of the character?");
} else {
next();
}
}
示例3: if
(session: any, args: any, next: any) => {
var brand = builder.EntityRecognizer.findEntity(args.entities, 'PcBrand');
var type = builder.EntityRecognizer.findEntity(args.entities, 'PcType');
var price: any = {
'price' : builder.EntityRecognizer.findEntity(args.entities, 'PcPrice'),
'startPrice' : builder.EntityRecognizer.findEntity(args.entities, 'PcPrice::startPrice'),
'endPrice' : builder.EntityRecognizer.findEntity(args.entities, 'PcPrice::endPrice')
};
var cam: any = null;
if (builder.EntityRecognizer.findEntity(args.entities, 'PcCam::With')) {
cam = true;
} else if (builder.EntityRecognizer.findEntity(args.entities, 'PcCam::Without')) {
cam = false;
}
var got_price: any = null;
for (var key in price) {
if (price[key]) {
got_price = true;
price[key] = price[key].entity;
}
}
session.userData.profile = {
brand: brand ? brand.entity : null,
type: type ? type.entity : null,
price: got_price ? price : null,
cam: cam
};
next();
},
示例4: function
function(session, args, next) {
console.log("args :: \n" + JSON.stringify(args.entities));
var symbol = builder.EntityRecognizer.findEntity(args.entities, 'company');
if (!symbol) {
builder.Prompts.text(session, "Which company stock you are intrested in?");
} else {
next({ response: symbol.entity });
}
},
示例5: next
(session: Session, luisResults: IIntentRecognizerResult, next: (results?: IDialogResult<any>) => void) => {
const languageEntity = EntityRecognizer.findEntity(luisResults.entities, 'language');
const language = languageEntity && languageEntity.entity;
if (!language) {
Prompts.choice(session, 'master.languageSelection', Object.keys(languages),
{ listStyle: ListStyle.button, maxRetries: 3, retryPrompt: 'master.retryLanguageSelection' });
} else {
next({ response: { entity: language }});
}
},
示例6: async
async (session: builder.Session, args: any, next?: (results?: builder.IDialogResult<any>) => void) => {
let data: IInformationStoredData | undefined = undefined;
// Get the Medication entity
if (args && args.intent) {
let intent = args.intent;
let medicationEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Medication.Name') as IEntityEx;
let typeEntity: IEntityEx = builder.EntityRecognizer.findEntity(intent.entities, 'Medication.Type') as IEntityEx;
data = session.dialogData.drug = {
name: medicationEntity ? medicationEntity.entity : undefined,
type: typeEntity ? typeEntity.resolution : undefined
}
}
if (data && data.name) {
if (next) return next();
}
else {
session.send("drugs_help_tip_image");
return builder.Prompts.text(session, "medication_prompt")
}
},
示例7: function
builder.LuisDialog.recognize(session.message.text, modelUri, function (err, intents, entities) {
if (null != err) {
session.endDialog("Unexpected error while parsing your answer. Try again after sometime!");
return;
}
session.userData.nameAlreadyAsked = true;
var entity = builder.EntityRecognizer.findEntity(entities, 'name');
if (null != entity) {
session.userData.name = entity.entity;
session.beginDialog("/showOffer");
}
else {
session.send("I am sorry, i did not understand your answser. Please provide your name again.");
//session.replaceDialog("/userProfile");
}
});
示例8: function
function (session, args) {
//session.userData.selectedPackageName = "Custom TV Essentials";
//session.send("From:" + session.message.from.channelId);
var entity = builder.EntityRecognizer.findEntity(args.entities, 'tv-package-name');
if (null != entity) {
var tvPackageName = entity.entity;
if (null != tvPackageName) {
tvPackageName = tvPackageName.replace(/\s+/g, '');
if (session.userData.selectedPackageName != fiosTVPackages[tvPackageName]) {
session.userData.selectedPackageName = fiosTVPackages[tvPackageName];
//session.send("Your current selection: " + session.userData.selectedPackageName);
var packageInfo = "Your current selection: " + session.userData.selectedPackageName;
builder.Prompts.confirm(session, packageInfo + "<br/>Are you looking for any specific channels in your package?");
}
}
}
},