internal Definition(IElement e) { IElement elem = (IElement)e.Clone(true); var dl = elem.QuerySelector("dl"); if (dl != null) { examples = Example.GetExamples(dl); elem.RemoveChild(dl); } else { examples = new Example[0]; } var anchors = elem.QuerySelectorAll("a").Where(a => a.HasAttribute("href")); if (anchors.Count() > 0) { linkDict = new LinkDictionary(anchors); //anchors.ToList().ForEach(a => links.AddLink(a)); } else { linkDict = new LinkDictionary(); } text = elem.TextContent.Trim(); }
public FiFiPageEntry(IElement[] elements) { Invalidate(elements); IElement wordElem = GetWordElement(elements.Skip(1)); term = wordElem.FirstElementChild.TextContent.Trim(); // entry info order: // category category = GetWordCategory(elements.First()); if (!PartsOfSpeech.Contains(category.ToLower())) { Console.WriteLine(); Logger.Warn(String.Format("{0} has unknown word category {1} ", term, category)); } // word itself + other info bool hasVerbConjugation = FiFiPageEntry.HasVerbConjugationLink(wordElem); if (hasVerbConjugation) { verbConjugation = VerbConjugationPage.GetPage(term); } IElement infoClone = (IElement)wordElem.Clone(); infoClone.RemoveChild(infoClone.FirstElementChild); info = infoClone.TextContent.Trim(); var anchors = wordElem.QuerySelectorAll("a").Where(a => a.HasAttribute("href")); if (anchors.Count() > 0) { linkDict = new LinkDictionary(anchors); } else { linkDict = new LinkDictionary(); } // 'Get' here could be 'Discover'. DiscoverDefinitions, DiscoverSections, etc. // definitions definitions = Definition.GetDefinitions(elements.Skip(1).FirstOrDefault(), new Definition[0]); // sections sections = Section.GetSections(elements.Skip(1).First()); // inflection tables declensionTable = DeclensionTable.GetTables(elements.Skip(1).First()).ToArray(); //inflections = declensions.SelectMany(iTable => iTable.declensions).ToArray(); }
internal Item(IElement li) { text = li.TextContent.Trim(); var anchors = li.QuerySelectorAll("a").Where(a => a.HasAttribute("href")); if (anchors.Count() > 0) { linkDict = new LinkDictionary(anchors); } else { linkDict = new LinkDictionary(); } }
internal Morpheme(string word, string[] attributes, IEnumerable <IElement> links) : this(word, attributes) { this.linkDict = new LinkDictionary(links); }
internal Morpheme(string word, string[] attributes, IHtmlCollection <IElement> links) : this(word, attributes) { this.linkDict = new LinkDictionary(links); }