Beispiel #1
0
            internal static FiFiPageEntry[] GetEntries(IElement[] elements, FiFiPageEntry[] entries)
            {
                // cycle through Finnish elements on HtmlPage
                IElement elem = elements.FirstOrDefault();

                if (FiFiPage.IsEndOfPage(elem))
                {
                    return(entries);
                }

                // page entries are headed by h3 tags
                // if element is not an h3 then
                if (elem.TagName != "H3")
                {
                    return(GetEntries(elements.Skip(1).ToArray(), entries));
                }


                // otherwise, create a new PageEntry, add it to entries, and continue.
                FiFiPageEntry entry = new FiFiPageEntry(elements);

                return(GetEntries(elements.Skip(1).ToArray(), FiFiPageEntry.AddEntry(entries, entry)));
            }
Beispiel #2
0
                internal static Item[] GetItems(IElement elem, Item[] items = null)
                {
                    if (items == null)
                    {
                        return(GetItems(elem, new Item[0]));
                    }
                    if (FiFiPage.IsEndOfPage(elem))
                    {
                        return(items);
                    }

                    if (String.IsNullOrEmpty(elem.TextContent.Trim()))
                    {
                        return(GetItems(elem.NextElementSibling, items));
                    }

                    switch (elem.TagName)
                    {
                    case "H3":
                    case "H4":
                    case "H5":
                        return(items);

                    case "UL":
                    case "OL":
                    case "DIV":
                    case "DD":
                        var lItems = elem.QuerySelectorAll("li,dl").Select(li => new Item(li)).ToArray();
                        return(GetItems(elem.NextElementSibling, items.Concat(lItems).ToArray()));

                    default:
                        return(GetItems(elem.NextElementSibling, items.Concat(new Item[1] {
                            new Item(elem)
                        }).ToArray()));
                    }
                }
Beispiel #3
0
 internal static bool IsEnd(IElement elem)
 {   // this should be moved to WiktionaryPage
     return(FiFiPage.IsEndOfPage(elem) || elem.TagName == "H3");
 }
Beispiel #4
0
 // end of section / entry
 internal static bool IsEnd(IElement elem)
 {
     return(FiFiPage.IsEndOfPage(elem) || elem.TagName == "H3");
 }