public void FindPrefixTapsTops() { var words = new[] { "tap", "taps", "top", "tops" }; var dawg = Dawg.CreateBuilder(words).Build(); var array = dawg.WithPrefix("to").ToArray(); Assert.Contains("top", array); Assert.Contains("tops", array); array = dawg.WithPrefix("tap").ToArray(); Assert.Contains("tap", array); Assert.Contains("taps", array); Assert.Empty(dawg.WithPrefix("tu")); array = dawg.WithPrefix("t").ToArray(); Assert.Contains("tap", array); Assert.Contains("taps", array); Assert.Contains("top", array); Assert.Contains("tops", array); }
protected override IPrefixMatcher Build(string dictionaryFile) { using (var dictionarySource = new WordDictionary(dictionaryFile)) { var dawgBuilder = Dawg.CreateBuilder(dictionarySource); var dawg = dawgBuilder.Build(); return(new PrefixMatcher(dawg)); } }
public void Case15() { var words = new[] { "AAHS", "AALIIS", "AALS" }; var builder = Dawg.CreateBuilder(words); }
public void Case7() { var words = new[] { "bcn", "acn", "bon", "boa", "asn" }; var builder = Dawg.CreateBuilder(words).Build(); Assert.True(builder.Contains("boa")); }
public void Case14() { var words = new[] { "RIG", "RIN", "RIE" }; var dawg = Dawg.CreateBuilder(words).Build(); var array = dawg.WithPrefix("R").ToArray(); Assert.Equal(3, array.Length); }
public void Case8() { var words = new[] { "AAHEED", "AAHED", "OOHED", "AALID", "AAED" }; var builder = Dawg.CreateBuilder(words).Build(); Assert.True(builder.Contains("AAHED")); Assert.False(builder.Contains("AAHEDS")); Assert.False(builder.Contains("AHAED")); }
public void FindPrefix() { var words = new[] { "ba", "ab", "aa", "bb" }; var dawg = Dawg.CreateBuilder(words).Build(); var array = dawg.WithPrefix("b").ToArray(); Assert.Contains("bb", array); Assert.Contains("ba", array); array = dawg.WithPrefix("a").ToArray(); Assert.Contains("aa", array); Assert.Contains("ab", array); Assert.Empty(dawg.WithPrefix("t")); }