예제 #1
0
        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);
        }
예제 #2
0
            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);
                }
            }
예제 #3
0
            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);
            }
예제 #4
0
            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);
            }
예제 #5
0
        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);
 }
예제 #7
0
 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;
     }
 }
예제 #8
0
 public Boolean DoesWordExist(String word, DictionaryOption option)
 {
     word = word.Trim();
     return(word.Equals(String.Empty) || dictionary.DoesWordExist(word, option));
 }