Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA NeMo Curator Resiliparse Extractor

From Leeroopedia
Revision as of 13:21, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/NVIDIA_NeMo_Curator_Resiliparse_Extractor.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Text Extraction, Boilerplate Removal, HTML Processing, NLP
Last Updated 2026-02-14 00:00 GMT

Overview

ResiliparseExtractor implements HTML text extraction using the Resiliparse library's fast rule-based plain text extractor, enhanced with a stopword density filter for quality control.

Description

The ResiliparseExtractor class extends HTMLExtractorAlgorithm and provides a high-performance alternative to JusText for HTML text extraction. It wraps the Resiliparse HTML2Text module, which is a very fast, rule-based plain text extractor that uses the Resiliparse DOM parser.

The extraction process works as follows:

  1. Text extraction: Calls resiliparse.extract.html2text.extract_plain_text with optional main_content heuristics and alt_texts preservation. This extracts all visible text nodes inside the HTML <body>, skipping <script>, <style>, and other invisible elements.
  2. Paragraph splitting: The extracted text is split by newlines, filtering out empty strings.
  3. Stopword density filtering: For space-separated languages, each paragraph is checked against a stopword density threshold (default 0.32). Only paragraphs meeting the minimum density are retained. This step is skipped for non-spaced languages (Thai, Chinese, Japanese, Korean) where stopword density metrics are unreliable.

NeMo Curator added the stopword density filter on top of the base Resiliparse extraction to improve quality, since research suggests that around 30-40% of typical English text consists of stopwords.

Usage

Use this class when you need fast HTML text extraction, particularly for large-scale Common Crawl processing. It is well-suited for scenarios where processing speed is prioritized, while still maintaining reasonable quality through stopword density filtering.

Code Reference

Source Location

  • Repository: NeMo-Curator
  • File: nemo_curator/stages/text/download/html_extractors/resiliparse.py
  • Lines: 1-79

Signature

class ResiliparseExtractor(HTMLExtractorAlgorithm):
    def __init__(
        self,
        required_stopword_density: float = 0.32,
        main_content: bool = True,
        alt_texts: bool = False,
    ): ...

    def extract_text(
        self,
        html: str,
        stop_words: frozenset[str],
        language: str,
    ) -> list[str] | None: ...

Import

from nemo_curator.stages.text.download.html_extractors.resiliparse import ResiliparseExtractor

I/O Contract

Inputs

Name Type Required Description
required_stopword_density float No Minimum proportion of stopwords required to preserve a paragraph. Defaults to 0.32
main_content bool No Whether to apply heuristics for extracting only "main-content" elements. Defaults to True
alt_texts bool No Whether to preserve alternative text descriptions (e.g., for images). Defaults to False

The extract_text method accepts:

Name Type Required Description
html str Yes Decoded HTML content string
stop_words frozenset[str] Yes Language-specific stop word set for density filtering
language str Yes Detected language name (uppercase, e.g., "ENGLISH")

Outputs

Name Type Description
return value list[str] List of extracted text paragraphs that meet the stopword density threshold. For non-spaced languages, all non-empty paragraphs are returned

Usage Examples

Basic Usage

from nemo_curator.stages.text.download.html_extractors.resiliparse import ResiliparseExtractor

extractor = ResiliparseExtractor()

html = "<html><body><p>This is the main content of the article.</p></body></html>"
stop_words = frozenset(["the", "is", "of"])
paragraphs = extractor.extract_text(html, stop_words, "ENGLISH")

Custom Stopword Density

from nemo_curator.stages.text.download.html_extractors.resiliparse import ResiliparseExtractor

# Lower threshold to keep more paragraphs
extractor = ResiliparseExtractor(
    required_stopword_density=0.20,
    main_content=True,
    alt_texts=True,
)

Using with CommonCrawlHTMLExtractor

from nemo_curator.stages.text.download.common_crawl.extract import CommonCrawlHTMLExtractor

# Use Resiliparse as the extraction algorithm
extractor = CommonCrawlHTMLExtractor(algorithm="resiliparse")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment