Ingestion#
nlql.ingest —— 写入管线:Normalizer → 可插拔 Splitter → Embedder(带缓存)→ Indexer。内置规则句子分割(中/英/日 + CJK 标点),可选 pysbd(nlql[segment])。
ingest
#
Ingestion: normalization, pluggable splitting, and the write-time pipeline.
Importing this package registers the default SENTENCE and CHUNK splitters.
__all__
module-attribute
#
__all__ = ['IngestionPipeline', 'Normalizer', 'DefaultNormalizer', 'split_sentences', 'split_chunks', 'detect_language', 'LanguageRouter', 'make_pysbd_splitter']
LanguageRouter
#
A splitter that dispatches to a per-language sub-splitter by detected script.
源代码位于: src/nlql/ingest/language.py
DefaultNormalizer
#
NFC-normalize, collapse spaces/tabs and blank lines, trim each line.
normalize
#
Normalizer
#
IngestionPipeline
#
IngestionPipeline(embedder: Embedder, *, registry: Registry = GLOBAL_REGISTRY, normalizer: Normalizer | None = None, granularity: str = 'sentence')
Turns documents into embedded units at a configured base granularity.
源代码位于: src/nlql/ingest/pipeline.py
process
#
Normalize, split, and embed documents into units (vectors attached).
Text payloads are split into segments; image payloads become one unit each and are
embedded via the embedder's embed_images when it is multimodal (otherwise they
are skipped). Both paths share the same index — only the vector's origin differs.
源代码位于: src/nlql/ingest/pipeline.py
detect_language
#
Coarse script detection: "cjk" if the text is substantially CJK, else "latin".
源代码位于: src/nlql/ingest/language.py
make_pysbd_splitter
#
A robust sentence splitter backed by pysbd (handles abbreviations).
Needs pip install pysbd. Register it as SENTENCE (globally or per engine) to
replace the rule-based default.
源代码位于: src/nlql/ingest/language.py
split_chunks
#
Group whole sentences into chunks no longer than max_chars characters.
源代码位于: src/nlql/ingest/splitters.py
split_sentences
#
Split text into sentences using punctuation and newline boundaries.