BuilderConfig#

class scikitplot.corpus.BuilderConfig(chunker='sentence', chunker_kwargs=<factory>, normalize=True, normalizer_steps=<factory>, normalizer_kwargs=<factory>, enrich=False, enricher_kwargs=<factory>, embed=False, embedding_model='all-MiniLM-L6-v2', embedding_kwargs=<factory>, build_index=False, retrieval_config=None, index_kwargs=<factory>, source_title=None, source_author=None, source_type=None, collection_id=None, default_language=None, filter_kwargs=<factory>, max_download_bytes=524288000, download_timeout=120, download_max_retries=3, download_retry_backoff=1.0, max_archive_files=10000, max_archive_bytes=2147483648, probe_url_content_type=True, probe_url_timeout=15, max_workers=1, reader_kwargs=<factory>, downloader_kwargs=<factory>, download_policy=None, doc_id_scheme=DocIdScheme.SHA256, security_filter=None)[source]#

Configuration for CorpusBuilder.

Parameters:
chunkerstr or object

Chunker to use: a name registered in the component registry ("sentence", "paragraph", "fixed_window", "word", "semantic", or one added with registry.register_chunker), or a pre-configured chunker instance (ChunkerBase subclass or new-style chunker, auto-bridged).

chunker_kwargsdict[str, Any]

Fields of the named chunker’s config (for example {"overlap": 1} for "sentence"); an unknown field raises TypeError listing the valid ones. Refused (ValueError) when chunker is an instance.

normalizebool

Run normalisation pipeline after filtering.

normalizer_stepslist[str]

Normaliser names registered in the component registry: "unicode", "whitespace", "html_strip", "lowercase", "dedup_lines", "language_detect", or one added with registry.register_normalizer. An unknown name raises ValueError when the build starts. Default: ["unicode", "whitespace"].

normalizer_kwargsdict[str, dict[str, Any]]

Options per normaliser step, {step: {option: value}} (for example {"unicode": {"form": "NFKC"}}). A key that is not in normalizer_steps raises ValueError; an option the step does not take raises TypeError.

enrichbool

Run NLPEnricher after normalisation.

enricher_kwargsdict[str, Any]

Kwargs for EnricherConfig.

embedbool

Run EmbeddingEngine after enrichment.

embedding_modelstr

Model name for EmbeddingEngine.

embedding_kwargsdict[str, Any]

Kwargs for EmbeddingEngine constructor.

build_indexbool

Build a RetrievalIndex after embedding.

retrieval_configRetrievalConfig or None

Canonical retrieval/index configuration. New code should prefer this field so backend constructor options can use RetrievalConfig(index_kwargs={...}) directly.

index_kwargsdict[str, Any]

Backward-compatible kwargs used to construct RetrievalConfig when retrieval_config is not supplied. Do not provide both forms.

source_titlestr or None

Default source_title for all documents.

source_authorstr or None

Default source_author for all documents.

source_typestr or None

Default source_type (e.g., "book", "movie").

collection_idstr or None

Group identifier for this corpus build.

default_languagestr or None

ISO 639-1 language code.

filter_kwargsdict[str, Any]

Kwargs for the DefaultFilter that judges prose; code is kept when it is not blank (CodeAwareFilter).

max_workersint

Parallelism for multi-file ingestion.

probe_url_content_typebool

When True (default), extensionless URLs are probed with an HTTP HEAD request to infer the correct reader before downloading. Disable to save a round-trip when all URLs have file extensions.

probe_url_timeoutint

HTTP timeout in seconds for probe_url_kind calls. Default: 15.

reader_kwargsdict[str, dict[str, Any]]

Reader options per file extension, applied wherever the builder makes a reader (local files, downloads, archive members, and the members a ZipReader reads itself), for example {".txt": {"encoding": "detect"}, ".md": {"encoding": "detect"}}. Keys are normalised as in ZipReader.reader_kwargs (lower case, leading dot). An option the reader does not take fails that file (recorded in the result’s errors). Provenance options the builder sets itself take precedence.

downloader_kwargsdict[str, Any]

Advanced keyword overrides forwarded to AnyDownloader (and to downloader_factory). Use this for explicit transport policy such as verify_ssl, block_private_ips, max_redirects, YouTube settings, headers or a GitHub token without replacing the downloader. Values here override the builder’s ordinary download defaults.

download_policyDownloadPolicy, str, mapping or None

Optional immutable transport/resource preset. When supplied it becomes the authority for timeout/size/TLS/SSRF/redirect/retry defaults; downloader_kwargs still provides deliberate per-build overrides.

doc_id_schemeDocIdScheme or str

How documents are named. "sha256" (default): the content-addressed 64-hex CorpusDocument.make_doc_id, identical on every rebuild. "uuid7": one RFC 9562 UUIDv7 per document, minted per source in reading order right after the source is read; time-ordered, but new on every build (deduplicate by content_hash). An unknown value raises ValueError when it is set, at construction or later.

security_filterSecurityFilter or None

Scope bound to every index this builder builds (R2-2): AND-ed with every search’s filter, so a caller can narrow but never widen what it sees. Default None.

Parameters:

Notes

User note: Most users need only:

config = BuilderConfig(chunker="sentence", embed=True)

Everything else has sensible defaults.

build_index: bool = False#
chunker: str | ChunkerBase | None = 'sentence'#
chunker_kwargs: dict[str, Any][source]#
collection_id: str | None = None#
default_language: str | list[str] | None = None#
doc_id_scheme: DocIdScheme | str = 'sha256'[source]#
download_max_retries: int = 3#

Maximum retry attempts for transient HTTP errors (429, 500, 502, 503, 504) during URL downloads. Set to 0 to disable retries. Default: 3.

download_policy: object | None = None#
download_retry_backoff: float = 1.0#

Base delay in seconds for exponential back-off between download retries. Actual wait = download_retry_backoff * 2 ** attempt. Default: 1.0.

download_timeout: int = 120#
Type:

HTTP timeout for URL downloads in seconds. Default

downloader_kwargs: dict[str, Any][source]#
embed: bool = False#
embedding_kwargs: dict[str, Any][source]#
embedding_model: str = 'all-MiniLM-L6-v2'#
enrich: bool = False#
enricher_kwargs: dict[str, Any][source]#
filter_kwargs: dict[str, Any][source]#
index_kwargs: dict[str, Any][source]#
max_archive_bytes: int = 2147483648#

2 GB.

Type:

Maximum cumulative extracted size per archive. Default

max_archive_files: int = 10000#

10,000.

Type:

Maximum file count inside a single archive. Default

max_download_bytes: int = 524288000#

500 MB.

Type:

Maximum download size per URL in bytes. Default

max_workers: int = 1#
normalize: bool = True#
normalizer_kwargs: dict[str, Any][source]#
normalizer_steps: list[str][source]#
probe_url_content_type: bool = True#

Probe extensionless URLs with a HEAD request to determine the correct reader. When True (default), any URL that classify_url classifies as WEB_PAGE and has no file extension in its path is probed via probe_url_kind before routing. Set to False to skip the extra network round-trip (e.g. when all your URLs already carry file extensions or you want pure-offline operation). Default: True.

probe_url_timeout: int = 15#

HTTP timeout in seconds for the URL-probing HEAD request. Default: 15.

reader_kwargs: dict[str, dict[str, Any]][source]#
retrieval_config: RetrievalConfig | None = None#
security_filter: object | None = None#
source_author: str | None = None#
source_title: str | None = None#
source_type: SourceType | str | None = None#