Пример #1
0
        private void btnTestWord_Click(object sender, RoutedEventArgs e)
        {
            String Result;

            if (m_WordList == null)
            {
                WordList temp = new WordList();
                m_WordList = temp.LoadXML("d:\\ocr\\wordlist.xml");
            }

            lstWordResult.Items.Clear();

            Result = m_WordList.Contains(txtWord.Text, false);

            if (Result.ToLower() == txtWord.Text.ToLower())
            {
                lstWordResult.Items.Add("Found: " + Result);
            }
            else
            {
                lstWordResult.Items.Add("Not found");

                List <SuggestionEntry> Suggestions = m_WordList.Suggestions(txtWord.Text);

                foreach (SuggestionEntry Suggestion in Suggestions)
                {
                    lstWordResult.Items.Add(Suggestion.Suggestion + " (" + Suggestion.EditDistance + ")");
                }
            }
        }
Пример #2
0
        public void open(string filename)
        {
            WordList currentWords = WordListFromText.get(new TextLoader(filename));

            newWords = new WordList();

            // remove trash and known
            foreach (string str in currentWords)
            {
                bool bypass = true;
                foreach (IWordFilter filter in filters)
                {
                    if (!filter.bypass(str))
                    {
                        bypass = false;
                        break;
                    }
                }
                if (!bypass)
                {
                    continue;
                }

                // no duplicates
                if (newWords.Contains(str))
                {
                    continue;
                }

                // add to new words
                newWords.Add(str);
            }
        }
Пример #3
0
        private void SaveWord(object sender, ExecutedRoutedEventArgs e)
        {
            string oldName     = CurrentWordForm == null ? null : CurrentWordForm.WordInfo.Word.Name;
            string newName     = (EditableWord.Name ?? "").Trim();
            string description = EditableWord.Description;
            string tags        = EditableWord.Tags;

            if (oldName != newName && WordList.Contains(newName))
            {
                throw new Exception(string.Format("Word '{0}' is present in dictionary already.", newName));
            }

            if (oldName == null)
            {
                WordList.Add(newName, description, tags);
            }
            else
            {
                WordList.Update(oldName, newName, description, tags);
            }

            EditableWord = null;
            SearchText   = newName;
            MarkSearchPending();
        }
Пример #4
0
 public bool Contains(Word word)
 {
     if (wordSet != null)
     {
         return(wordSet.Contains(word));
     }
     return(false);
 }
Пример #5
0
 public bool Contains(Word word)
 {
     if (head.Text == word.Text)
     {
         return(true);
     }
     return(tags.Contains(word));
 }
Пример #6
0
 public bool bypass(string word)
 {
     if (wordList == null)
     {
         return(true);
     }
     return(!wordList.Contains(word));
 }
Пример #7
0
        public void Words_Uses_Words_From_Basic_List_Only()
        {
            var words = Lorem.Words(WordList.Length, supplemental: false);

            foreach (var word in words)
            {
                Assert.IsTrue(WordList.Contains(word),
                              $"Locale '{Locale}'. Word missing from word list '{word}'"
                              );
            }
        }
Пример #8
0
        public void checkNAdd(Word word)
        {
            Word word2BChanged = new Word();

            if (WordList.Contains(word))
            {
                WordList.ElementAt <Word>(WordList.IndexOf(word)).AdditionalInfo = word.AdditionalInfo;
                WordDaoImpl dao = new WordDaoImpl();
                dao.updateNote(word);
            }
        }
Пример #9
0
        public void Question_Without_Supplementary_List()
        {
            const int wordCount  = 50;
            var       question   = Lorem.Question(wordCount);
            var       checkCount = 0;

            foreach (var word in question.ToWordList())
            {
                checkCount++;
                Assert.IsTrue(WordList.Contains(word),
                              $"Locale '{Locale}'. Missing word is '{word}'"
                              );
            }
            Assert.AreEqual(wordCount, checkCount);
        }
Пример #10
0
        private static void AddCommand(string msg)
        {
            bool IsCommand = false;

            char[] command = { '.', 'b', 'l', 'o', 'c', 'k', ' ' };

            for (int i = 0; i < 6; i++)
            {
                if (msg.ElementAt(i) == command[i])
                {
                    IsCommand = true;
                    continue;
                }
                else
                {
                    IsCommand = false;
                    break;
                }
            }

            if (!IsCommand)
            {
                return;
            }

            if (!WordList.Contains(msg.Remove(0, 7)))
            {
                WordList.Add(msg.Remove(0, 7));
                Core.DelayAction(delegate
                {
                    if (WordList.Contains(msg.Remove(0, 7)))
                    {
                        Chat.Print("Successfuly Added Word To The List!");
                    }
                    else
                    {
                        Chat.Print("Failed To Add New Word To The List!");
                    }
                }, 50);
                return;
            }
            else
            {
                Chat.Print("This Word Is Already In The List!");
            }

            return;
        }
Пример #11
0
        private List <string> GetNextFunnelLayer(string word)
        {
            var nextFunnelLayer = new List <string>();

            for (int i = 0; i < word.Length; i++)
            {
                string funneledWord = word.Remove(i, 1);

                if (WordList.Contains(funneledWord))
                {
                    nextFunnelLayer.Add(funneledWord);
                }
            }

            return(nextFunnelLayer);
        }
Пример #12
0
        public bool IsValidWord(string boggleBoxId, string word)
        {
            BoggleBox foundBox = RegisteredBoggleBoxes.Find(x => x.BoggleBoxID.ToString() == boggleBoxId);

            if (foundBox == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            if (WordList.Contains(word.ToLower()))
            {
                return(true);
            }

            return(false);
        }
Пример #13
0
        public void Words_With_WordCount()
        {
            const int wordCount = 42;
            var       words     = Lorem.Words(wordCount);

            Assert.AreEqual(wordCount, words.Count());
            Assert.AreEqual(0, words.Count(x => string.IsNullOrWhiteSpace(x)));
            foreach (var word in words)
            {
                if (JointWords.Contains(word))
                {
                    continue;
                }
                Assert.True(WordList.Contains(word),
                            $"Locale '{Locale}'. Word missing from word list '{word}'"
                            );
                Assert.False(SupplementalWordList.Contains(word));
            }
        }
Пример #14
0
        internal void FindChildrenNodes(TreeNode parent, string target)
        {
            if (!WordList.Contains(target))
            {
                return;
            }

            var children = WordList.Where(o => parent.Value.IsSimilar(o)).ToList();

            WordList.RemoveAll(o => children.Any(s => s == o));

            var childNodes = children.Select(o => new TreeNode {
                ParentId = parent.Id, Parent = parent, Value = o
            }).ToList();

            foreach (var child in childNodes)
            {
                child.Id = NodeQueue.Last().Id + 1;
                NodeQueue.Enqueue(child);
            }
        }
Пример #15
0
        public void Words_Locale_Ko()
        {
            Config.Locale = "ko";
            var someWords = new[] { "아니하며", "보호한다" };

            foreach (var word in someWords)
            {
                Assert.IsTrue(WordList.Contains(word),
                              $"Missing word is '{word}'. {WordList} is '{string.Join('|', WordList.ToArray())}'"
                              );
            }

            var tries = 100;

            while (--tries > 0)
            {
                var someOtherWord = Lorem.Word();
                Assert.IsTrue(WordList.Contains(someOtherWord),
                              $"Missing word is '{someOtherWord}'"
                              );
            }
        }