public void ParseDictionaryOption_WithKeyOnlyArgument_ReturnsFailedResult(TemporaryDirectoryFixture tempDirectory) { // arrange DictionaryOption dictOption = DictionaryOption.Create("dictionary", "kvp"); string key = "key1"; string[] args = { "--kvp", key }; // act var result = dictOption.Parse(args); // assert Assert.False(result.Success); Assert.Contains("Error", result.ErrorMessage); Assert.Contains("format", result.ErrorMessage); }
public Boolean DoesWordExist(String word, DictionaryOption option) { var trimmedWord = word.Trim().ToLower(); bool found = false; lock (locker) { GetSmallerWordsCount(originalWords, trimmedWord, out found); if (!found && option == DictionaryOption.IncludingStemming) { var stemmedWord = trimmedWord.GetStemmedQuery(); if (!stemmedWord.Equals(word)) { GetSmallerWordsCount(stemmedWords, stemmedWord, out found); } } return(found); } }
public void AddWords(IEnumerable<String> words, DictionaryOption option) { var addedWords = new List<String>(); var originalWordsToAdd = SelectingWordsAddToDictionary(words).ToList(); var stemmedWordsToAdd = new List<String>(); if (option == DictionaryOption.IncludingStemming) { var stems = originalWordsToAdd.Select(DictionaryHelper.GetStemmedQuery); stemmedWordsToAdd.AddRange(stems); } lock (locker) { addedWords.AddRange(AddWordsToList(originalWords, originalWordsToAdd)); AddWordsToList(stemmedWords, stemmedWordsToAdd); } addWordsEvent(addedWords); rawWordsEvent(originalWordsToAdd); }
public void AddWords(IEnumerable <String> words, DictionaryOption option) { var addedWords = new List <String>(); var originalWordsToAdd = SelectingWordsAddToDictionary(words).ToList(); var stemmedWordsToAdd = new List <String>(); if (option == DictionaryOption.IncludingStemming) { var stems = originalWordsToAdd.Select(DictionaryHelper.GetStemmedQuery); stemmedWordsToAdd.AddRange(stems); } lock (locker) { addedWords.AddRange(AddWordsToList(originalWords, originalWordsToAdd)); AddWordsToList(stemmedWords, stemmedWordsToAdd); } addWordsEvent(addedWords); rawWordsEvent(originalWordsToAdd); }
public void ParseDictionaryOption_WithMultipleKeyValueArguments_ReturnsDictionary(TemporaryDirectoryFixture tempDirectory) { // arrange DictionaryOption dictOption = DictionaryOption.Create("dictionary", "kvp"); string key1 = "key1"; string value1 = "value1"; string key2 = "key2"; string value2 = "value2"; string[] args = { "--kvp", $"{key1}, {value1}", "--kvp", $"{key2}, {value2}" }; // act var result = dictOption.Parse(args); // assert Assert.Equal("", result.ErrorMessage); Assert.True(result.Success); Assert.Equal(value1, result.Result[key1]); Assert.Equal(value2, result.Result[key2]); }
public Boolean DoesWordExist(String word, DictionaryOption option) { word = word.Trim(); return word.Equals(String.Empty) || dictionary.DoesWordExist(word, option); }
public Boolean DoesWordExist(String word, DictionaryOption option) { var trimmedWord = word.Trim().ToLower(); bool found = false; lock (locker) { GetSmallerWordsCount(originalWords, trimmedWord, out found); if (!found && option == DictionaryOption.IncludingStemming) { var stemmedWord = trimmedWord.GetStemmedQuery(); if (!stemmedWord.Equals(word)) { GetSmallerWordsCount(stemmedWords, stemmedWord, out found); } } return found; } }
public Boolean DoesWordExist(String word, DictionaryOption option) { word = word.Trim(); return(word.Equals(String.Empty) || dictionary.DoesWordExist(word, option)); }