public void ScannerWithRelevantKeys() { var result = new Dictionary <string, string>(); DictionaryScanner.Parse(Input, RelevantKeys, result); if (result.Count != 50) { throw new InvalidOperationException($"ScannerWithRelevantKeys: result.Count={result.Count}"); } }
public void Scanner() { var result = new Dictionary <string, string>(); DictionaryScanner.Parse(Input, result); if (result.Count != 100) { throw new InvalidOperationException($"Scanner: result.Count={result.Count}"); } }
private async void UpdateMisspelledWords() { var keys = misspelledWords.Keys.ToArray(); foreach (var key in keys) { misspelledWords[key] = await Task.Run(() => DictionaryScanner.FindSimilarWords(key, MaxResults, LevDistance, HowManyChanges) ); } }
// Add word to dictionary if it's not already in it private async void AddWordToDictionary(string word) { try { if (!misspelledWords.ContainsKey(word)) { misspelledWords.Add( word, await Task.Run(() => DictionaryScanner.FindSimilarWords(word, MaxResults, LevDistance, HowManyChanges)) ); } } catch { } }
private static void CheckParsedDictionary(string input, Dictionary <string, string> expectedResult, params string[] relevantKeys) { var actualResult = new Dictionary <string, string>(); if (relevantKeys.Length == 0) { DictionaryScanner.Parse(input, actualResult); } else { var dictionaryRelevantKeys = new DictionaryRelevantKeys(relevantKeys); dictionaryRelevantKeys.Clear(); DictionaryScanner.Parse(input, dictionaryRelevantKeys, actualResult); } DictionaryAssert.AreEqual(expectedResult, actualResult); }
/// <summary> /// Check spelling of word parameter /// </summary> /// <param name="word"></param> /// <returns>true if word is correct and false if it's not</returns> public bool CheckWord(string word) { if (correctWords.Contains(word)) // if word was already checked and is correct { return(true); } else if (misspelledWords.ContainsKey(word)) // if word was already checked and is misspelled { return(false); } else if (!DictionaryScanner.IsLowerWordInDictionary(ref word)) // if word was never checked and it's misspelled { AddWordToDictionary(word); return(false); } correctWords.Add(word); return(true); }
private void Start(string word, int count, int distance, int howManyChanges) { var result = new List <string>(); Boolean isGood = false; string copy = word; if (!DictionaryScanner.IsLowerWordInDictionary(ref word) && word.Length > 1) { result = DictionaryScanner.FindSimilarWords(word, count, distance, howManyChanges); } else { if (copy != word) { result.Add(word); } else { isGood = true; } } if (isGood) { AppendTextBoxes(tbList.Text, Color.Green); } else { var list = ""; if (result.Count != 0) { foreach (var item in result) { list += (item + "\r\n"); } AppendTextBoxes(list, Color.Red); } else { AppendTextBoxes("Brak", Color.Red); } } }
public SpellCheckManager() { GetDictionary(out Dictionary dictionary); DictionaryScanner.AddDictionary(dictionary); }
public List <string> RawSpellingPropositions(string word) { return(DictionaryScanner.FindSimilarWords(word, MaxResults, LevDistance, HowManyChanges)); }
public Form1() { InitializeComponent(); GetDictionary(out Dictionary dictionary); DictionaryScanner.AddDictionary(dictionary); }