Exemplo n.º 1
0
        private List <Word> searchSingleCharacterAndLength(char ch, Language language, int length)
        {
            List <Word> words;

            words = WordService.getInstance().getByFirstCharacterAndLength(language, ch, length, true);
            return(words);
        }
Exemplo n.º 2
0
        public bool addDictionaryFromFile(Language language, string path)
        {
            if (DatabaseController.getInstance().checkTableExists(language.ToString()))
            {
                return(false);
            }
            List <Word> words = new List <Word>();

            if (!File.Exists(path))
            {
                throw new Exceptions.WordControllerFileNotFoundException(path);
            }
            else
            {
                foreach (string wordstring in File.ReadLines(path))
                {
                    if (Word.isVaild(wordstring))
                    {
                        words.Add(new Word(wordstring));
                    }
                    else
                    {
                        log.Info(String.Format("{0} was not added to database, because it is not forged only from letters", wordstring));
                    }
                }
            }
            return(WordService.getInstance().saveList(words, language));
        }
Exemplo n.º 3
0
        private void button_submit_Click(object sender, RoutedEventArgs e)
        {
            int numbOfResults;

            int.TryParse(txt_result_no.Text, out numbOfResults);

            SearchEngine seng       = new SearchEngine(numbOfResults);
            List <char>  characters = new List <char>();

            foreach (TextBox textBox in txt_chars)
            {
                if (textBox.Text.Length > 0)
                {
                    characters.Add(textBox.Text.ToLower()[0]);
                }
            }

            List <Word> wordList;

            if (!txt_length.Text.Equals(String.Empty))
            {
                int expLenght = int.Parse(txt_length.Text);
                wordList = seng.search(characters, SelectedLang, expLenght);
                wordList = wordList.FindAll(w => (w.Length == expLenght));
            }
            else
            {
                wordList = seng.search(characters, ProgramTech.Language.EN);
            }
            datagrid_words.ItemsSource = wordList;

            WordService.getInstance().Dispose();
        }
Exemplo n.º 4
0
        public bool downloadDictionary(Language language, string url)
        {
            if (DatabaseController.getInstance().checkTableExists(language.ToString()))
            {
                return(false);
            }

            List <Word> words = new List <Word>();

            try
            {
                using (var client = new WebClient())
                {
                    using (System.IO.StringReader reader = new System.IO.StringReader(client.DownloadString(new Uri(url))))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            if (Word.isVaild(line))
                            {
                                words.Add(new Word(line));
                            }
                            else
                            {
                                log.Info(String.Format("{0} was not added to database, because it is not forged only from letters", line));
                            }
                        }
                    }
                }
            } catch (WebException ex)
            {
                throw new Exceptions.WordControllerWebException(url, ex);
            }

            return(WordService.getInstance().saveList(words, language));
        }