/// <summary> /// Create a new GreWordDefinition object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="word">Initial value of the Word property.</param> /// <param name="serial">Initial value of the Serial property.</param> /// <param name="partsOfSpeech">Initial value of the PartsOfSpeech property.</param> public static GreWordDefinition CreateGreWordDefinition(global::System.Int64 id, global::System.String word, global::System.String serial, global::System.String partsOfSpeech) { GreWordDefinition greWordDefinition = new GreWordDefinition(); greWordDefinition.Id = id; greWordDefinition.Word = word; greWordDefinition.Serial = serial; greWordDefinition.PartsOfSpeech = partsOfSpeech; return greWordDefinition; }
/// <summary> /// Deprecated Method for adding a new object to the GreWordDefinitions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGreWordDefinitions(GreWordDefinition greWordDefinition) { base.AddObject("GreWordDefinitions", greWordDefinition); }
private void ParseWordnetDefinitions(string word) { FireLogMessage("WordnetDefinitions Parsing: " + word); var html = (from w in _entities.DefinitionsNetHtmls where w.Word == word select w).FirstOrDefault(); var greWord = GetGreWord(word); try { Regex r = new Regex("Wordnet</span>.+?<td class=\"dsc2\" width=100%>(.+?)</td>", RegexOptions.Singleline); string resultstring = r.Match(html.Html).Groups[1].Value; Regex regexObj = new Regex(@"<br><b>([0-9]+)\. <span style=""color:#000055;font-size:10px"">\((.+?)\)</span></b> <b>(.+?)</b>\s*<br>(.+?)<br>\s*(<i><span style=""color:#666666"">(.+?)</span></i><br>)?"); MatchCollection mc = regexObj.Matches(resultstring); foreach (Match match in mc) { string similar = match.Groups[3].Value; var defs = (from w in _entities.GreWordDefinitions where w.GreWord.Word == word && w.SimilarWords == similar select w).FirstOrDefault(); if (defs == null) { defs = new GreWordDefinition() { GreWord = greWord, Serial = match.Groups[1].Value, PartsOfSpeech = match.Groups[2].Value, SimilarWords = match.Groups[3].Value, Definitions = match.Groups[4].Value, Sentences = match.Groups[6].Value }; defs.Definitions = Regex.Replace(defs.Definitions, "<a.+?>(.+?)</a>", "$1"); _entities.AddToGreWordDefinitions(defs); _entities.SaveChanges(); } else { defs.Serial = match.Groups[1].Value; defs.PartsOfSpeech = match.Groups[2].Value; defs.SimilarWords = match.Groups[3].Value; defs.Definitions = match.Groups[4].Value; defs.Sentences = match.Groups[6].Value; defs.Definitions = Regex.Replace(defs.Definitions, "<a.+?>(.+?)</a>", "$1"); _entities.SaveChanges(); } } } catch (ArgumentException ex) { FireLogMessage(word + ": " + ex.Message); // Syntax error in the regular expression } }