Exemple #1
0
        private void ParseGoogleBengali(string word)
        {
            FireLogMessage("GoogleBengali for " + word);

            GreWord greWord         = GetGreWord(word);
            GoogleDictionaryHtml gd = (_entities.GoogleDictionaryHtmls.Where(w => w.Word == word)).FirstOrDefault();

            if (gd == null)
            {
                return;
            }

            string text      = gd.Html;
            Regex  regexWord = new Regex(@"<div  class=""dct-em"">\s+<span class=""dct-tt"">(.+?)</span>", RegexOptions.Singleline | RegexOptions.IgnoreCase);

            MatchCollection meanings = regexWord.Matches(text);

            foreach (string def in from Match m in meanings select CleanText(m.Groups[1].Value))
            {
                UpdateGoogleBengaliWord(greWord, def);
            }
        }
Exemple #2
0
        private void AddGoogleHtml(string word, string data)
        {
            var sql = from w in _entities.GoogleDictionaryHtmls
                      where w.Word.Equals(word)
                      select w;

            if (sql.Count() == 0)
            {
                GoogleDictionaryHtml mh = new GoogleDictionaryHtml()
                {
                    Word = word,
                    Html = data
                };
                _entities.AddToGoogleDictionaryHtmls(mh);
                _entities.SaveChanges();
            }
            else
            {
                sql.First().Html = data;
                _entities.SaveChanges();
            }
        }
Exemple #3
0
        private void ParseGoogleSynonym(string word)
        {
            GreWord greWord         = GetGreWord(word);
            GoogleDictionaryHtml gd = (_entities.GoogleDictionaryHtmls.Where(w => w.Word == word)).FirstOrDefault();

            FireLogMessage("GoogleSynonym Parsing " + word);

            if (gd == null)
            {
                return;
            }

            string text      = gd.Html;
            Regex  regexWord = new Regex(@"<a href=""/dictionary\?hl=en&q=.+?&sl=en&tl=bn&oi=dict_lk"">(.+?)</a>");

            MatchCollection meanings = regexWord.Matches(text);

            foreach (Match m in meanings)
            {
                string def = CleanText(m.Groups[1].Value);
                UpdateGoogleSynonym(greWord, def);
            }
        }