Object PageSummaryIndexService

  • All Implemented Interfaces:

    
    public class PageSummaryIndexService
    
                        

    Web Page Summary Index (WPSI) — generates a compressed, AI-readable YAML summary from a parsed FeaturedDocument.

    The summary is typically 0.1%–1% the size of the original HTML while preserving:

    • Page metadata and type inference

    • Landmark structure (header, nav, main, footer, etc.)

    • Scored key content nodes with CSS selector hints

    • Repeated structure detection (lists, tables)

    • Aggregated statistics

    Every summary node carries its vi attribute (bounding box) so it can be traced back to the original DOM element.

    The algorithm is fully deterministic — no AI model is involved.

    • Constructor Detail

    • Method Detail

      • generate

         final String generate(FeaturedDocument document, String pageUrl, String title)

        Generate a WPSI YAML summary from a FeaturedDocument.

        Parameters:
        document - The parsed DOM document (never mutated — the algorithm works on a clone).
        pageUrl - The normalized page URL.
        title - The page title (from FeaturedDocument.title).
        Returns:

        A YAML string suitable for saving to a .yml file.

      • detectLinkGroups

         final List<PageSummaryIndexService.SummaryLinkGroup> detectLinkGroups(FeaturedDocument document)

        Detect link groups — coherent collections of item cards where each card contains one or more links.

        Algorithm: cluster by visual geometry (bounding box), then walk up the DOM to find the nearest container element.