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 withregistry.register_chunker), or a pre-configured chunker instance (ChunkerBasesubclass 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 raisesTypeErrorlisting 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 withregistry.register_normalizer. An unknown name raisesValueErrorwhen 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 raisesValueError; an option the step does not take raisesTypeError.- enrichbool
Run
NLPEnricherafter normalisation.- enricher_kwargsdict[str, Any]
Kwargs for
EnricherConfig.- embedbool
Run
EmbeddingEngineafter enrichment.- embedding_modelstr
Model name for
EmbeddingEngine.- embedding_kwargsdict[str, Any]
Kwargs for
EmbeddingEngineconstructor.- build_indexbool
Build a
RetrievalIndexafter 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
RetrievalConfigwhenretrieval_configis not supplied. Do not provide both forms.- source_titlestr or None
Default
source_titlefor all documents.- source_authorstr or None
Default
source_authorfor 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
DefaultFilterthat 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_kindcalls. 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
ZipReaderreads itself), for example{".txt": {"encoding": "detect"}, ".md": {"encoding": "detect"}}. Keys are normalised as inZipReader.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 todownloader_factory). Use this for explicit transport policy such asverify_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_kwargsstill provides deliberate per-build overrides.- doc_id_schemeDocIdScheme or str
How documents are named.
"sha256"(default): the content-addressed 64-hexCorpusDocument.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 bycontent_hash). An unknown value raisesValueErrorwhen 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. DefaultNone.
- Parameters:
chunker (str | ChunkerBase | None)
normalize (bool)
enrich (bool)
embed (bool)
embedding_model (str)
build_index (bool)
retrieval_config (RetrievalConfig | None)
source_title (str | None)
source_author (str | None)
source_type (SourceType | str | None)
collection_id (str | None)
max_download_bytes (int)
download_timeout (int)
download_max_retries (int)
download_retry_backoff (float)
max_archive_files (int)
max_archive_bytes (int)
probe_url_content_type (bool)
probe_url_timeout (int)
max_workers (int)
download_policy (object | None)
doc_id_scheme (DocIdScheme | str)
security_filter (object | None)
Notes
User note: Most users need only:
config = BuilderConfig(chunker="sentence", embed=True)
Everything else has sensible defaults.
- chunker: str | ChunkerBase | None = 'sentence'#
- 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
0to disable retries. Default: 3.
- 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.
- max_archive_bytes: int = 2147483648#
2 GB.
- Type:
Maximum cumulative extracted size per archive. Default
- probe_url_content_type: bool = True#
Probe extensionless URLs with a HEAD request to determine the correct reader. When
True(default), any URL thatclassify_urlclassifies asWEB_PAGEand has no file extension in its path is probed viaprobe_url_kindbefore routing. Set toFalseto skip the extra network round-trip (e.g. when all your URLs already carry file extensions or you want pure-offline operation). Default:True.
- retrieval_config: RetrievalConfig | None = None#
- source_type: SourceType | str | None = None#