internal DialogContext(QuestionInfo topic, ResponseBase contextQuestion, IModel handlingModel, SLUFactory factory) { HandlingModel = handlingModel; Factory = factory; Topic = topic; ContextQuestion = contextQuestion; NextMachineOutput = contextQuestion; }
private ResponseBase selectQuestion(QuestionInfo topic, IModel model) { if (topic == null) { return(null); } return(model.PoseQuestions(topic).Except(_discussedQuestions).FirstOrDefault()); }
internal void AddAnswerHint(QuestionInfo questionInfo, ParsedUtterance utterance) { lock (_L_global) { //TODO thread safe var newInfo = questionInfo.WithAnswerHint(utterance); _questionIndex[questionInfo.Utterance.OriginalSentence] = newInfo; commitChanges(); } }
internal void AddQuestion(string question) { lock (_L_global) { if (_questionIndex.ContainsKey(question)) { return; } _questionIndex[question] = new QuestionInfo(UtteranceParser.Parse(question)); commitChanges(); } }
internal QuestionReport(QuestionInfo info, string answerId, LinkBasedExtractor extractor) { var linker = extractor.Linker; Question = linker.LinkUtterance(info.Utterance.OriginalSentence); AnswerLabel = extractor.Db.GetEntryFromId(answerId); var denotations = new List <Tuple <LinkedUtterance, EntityInfo, bool> >(); foreach (var answerHint in info.AnswerHints) { var linkedHint = linker.LinkUtterance(answerHint.OriginalSentence, Question.Entities); var denotation = extractor.ExtractAnswerEntity(info.Utterance.OriginalSentence, answerHint.OriginalSentence).FirstOrDefault(); var item = Tuple.Create(linkedHint, denotation, answerId == FreebaseDbProvider.GetId(denotation.Mid)); denotations.Add(item); } CollectedDenotations = denotations; var denotationCounts = from denotation in denotations group denotation by FreebaseDbProvider.GetId(denotation.Item2.Mid) into grouped select Tuple.Create(grouped.Key, grouped.Count()); var maxDenotation = denotationCounts.OrderByDescending(t => t.Item2).FirstOrDefault(); if (maxDenotation != null && AnswerLabel != null) { HasCorrectDenotation = maxDenotation.Item1 == AnswerLabel.Id; } if (maxDenotation != null) { TopDenotationEvidence = maxDenotation.Item2; } }