/// <summary> /// Deprecated Method for adding a new object to the BasicMnemonics EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBasicMnemonics(BasicMnemonic basicMnemonic) { base.AddObject("BasicMnemonics", basicMnemonic); }
/// <summary> /// Create a new BasicMnemonic object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="word">Initial value of the Word property.</param> /// <param name="mnemonic">Initial value of the Mnemonic property.</param> /// <param name="helpful">Initial value of the Helpful property.</param> /// <param name="notHelpful">Initial value of the NotHelpful property.</param> public static BasicMnemonic CreateBasicMnemonic(global::System.Int64 id, global::System.String word, global::System.String mnemonic, global::System.String helpful, global::System.String notHelpful) { BasicMnemonic basicMnemonic = new BasicMnemonic(); basicMnemonic.Id = id; basicMnemonic.Word = word; basicMnemonic.Mnemonic = mnemonic; basicMnemonic.Helpful = helpful; basicMnemonic.NotHelpful = notHelpful; return basicMnemonic; }
private void ParseMnemonicDictionary(string word) { FireLogMessage("Parsing Mnemonics for: " + word); GreWord greWord = GetGreWord(word); MnemonicsDictionaryHtml gd = (_entities.MnemonicsDictionaryHtmls.Where(w => w.Word == word)).FirstOrDefault(); if (gd == null) return; string text = gd.Html; Regex regexWordUl = new Regex("<ul class='wordnet'>(.+?)</ul>", RegexOptions.Singleline); Regex regexWordLi = new Regex("<li>(.+?)</li>", RegexOptions.Singleline); Regex regexImage = new Regex("<div class=\"floatright\">.+?<img src=\"(.+?)\".+?</div>", RegexOptions.Singleline); Regex regexTag = new Regex("<div class=\"floatleft\">(.+?)</div>", RegexOptions.Singleline); Match meaningMatch = regexWordUl.Match(text); if (meaningMatch.Success) { MatchCollection meanings = regexWordLi.Matches(meaningMatch.Value); foreach (Match m in meanings) { string tag = ""; string img = ""; string def = CleanText(m.Groups[1].Value); MatchCollection mci = regexImage.Matches(def); foreach (Match mi in mci) { Match mt = regexTag.Match(def); img = mi.Groups[1].Value; tag = mt.Groups[1].Value.Replace("\r\n", ""); def = regexImage.Replace(def, ""); def = regexTag.Replace(def, ""); def = def.Replace("<div class='clear'></div>", ""); } WordDefinition wordDefinition = new WordDefinition { Definition = def, Image = img, Tag = tag, GreWord = greWord, }; _entities.AddToWordDefinitions(wordDefinition); _entities.SaveChanges(); } } Regex regexSelectedMnemonicDiv = new Regex("<div class='mnemonics'>(.+?)</div>", RegexOptions.Singleline | RegexOptions.IgnoreCase); Regex regexSelectedMnemonicLi = new Regex(@"<li><p>(.+?)</p><p>\s+added by.+?</li>", RegexOptions.Singleline | RegexOptions.IgnoreCase); Match selectedMnemonic = regexSelectedMnemonicDiv.Match(text); if (selectedMnemonic.Success) { MatchCollection selectedMnemonics = regexSelectedMnemonicLi.Matches(selectedMnemonic.Groups[1].Value); foreach (Match m in selectedMnemonics) { //listSelectedMnemonics.Items.Add(clarify(m.Groups[1].Value)); string def = CleanText(m.Groups[1].Value); FeaturedMnemonic mnemonics = new FeaturedMnemonic { Mnemonic = def, GreWord = greWord }; _entities.AddToFeaturedMnemonics(mnemonics); _entities.SaveChanges(); } } Regex regexAllMnemonicDiv = new Regex("<div class='mnemonic'>(.+?)</div>", RegexOptions.Singleline | RegexOptions.IgnoreCase); Regex regexAllMnemonicLi = new Regex(@"<li><p>(.+?)</p><p>\s+added by.+?<p>Was this mnemonic useful \? \s+<strong id='hallo\d+'>(.+?)</strong>.+?<strong id='hallo\d+'> (.+?)</strong>", RegexOptions.Singleline | RegexOptions.IgnoreCase); Match allMnemonic = regexAllMnemonicDiv.Match(text); if (allMnemonic.Success) { MatchCollection meanings = regexAllMnemonicLi.Matches(allMnemonic.Groups[1].Value); foreach (Match m in meanings) { string def = CleanText(m.Groups[1].Value); BasicMnemonic mnemonics = new BasicMnemonic() { Mnemonic = def, Helpful = m.Groups[2].Value, NotHelpful = m.Groups[3].Value }; mnemonics.GreWord = greWord; _entities.AddToBasicMnemonics(mnemonics); _entities.SaveChanges(); } } }