Exemple #1
0
        /// <summary>
        /// Given an input, provide a normalized output
        /// </summary>
        /// <param name="input">The string to be normalized</param>
        /// <param name="isUserInput">True if the string being normalized is part of the user input path -
        /// flags that we need to normalize out * and _ chars</param>
        /// <returns>The normalized string</returns>
        private string Normalize(string input, bool isUserInput)
        {
            StringBuilder result = new StringBuilder();

            string substitutedInput = _substitutor.Transform(input);

            // split the pattern into it's component words
            string[] substitutedWords = substitutedInput.Split(" \r\n\t".ToCharArray());

            // Normalize all words unless they're the AIML wildcards "*" and "_" during AIML loading
            foreach (string word in substitutedWords)
            {
                string normalizedWord;
                if (isUserInput)
                {
                    normalizedWord = _stripper.Transform(word);
                }
                else
                {
                    if ((word == "*") || (word == "_"))
                    {
                        normalizedWord = word;
                    }
                    else
                    {
                        normalizedWord = _stripper.Transform(word);
                    }
                }
                result.Append(normalizedWord.Trim() + " ");
            }

            return(result.ToString().Replace("  ", " ")); // make sure the whitespace is neat
        }
        // Token: 0x06000066 RID: 102 RVA: 0x000047D4 File Offset: 0x000037D4
        public string Normalize(string input, bool isUserInput)
        {
            StringBuilder          stringBuilder          = new StringBuilder();
            ApplySubstitutions     applySubstitutions     = new ApplySubstitutions(this.bot);
            StripIllegalCharacters stripIllegalCharacters = new StripIllegalCharacters(this.bot);
            string text = applySubstitutions.Transform(input);

            string[] array = text.Split(" \r\n\t".ToCharArray());
            foreach (string text2 in array)
            {
                string text3;
                if (isUserInput)
                {
                    text3 = stripIllegalCharacters.Transform(text2);
                }
                else if (text2 == "*" || text2 == "_")
                {
                    text3 = text2;
                }
                else
                {
                    text3 = stripIllegalCharacters.Transform(text2);
                }
                stringBuilder.Append(text3.Trim() + " ");
            }
            return(stringBuilder.ToString().Replace("  ", " "));
        }