private void AutocompleteForm_Load(object sender, EventArgs e) { var phraseGenerator = CreatePhraseGenerator(); if (phraseGenerator == null) { Environment.Exit(-1); } var phrases = phraseGenerator.Generate().Take(1500 * 1000).ToList(); phrases.Sort(); autocompleter = new Autocompleter(phrases.ToArray()); }
private void AutocompleteForm_Load(object sender, EventArgs e) { string filename = "..\\..\\..\\words.txt"; if (!File.Exists(filename)) { MessageBox.Show( string.Format( "Не найден файл со словарем {0}\r\nВозможно вы забыли распаковать файл words.zip", Path.GetFullPath(filename)), "Ошибка"); Environment.Exit(1); } autocompleter = new Autocompleter(File.ReadAllLines(filename)); }
public void FindRightttIndex() { var completer = new autocomplete.Autocompleter(new String[] { "abc", "abcd", "bfb", "bfe", "bfzsd" }); var result = completer.FindLimitIndex("bf", "right"); Assert.AreEqual(4, result); }
public void FindCountTest() { var completer = new autocomplete.Autocompleter(new String[] { "abc", "abcd", "bfb", "bfe", "bfzsd" }); var result = completer.FindCount("bf"); Assert.AreEqual(3, result); }
public void FindByPrefixTest() { var completer = new autocomplete.Autocompleter(new String[] { "abc", "abcd", "afb", "afe", "azsd" }); var result = completer.FindByPrefix("az"); Assert.AreEqual("azsd", result); }