private string getRequestedPropertyName(AnalyzedChat analyzedChat)
 {
     foreach (var regex in propertySearch)
     {
         var match = getPropertyMatch(analyzedChat.chat.message, regex);
         if (!string.IsNullOrWhiteSpace(match) && _userNaturalLanguageService.isNaturalLanguagePropertyName(analyzedChat, match))
         {
             return(match);
         }
     }
     return(string.Empty);
 }
Exemplo n.º 2
0
 public UserNameAndProperty GetOtherUserProperty(AnalyzedChat analyzedChat, ConcurrentBag <UserData> users)
 {
     if (!excludePropertySearch.Any(e => analyzedChat.chat.message.ToLower().Contains(e)))
     {
         foreach (var regex in propertySearchUserValueName)
         {
             var match = _propertyMatchService.getPropertyMatchUserValueName(analyzedChat.chat.message, regex);
             if (!string.IsNullOrWhiteSpace(match.userProperty.name) && !string.IsNullOrWhiteSpace(match.userProperty.value) && _userNaturalLanguageService.isNaturalLanguagePropertyName(analyzedChat, match.userProperty.name) && _userNaturalLanguageService.isNaturalLanguagePropertyValue(analyzedChat, match.userProperty.value))
             {
                 var userMatches = users.Where(u => "@" + u.userName == match.userName || u.userName == match.userName);
                 if (userMatches.Count() == 0)
                 {
                     userMatches = users.Where(u => u.nickNames.Contains(match.userName));
                 }
                 if (userMatches.Count() > 0)
                 {
                     match.userProperty.source = analyzedChat.chat.user;
                     return(match);
                 }
             }
         }
         foreach (var regex in selfPropertySearchUserValueName)
         {
             var match = _propertyMatchService.getSelfPropertyMatchUserValueName(analyzedChat.chat.message, regex);
             if (!string.IsNullOrWhiteSpace(match.userProperty.name) && !string.IsNullOrWhiteSpace(match.userProperty.value) && _userNaturalLanguageService.isNaturalLanguageSelfProperty(analyzedChat, match.userProperty.value))
             {
                 var userMatches = users.Where(u => "@" + u.userName == match.userName || u.userName == match.userName);
                 if (userMatches.Count() == 0)
                 {
                     userMatches = users.Where(u => u.nickNames.Contains(match.userName));
                 }
                 if (userMatches.Count() > 0)
                 {
                     match.userProperty.source = analyzedChat.chat.user;
                     return(match);
                 }
             }
         }
     }
     return(new UserNameAndProperty());
 }
Exemplo n.º 3
0
        private UserProperty getPropertyFromResponse(AnalyzedChat analyzedChat, AnalyzedChat question)
        {
            var property = new UserProperty();

            if (!excludePropertySearch.Any(e => analyzedChat.chat.message.ToLower().Contains(e)))
            {
                foreach (var regex in propertySearchNameValue)
                {
                    var match = _propertyMatchService.getPropertyMatchNameValue(analyzedChat.chat.message, regex);
                    if (!string.IsNullOrWhiteSpace(match.name) && !string.IsNullOrWhiteSpace(match.value) && _userNaturalLanguageService.isNaturalLanguagePropertyName(analyzedChat, match.name) && _userNaturalLanguageService.isNaturalLanguagePropertyValue(analyzedChat, match.value))
                    {
                        match.source = analyzedChat.chat.user;
                        match.time   = analyzedChat.chat.time;
                        return(match);
                    }
                }
                foreach (var regex in propertySearchValueName)
                {
                    var match = _propertyMatchService.getPropertyMatchValueName(analyzedChat.chat.message, regex);
                    if (!string.IsNullOrWhiteSpace(match.name) && !string.IsNullOrWhiteSpace(match.value) && _userNaturalLanguageService.isNaturalLanguagePropertyName(analyzedChat, match.name) && _userNaturalLanguageService.isNaturalLanguagePropertyValue(analyzedChat, match.value))
                    {
                        match.source = analyzedChat.chat.user;
                        match.time   = analyzedChat.chat.time;
                        return(match);
                    }
                }
                foreach (var regex in selfPropertySearchValueName)
                {
                    var match = _propertyMatchService.getSelfPropertyMatchValue(analyzedChat.chat.message, regex);
                    if (!string.IsNullOrWhiteSpace(match.value) && _userNaturalLanguageService.isNaturalLanguageSelfProperty(analyzedChat, match.value))
                    {
                        match.source = analyzedChat.chat.user;
                        match.time   = analyzedChat.chat.time;
                        return(match);
                    }
                }
            }
            return(property);
        }