コード例 #1
0
        public bool UpdateDatabases(ChatRequest chat)
        {
            var          conversation = _conversationService.GetConversation(chat);
            AnalyzedChat inResponseTo = null;

            if (conversation.responses.Count() > 1)
            {
                inResponseTo = conversation.responses[conversation.responses.Count() - 2];
            }
            var analyzedConversation = _analyzationService.AnalyzeConversationAsync(conversation);
            var conversationUdpdated = _covnersationUpdateService.UpdateConversation(analyzedConversation, chat.type);

            _userService.UpdateUsers(analyzedConversation.responses.Last(), inResponseTo);

            return(conversationUdpdated);
        }
コード例 #2
0
        public ConcurrentDictionary <string, ConversationList> LoadConversations()
        {
            var analyzationVersion = ConfigurationService.AnalyzationVersion;

            var conversationLists = new ConcurrentDictionary <string, ConversationList>();

            foreach (var directory in Directory.GetDirectories(_databaseDirectory))
            {
                conversationLists[Path.GetFileName(directory)] = LoadConversationList(directory);
            }

            foreach (var conversationList in conversationLists)
            {
                foreach (var conversation in conversationList.Value.conversations)
                {
                    if (conversation.Value.analyzationVersion != analyzationVersion)
                    {
                        var analyzedConversation = _analyzationService.AnalyzeConversationAsync(conversation.Value);
                        conversationLists[conversationList.Key].conversations[conversation.Key] = analyzedConversation;
                        var json = JsonConvert.SerializeObject(analyzedConversation);
                        File.WriteAllText(_databaseDirectory + "\\" + conversationList.Value.type + "\\" + analyzedConversation.name + ".json", json, Encoding.Unicode);
                    }
                }
            }

            return(conversationLists);
        }
コード例 #3
0
        public ChatResponse ProcessChat(ChatRequest chat)
        {
            var conversation         = _conversationService.GetConversation(chat);
            var analyzedConversation = _analyzationService.AnalyzeConversationAsync(conversation);
            var conversationUdpdated = _covnersationUpdateService.UpdateConversation(analyzedConversation, chat.type);

            AnalyzedChat inResponseTo = null;

            if (analyzedConversation.responses.Count() > 1)
            {
                inResponseTo = analyzedConversation.responses[analyzedConversation.responses.Count() - 2];
            }
            _userService.UpdateUsers(analyzedConversation.responses.Last(), inResponseTo);

            return(GetChatResponse(conversation, chat.exclusiveTypes, chat.requiredPropertyMatches, chat.excludedTypes, chat.subjectGoals));
        }