2017-09-04 77 views
1

是否有可能獲得IntentDialogs的概率分數(0-1)?所以我想知道機器人對於回答這個問題有多大的自信,並且基於它我想要執行某些操作。我怎樣才能做到這一點?我正在使用QnAMaker以及一些硬編碼的對話框。BotFramework:獲得IntentDialog的概率分數

示例代碼:

var qnarecognizer = new cognitiveservices.QnAMakerRecognizer({ 
    knowledgeBaseId: '', 
    subscriptionKey: '', 
    top:4}); 

var intentrecognizer = new builder.IntentDialog(); 

var intents = new builder.IntentDialog({ recognizers: [intentrecognizer, qnarecognizer] }); 
bot.dialog('/', intents); 

intents.matches('qna', [ 
    function (session, args, next) { 
     var answerEntity = builder.EntityRecognizer.findEntity(args.entities, 'answer'); 
     session.send(answerEntity.entity); 
    } 
]); 

intents.matchesAny([/Test/i], [ 
     function (session) { 
      session.send('This is not from QnA Maker.'); 
     } 
]); 

intents.onDefault([ 
     function (session) { 
      session.send('Sorry, I don\'t know that.'); 
     } 
]); 

回答

2

的分數是在實體本身的屬性。以下將通過向用戶發送一條消息來回復相應得分的每個qna答案:

intents.matches('qna', [ 
    function (session, args, next) { 
     args.entities.forEach(function(element) { 
      session.send('score=' + element.score + ':' + element.entity); 
     }, this); 
    } 
]); 
0

你可以找到findBestMatchhere。正如你可以看到你可以通過以下獲得比賽:

var matches = EntityRecognizer.findAllMatches(choices, utterance, threshold); 

而且比賽的比分讓喜歡以下內容:

matches[i].score 
+0

我收到一個錯誤,說EntityRecognizer沒有定義。我不知道我需要在哪裏以及如何定義它。 – Anish