public void UpdateContextWithNewItem(ConversationContext context, NlpAnalysis nlpAnalysis, SearchQuery searchQuery, bool isRelevant) { context.ContextItems.Add(new ContextItem { NlpAnalysis = nlpAnalysis, SearchQuery = searchQuery, Relevant = isRelevant, }); }
private bool IsIntentRelevant(NlpAnalysis nlpAnalysis) { var mostConfidentIntent = nlpAnalysis.Intents.OrderByDescending(x => x.Confidence).First(); if (mostConfidentIntent.Confidence < this._minimumRelevantConfidence) { return(true); } return(!this._irrelevantIntents.Any(x => Regex.IsMatch(mostConfidentIntent.Name, this.WildCardToRegularExpression(x)))); }
internal bool IsQueryRelevant(NlpAnalysis nlpAnalysis) { nlpAnalysis.Intents.ForEach(x => Log.Debug($"Intent - Name: {x.Name}, Confidence: {x.Confidence}")); nlpAnalysis.Entities.ForEach(x => Log.Debug($"Entity - Name: {x.Name}")); return(this.IsIntentRelevant(nlpAnalysis)); }
private void SetUpNLPCallMockToReturn(NlpAnalysis nlpAnalysis) { this._nlpCallMock .Setup(x => x.GetNlpAnalysis(It.IsAny <string>())) .Returns(nlpAnalysis); }
public ContextItemBuilder WithNlpAnalysis(NlpAnalysis nlpAnalysis) { this._nlpAnalysis = nlpAnalysis; return(this); }
private ContextItemBuilder() { this._nlpAnalysis = NlpAnalysisBuilder.Build.Instance; this._searchQuery = SearchQueryBuilder.Build.Instance; this._relevant = false; }
private void SetUpNLPCallMockToReturn(NlpAnalysis nlpAnalysis, bool isRelevant) { this._nlpCallMock .Setup(x => x.AnalyzeSearchQuery(It.IsAny <SearchQuery>(), out isRelevant)) .Returns(nlpAnalysis); }