static void Main(string[] args) { string textfile = ""; using (StreamReader fs = new StreamReader(@"C:\Новая папка\1.txt")) { while (true) { string temp = fs.ReadLine(); if (temp == null) { break; } textfile += temp + ':'; } } Console.WriteLine(textfile); Console.ReadKey(); AhoCorasick.Trie trie = new AhoCorasick.Trie(); trie.Add("string"); trie.Build(); string[] matches = trie.Find(textfile).ToArray(); foreach (var item in matches) { Console.WriteLine(item); Console.ReadKey(); } }
public void NoString() { string textfile = ""; using (StreamReader fs = new StreamReader(@"C:\Новая папка\3.txt")) { while (true) { string temp = fs.ReadLine(); if (temp == null) { break; } textfile += temp; } } AhoCorasick.Trie trie = new AhoCorasick.Trie(); trie.Add("NONONO"); trie.Build(); string[] matches = trie.Find(textfile).ToArray(); Assert.AreEqual(0, matches.Length); }
public void Contains() { string text = "string and stringa ta fsd fafad string!"; AhoCorasick.Trie trie = new AhoCorasick.Trie(); trie.Add("sring"); trie.Add("stringa"); trie.Build(); Assert.IsTrue(trie.Find(text).Any()); }
public void String() { string text = "string and stringa ta fsd fafad string!"; AhoCorasick.Trie trie = new AhoCorasick.Trie(); trie.Add("string"); trie.Add("and"); trie.Build(); trie.Add("NONONO"); trie.Add("NaNaNa"); trie.Build(); string[] matches = trie.Find(text).ToArray(); }
public Node(TNode word, Trie <T, TValue> .Node <TNode, TNodeValue> parent) { this.word = word; this.parent = parent; }