private void button10_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            parser.OnLogMessage += OnParserOnLogMessage;

            workerThread = new Thread(parser.ParseGoogleBengali) { IsBackground = true };
            workerThread.Start();
        }
        private void buttonCollect_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();

            long listNameId = -1;
            if (comboBoxList.Text.Trim().Length > 0)
            {
                var list = entities.ListNames.Where(o => o.Name.ToLower().Equals(comboBoxList.Text.Trim().ToLower())).Select(o => o).FirstOrDefault();
                if (list == null)
                {

                    ListName listName = new ListName();
                    listName.Name = comboBoxList.Text.Trim().ToLower();
                    entities.AddToListNames(listName);
                    entities.SaveChanges();

                    listNameId = listName.Id;
                }
                else
                {
                    listNameId = list.Id;
                }
            }
            else
            {
                listNameId = Convert.ToInt64(comboBoxList.SelectedValue);
            }

            String strWord = textBoxWord.Text.Trim().ToLower();
            ListName ln = (from n in entities.ListNames
                           where n.Id == listNameId
                           select n).FirstOrDefault();

            try
            {
                GreWord word;
                word = (from w in entities.GreWords
                        where w.Word.ToLower() == strWord
                        select w).FirstOrDefault();

                if (word == null)
                {
                    word = new GreWord()
                    {
                        Word = strWord,
                    };
                    entities.AddToGreWords(word);
                    entities.SaveChanges();
                }

                ListedWord lw = (from w in entities.ListedWords
                                 where w.ListName.Id == ln.Id && w.GreWord.Word == word.Word
                                 select w).FirstOrDefault();

                if (lw == null)
                {
                    lw = new ListedWord()
                    {
                        GreWord = word,
                        ListName = ln
                    };
                    entities.AddToListedWords(lw);
                    entities.SaveChanges();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }

            ParserHelper parserHelper = new ParserHelper(entities);
            parserHelper.OnLogMessage += (sender2, person) => this.Invoke((MethodInvoker)(() => textBoxInfo.AppendText(person + "\r\n")));

            parserHelper.WordToFetch = strWord;
            var workerThread = new Thread(parserHelper.FetchAndParseSingleWord) {IsBackground = true};
            workerThread.Start();
        }
        String getMnemonics(GreWord gw)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            String mnemonics = "";

            List<FeaturedMnemonic> mSelected = (from w in entities.FeaturedMnemonics
                                                where w.GreWord.Word == gw.Word
                                                select w).ToList();
            foreach (FeaturedMnemonic ms in mSelected)
                mnemonics += "##:" + ms.Mnemonic + ", ";

            List<BasicMnemonic> mAll = (from w in entities.BasicMnemonics
                                        where w.GreWord.Word == gw.Word
                                        select w).ToList();
            foreach (BasicMnemonic ms in mAll)
                mnemonics += "#" + ms.Helpful + "," + ms.NotHelpful + ":" + ms.Mnemonic + ", ";

            mnemonics = Clean(mnemonics, @"\(Tag.+?\)");
            mnemonics = Clean(mnemonics);

            return mnemonics;
        }
        String getGoogleSynonym(GreWord gw)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            String synnonym = "";

            List<GoogleSynonym> gSyn = (from w in entities.GoogleSynonyms
                                        where w.GreWord.Word == gw.Word
                                        select w).ToList();
            foreach (GoogleSynonym gs in gSyn)
                synnonym += gs.Synonym + ", ";

            return synnonym;
        }
        private void buttonSynonymsNet_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            parser.OnLogMessage += OnParserOnLogMessage;

            workerThread = new Thread(parser.FetchSynonymsNet) { IsBackground = true };
            workerThread.Start();
        }
        private void buttonMnemonicDictionarySynonym_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            parser.OnLogMessage += delegate(object sender2, string person)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    textBox2.AppendText(person + "\r\n");
                });
            };

            workerThread = new Thread(new ThreadStart(parser.ParseMnemonicDictionarySynonym));
            workerThread.IsBackground = true;
            workerThread.Start();
        }
        private void button6_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();
            var parser = new ParserHelper(entities);

            GreWord[] greWords = (from w in entities.GreWords
                                  //where w.list_name == comboBox1.Text
                                  orderby w.Word
                                  select w).ToArray();

            String strGre = "";
            foreach (GreWord w in greWords)
            {
                strGre += w.Word + "\r\n";
                strGre += getGoogleSynonym(w) + "\r\n";
                strGre += getMnemonics(w) + "\r\n";
                strGre += "\r\n";
                strGre += "\r\n";
            }

            SaveFileDialog sfd = new SaveFileDialog();
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                StreamWriter sw = new StreamWriter(sfd.FileName);
                sw.Write(strGre);
                sw.Close();
            }
        }