public string[] SplitNormalize(string input) { StringBuilder result = new StringBuilder(); // objects for normalization of the input LIAM.Normalize.ApplySubstitutions substitutor = new LIAM.Normalize.ApplySubstitutions(this.process); LIAM.Normalize.StripIllegalCharacters stripper = new LIAM.Normalize.StripIllegalCharacters(this.process); string substitutedInput = substitutor.Transform(input); // split the pattern into it's component words return(substitutedInput.Split(" \r\n\t".ToCharArray())); }
public string Normalize(string input, bool isUserInput) { StringBuilder result = new StringBuilder(); // objects for normalization of the input LIAM.Normalize.ApplySubstitutions substitutor = new LIAM.Normalize.ApplySubstitutions(this.process); LIAM.Normalize.StripIllegalCharacters stripper = new LIAM.Normalize.StripIllegalCharacters(this.process); 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 }