public List <ConversationMatchList> GetConversationMatchLists(Conversation targetConversation, List <ConversationList> conversationLists, List <string> subjectGoals) { var pathSubjects = getPathSubjects(targetConversation, conversationLists, subjectGoals); var conversationMatchLists = new List <ConversationMatchList>(); foreach (var conversationList in conversationLists) { var conversationMatchList = new ConversationMatchList { type = conversationList.type, matchConversations = new ConcurrentBag <MatchConversation>() }; Parallel.ForEach(conversationList.conversations, (conversationKeyValuePair) => { var conversation = conversationKeyValuePair.Value; if (conversation.name != targetConversation.name && targetConversation.analyzationVersion != null) { var matchConversation = new MatchConversation { name = conversation.name, responses = new List <MatchChat>() }; var subjectMatchConfidence = _subjectConfidenceService.GetSubjectMatchConfidence(targetConversation, conversation); var readingLevelMatchConfidence = _readingLevelConfidenceService.GetReadingLevelConfidence(targetConversation.readingLevel, conversation.readingLevel); for (var index = 0; index < conversation.responses.Count(); index++) { var userlessReply = string.Empty; if (index + 1 < conversation.responses.Count()) { userlessReply = conversation.responses[index + 1].naturalLanguageData.userlessMessage; } var matchChat = GetMatch(targetConversation, conversation.responses[index], subjectMatchConfidence, readingLevelMatchConfidence, conversation.groupChat, userlessReply, pathSubjects); matchConversation.responses.Add(matchChat); } conversationMatchList.matchConversations.Add(matchConversation); } }); conversationMatchLists.Add(conversationMatchList); } return(conversationMatchLists); }
private bool userMatch(MatchConversation conversation, int index, List <UserData> matchingUsers) { return(matchingUsers.Any(user => user.userName == conversation.responses[index].analyzedChat.chat.user)); }