public void TestSplitWithNoValidResults() { AimlBot.Bot bot = new AimlBot.Bot(); bot.SentenceSplittingTokens = new char[] { '.', '!', '?', ':' }; AimlBot.Normalize.Std.SentenceSplit s = new AimlBot.Normalize.Std.SentenceSplit(); string[] result = s.Normalize(@"... !! ???? : : : ...", bot); Assert.AreEqual(0, result.Length); }
public void TestSplitWithNoTokens() { AimlBot.Bot bot = new AimlBot.Bot(); bot.WordSplittingTokens = new char[0]; AimlBot.Normalize.Std.WordSplit w = new AimlBot.Normalize.Std.WordSplit(); string[] result = w.Normalize("word1 word2", bot); Assert.AreEqual(11, result.Length); Assert.AreEqual("word1 word2", String.Join(string.Empty, result)); }
public void TestSplitWithNoTokens() { AimlBot.Bot bot = new AimlBot.Bot(); bot.SentenceSplittingTokens = new char[0]; AimlBot.Normalize.Std.SentenceSplit s = new AimlBot.Normalize.Std.SentenceSplit(); string[] result = s.Normalize("Sentence 1... Sentence 2!! Sentence 3???? Sentence 4: : : Sentence 5...", bot); Assert.AreEqual(1, result.Length); Assert.AreEqual("Sentence 1... Sentence 2!! Sentence 3???? Sentence 4: : : Sentence 5...", result[0]); }
public void TestPatternFit() { AimlBot.Bot bot = new AimlBot.Bot(); bot.PatternFitExclusions = new System.Text.RegularExpressions.Regex("[^a-zA-Z]"); AimlBot.Normalize.Std.PatternFit pf = new AimlBot.Normalize.Std.PatternFit(); string result = pf.Normalize("!this\"is@a2TeSt", bot)[0]; Assert.AreEqual(" THIS IS A TEST", result); }
public void TestSplitWithNoValidResults() { AimlBot.Bot bot = new AimlBot.Bot(); bot.WordSplittingTokens = new char[] { ' ', '\t', '\r', '\n' }; AimlBot.Normalize.Std.WordSplit w = new AimlBot.Normalize.Std.WordSplit(); string[] result = w.Normalize(@" ", bot); Assert.AreEqual(0, result.Length); }
public void TestSplitWithEmptySentences() { AimlBot.Bot bot = new AimlBot.Bot(); bot.SentenceSplittingTokens = new char[] { '.', '!', '?', ':' }; AimlBot.Normalize.Std.SentenceSplit s = new AimlBot.Normalize.Std.SentenceSplit(); string[] result = s.Normalize("Sentence 1... Sentence 2!! Sentence 3???? Sentence 4: : : Sentence 5...", bot); Assert.AreEqual(5, result.Length); Assert.AreEqual("Sentence 1", result[0]); Assert.AreEqual("Sentence 2", result[1]); Assert.AreEqual("Sentence 3", result[2]); Assert.AreEqual("Sentence 4", result[3]); Assert.AreEqual("Sentence 5", result[4]); }
public void TestBasicSplit() { AimlBot.Bot bot = new AimlBot.Bot(); bot.WordSplittingTokens = new char[] { ' ', '\t', '\r', '\n' }; AimlBot.Normalize.Std.WordSplit w = new AimlBot.Normalize.Std.WordSplit(); string[] result = w.Normalize(@"word1 word2 word3 word4", bot); Assert.AreEqual(4, result.Length); Assert.AreEqual("word1", result[0]); Assert.AreEqual("word2", result[1]); Assert.AreEqual("word3", result[2]); Assert.AreEqual("word4", result[3]); }
public void TestSubstituteWithKeyValueMatches() { AimlBot.Bot bot = new AimlBot.Bot(); Dictionary<string, string> subs = new Dictionary<string, string>(); subs.Add("aaa", "aab"); subs.Add("aab", "aba"); subs.Add("aba", "baa"); bot.CreateSubstitutionGraph(subs); AimlBot.Normalize.Std.Substitute s = new AimlBot.Normalize.Std.Substitute(); string result = s.Normalize("aa aaa aab aba baa", bot)[0]; Assert.AreEqual("aa aab aba baa baa", result); }
public void TestSubstituteSimple() { AimlBot.Bot bot = new AimlBot.Bot(); Dictionary<string, string> subs = new Dictionary<string, string>(); subs.Add("aaa", "xxx"); subs.Add("bbb", "yyy"); subs.Add("ccc", "zzz"); bot.CreateSubstitutionGraph(subs); AimlBot.Normalize.Std.Substitute s = new AimlBot.Normalize.Std.Substitute(); string result = s.Normalize("aa ccc cc aaa abc bbb bb", bot)[0]; Assert.AreEqual("aa zzz cc xxx abc yyy bb", result); }
public void TestSubstituteWithKeyValueMatches() { AimlBot.Bot bot = new AimlBot.Bot(); Dictionary <string, string> subs = new Dictionary <string, string>(); subs.Add("aaa", "aab"); subs.Add("aab", "aba"); subs.Add("aba", "baa"); bot.CreateSubstitutionGraph(subs); AimlBot.Normalize.Std.Substitute s = new AimlBot.Normalize.Std.Substitute(); string result = s.Normalize("aa aaa aab aba baa", bot)[0]; Assert.AreEqual("aa aab aba baa baa", result); }
public void TestSubstituteSimple() { AimlBot.Bot bot = new AimlBot.Bot(); Dictionary <string, string> subs = new Dictionary <string, string>(); subs.Add("aaa", "xxx"); subs.Add("bbb", "yyy"); subs.Add("ccc", "zzz"); bot.CreateSubstitutionGraph(subs); AimlBot.Normalize.Std.Substitute s = new AimlBot.Normalize.Std.Substitute(); string result = s.Normalize("aa ccc cc aaa abc bbb bb", bot)[0]; Assert.AreEqual("aa zzz cc xxx abc yyy bb", result); }