kreuzberg 4.0.8 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/ext/kreuzberg_rb/native/Cargo.lock +94 -98
- data/ext/kreuzberg_rb/native/Cargo.toml +4 -2
- data/ext/kreuzberg_rb/native/src/batch.rs +139 -0
- data/ext/kreuzberg_rb/native/src/config/mod.rs +10 -0
- data/ext/kreuzberg_rb/native/src/config/types.rs +1058 -0
- data/ext/kreuzberg_rb/native/src/error_handling.rs +125 -0
- data/ext/kreuzberg_rb/native/src/extraction.rs +79 -0
- data/ext/kreuzberg_rb/native/src/gc_guarded_value.rs +35 -0
- data/ext/kreuzberg_rb/native/src/helpers.rs +176 -0
- data/ext/kreuzberg_rb/native/src/lib.rs +342 -3622
- data/ext/kreuzberg_rb/native/src/metadata.rs +34 -0
- data/ext/kreuzberg_rb/native/src/plugins/mod.rs +92 -0
- data/ext/kreuzberg_rb/native/src/plugins/ocr_backend.rs +159 -0
- data/ext/kreuzberg_rb/native/src/plugins/post_processor.rs +126 -0
- data/ext/kreuzberg_rb/native/src/plugins/validator.rs +99 -0
- data/ext/kreuzberg_rb/native/src/result.rs +326 -0
- data/ext/kreuzberg_rb/native/src/validation.rs +4 -0
- data/lib/kreuzberg/config.rb +66 -0
- data/lib/kreuzberg/result.rb +107 -2
- data/lib/kreuzberg/types.rb +104 -0
- data/lib/kreuzberg/version.rb +1 -1
- data/lib/kreuzberg.rb +0 -4
- data/sig/kreuzberg.rbs +105 -1
- data/vendor/Cargo.toml +3 -3
- data/vendor/kreuzberg/Cargo.toml +4 -3
- data/vendor/kreuzberg/README.md +1 -1
- data/vendor/kreuzberg/src/api/config.rs +69 -0
- data/vendor/kreuzberg/src/api/handlers.rs +99 -2
- data/vendor/kreuzberg/src/api/mod.rs +14 -7
- data/vendor/kreuzberg/src/api/router.rs +214 -0
- data/vendor/kreuzberg/src/api/startup.rs +243 -0
- data/vendor/kreuzberg/src/api/types.rs +78 -0
- data/vendor/kreuzberg/src/cache/cleanup.rs +277 -0
- data/vendor/kreuzberg/src/cache/core.rs +428 -0
- data/vendor/kreuzberg/src/cache/mod.rs +21 -843
- data/vendor/kreuzberg/src/cache/utilities.rs +156 -0
- data/vendor/kreuzberg/src/chunking/boundaries.rs +301 -0
- data/vendor/kreuzberg/src/chunking/builder.rs +294 -0
- data/vendor/kreuzberg/src/chunking/config.rs +52 -0
- data/vendor/kreuzberg/src/chunking/core.rs +1017 -0
- data/vendor/kreuzberg/src/chunking/mod.rs +14 -2211
- data/vendor/kreuzberg/src/chunking/processor.rs +10 -0
- data/vendor/kreuzberg/src/chunking/validation.rs +686 -0
- data/vendor/kreuzberg/src/core/config/extraction/core.rs +169 -0
- data/vendor/kreuzberg/src/core/config/extraction/env.rs +179 -0
- data/vendor/kreuzberg/src/core/config/extraction/loaders.rs +204 -0
- data/vendor/kreuzberg/src/core/config/extraction/mod.rs +42 -0
- data/vendor/kreuzberg/src/core/config/extraction/types.rs +93 -0
- data/vendor/kreuzberg/src/core/config/formats.rs +135 -0
- data/vendor/kreuzberg/src/core/config/mod.rs +20 -0
- data/vendor/kreuzberg/src/core/config/ocr.rs +73 -0
- data/vendor/kreuzberg/src/core/config/page.rs +57 -0
- data/vendor/kreuzberg/src/core/config/pdf.rs +111 -0
- data/vendor/kreuzberg/src/core/config/processing.rs +312 -0
- data/vendor/kreuzberg/src/core/config_validation/dependencies.rs +187 -0
- data/vendor/kreuzberg/src/core/config_validation/mod.rs +386 -0
- data/vendor/kreuzberg/src/core/config_validation/sections.rs +401 -0
- data/vendor/kreuzberg/src/core/extractor/batch.rs +246 -0
- data/vendor/kreuzberg/src/core/extractor/bytes.rs +116 -0
- data/vendor/kreuzberg/src/core/extractor/file.rs +240 -0
- data/vendor/kreuzberg/src/core/extractor/helpers.rs +71 -0
- data/vendor/kreuzberg/src/core/extractor/legacy.rs +62 -0
- data/vendor/kreuzberg/src/core/extractor/mod.rs +490 -0
- data/vendor/kreuzberg/src/core/extractor/sync.rs +208 -0
- data/vendor/kreuzberg/src/core/mod.rs +4 -1
- data/vendor/kreuzberg/src/core/pipeline/cache.rs +60 -0
- data/vendor/kreuzberg/src/core/pipeline/execution.rs +89 -0
- data/vendor/kreuzberg/src/core/pipeline/features.rs +108 -0
- data/vendor/kreuzberg/src/core/pipeline/format.rs +392 -0
- data/vendor/kreuzberg/src/core/pipeline/initialization.rs +67 -0
- data/vendor/kreuzberg/src/core/pipeline/mod.rs +135 -0
- data/vendor/kreuzberg/src/core/pipeline/tests.rs +975 -0
- data/vendor/kreuzberg/src/core/server_config/env.rs +90 -0
- data/vendor/kreuzberg/src/core/server_config/loader.rs +202 -0
- data/vendor/kreuzberg/src/core/server_config/mod.rs +380 -0
- data/vendor/kreuzberg/src/core/server_config/tests/basic_tests.rs +124 -0
- data/vendor/kreuzberg/src/core/server_config/tests/env_tests.rs +216 -0
- data/vendor/kreuzberg/src/core/server_config/tests/file_loading_tests.rs +341 -0
- data/vendor/kreuzberg/src/core/server_config/tests/mod.rs +5 -0
- data/vendor/kreuzberg/src/core/server_config/validation.rs +17 -0
- data/vendor/kreuzberg/src/embeddings.rs +136 -13
- data/vendor/kreuzberg/src/extraction/{archive.rs → archive/mod.rs} +45 -239
- data/vendor/kreuzberg/src/extraction/archive/sevenz.rs +98 -0
- data/vendor/kreuzberg/src/extraction/archive/tar.rs +118 -0
- data/vendor/kreuzberg/src/extraction/archive/zip.rs +101 -0
- data/vendor/kreuzberg/src/extraction/html/converter.rs +592 -0
- data/vendor/kreuzberg/src/extraction/html/image_handling.rs +95 -0
- data/vendor/kreuzberg/src/extraction/html/mod.rs +53 -0
- data/vendor/kreuzberg/src/extraction/html/processor.rs +659 -0
- data/vendor/kreuzberg/src/extraction/html/stack_management.rs +103 -0
- data/vendor/kreuzberg/src/extraction/html/types.rs +28 -0
- data/vendor/kreuzberg/src/extraction/mod.rs +6 -2
- data/vendor/kreuzberg/src/extraction/pptx/container.rs +159 -0
- data/vendor/kreuzberg/src/extraction/pptx/content_builder.rs +168 -0
- data/vendor/kreuzberg/src/extraction/pptx/elements.rs +132 -0
- data/vendor/kreuzberg/src/extraction/pptx/image_handling.rs +57 -0
- data/vendor/kreuzberg/src/extraction/pptx/metadata.rs +160 -0
- data/vendor/kreuzberg/src/extraction/pptx/mod.rs +558 -0
- data/vendor/kreuzberg/src/extraction/pptx/parser.rs +379 -0
- data/vendor/kreuzberg/src/extraction/transform/content.rs +205 -0
- data/vendor/kreuzberg/src/extraction/transform/elements.rs +211 -0
- data/vendor/kreuzberg/src/extraction/transform/mod.rs +480 -0
- data/vendor/kreuzberg/src/extraction/transform/types.rs +27 -0
- data/vendor/kreuzberg/src/extractors/archive.rs +2 -0
- data/vendor/kreuzberg/src/extractors/bibtex.rs +2 -0
- data/vendor/kreuzberg/src/extractors/djot_format/attributes.rs +134 -0
- data/vendor/kreuzberg/src/extractors/djot_format/conversion.rs +223 -0
- data/vendor/kreuzberg/src/extractors/djot_format/extractor.rs +172 -0
- data/vendor/kreuzberg/src/extractors/djot_format/mod.rs +24 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/block_handlers.rs +271 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/content_extraction.rs +257 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/event_handlers.rs +101 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/inline_handlers.rs +201 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/mod.rs +16 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/state.rs +78 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/table_extraction.rs +68 -0
- data/vendor/kreuzberg/src/extractors/djot_format/parsing/text_extraction.rs +61 -0
- data/vendor/kreuzberg/src/extractors/djot_format/rendering.rs +452 -0
- data/vendor/kreuzberg/src/extractors/docbook.rs +2 -0
- data/vendor/kreuzberg/src/extractors/docx.rs +12 -1
- data/vendor/kreuzberg/src/extractors/email.rs +2 -0
- data/vendor/kreuzberg/src/extractors/epub/content.rs +333 -0
- data/vendor/kreuzberg/src/extractors/epub/metadata.rs +137 -0
- data/vendor/kreuzberg/src/extractors/epub/mod.rs +186 -0
- data/vendor/kreuzberg/src/extractors/epub/parsing.rs +86 -0
- data/vendor/kreuzberg/src/extractors/excel.rs +4 -0
- data/vendor/kreuzberg/src/extractors/fictionbook.rs +2 -0
- data/vendor/kreuzberg/src/extractors/frontmatter_utils.rs +466 -0
- data/vendor/kreuzberg/src/extractors/html.rs +80 -8
- data/vendor/kreuzberg/src/extractors/image.rs +8 -1
- data/vendor/kreuzberg/src/extractors/jats/elements.rs +350 -0
- data/vendor/kreuzberg/src/extractors/jats/metadata.rs +21 -0
- data/vendor/kreuzberg/src/extractors/{jats.rs → jats/mod.rs} +10 -412
- data/vendor/kreuzberg/src/extractors/jats/parser.rs +52 -0
- data/vendor/kreuzberg/src/extractors/jupyter.rs +2 -0
- data/vendor/kreuzberg/src/extractors/latex/commands.rs +93 -0
- data/vendor/kreuzberg/src/extractors/latex/environments.rs +157 -0
- data/vendor/kreuzberg/src/extractors/latex/metadata.rs +27 -0
- data/vendor/kreuzberg/src/extractors/latex/mod.rs +146 -0
- data/vendor/kreuzberg/src/extractors/latex/parser.rs +231 -0
- data/vendor/kreuzberg/src/extractors/latex/utilities.rs +126 -0
- data/vendor/kreuzberg/src/extractors/markdown.rs +39 -162
- data/vendor/kreuzberg/src/extractors/mod.rs +9 -1
- data/vendor/kreuzberg/src/extractors/odt.rs +2 -0
- data/vendor/kreuzberg/src/extractors/opml/core.rs +165 -0
- data/vendor/kreuzberg/src/extractors/opml/mod.rs +31 -0
- data/vendor/kreuzberg/src/extractors/opml/parser.rs +479 -0
- data/vendor/kreuzberg/src/extractors/orgmode.rs +2 -0
- data/vendor/kreuzberg/src/extractors/pdf/extraction.rs +106 -0
- data/vendor/kreuzberg/src/extractors/{pdf.rs → pdf/mod.rs} +25 -324
- data/vendor/kreuzberg/src/extractors/pdf/ocr.rs +214 -0
- data/vendor/kreuzberg/src/extractors/pdf/pages.rs +51 -0
- data/vendor/kreuzberg/src/extractors/pptx.rs +9 -2
- data/vendor/kreuzberg/src/extractors/rst.rs +2 -0
- data/vendor/kreuzberg/src/extractors/rtf/encoding.rs +116 -0
- data/vendor/kreuzberg/src/extractors/rtf/formatting.rs +24 -0
- data/vendor/kreuzberg/src/extractors/rtf/images.rs +72 -0
- data/vendor/kreuzberg/src/extractors/rtf/metadata.rs +216 -0
- data/vendor/kreuzberg/src/extractors/rtf/mod.rs +142 -0
- data/vendor/kreuzberg/src/extractors/rtf/parser.rs +259 -0
- data/vendor/kreuzberg/src/extractors/rtf/tables.rs +83 -0
- data/vendor/kreuzberg/src/extractors/structured.rs +2 -0
- data/vendor/kreuzberg/src/extractors/text.rs +4 -0
- data/vendor/kreuzberg/src/extractors/typst.rs +2 -0
- data/vendor/kreuzberg/src/extractors/xml.rs +2 -0
- data/vendor/kreuzberg/src/keywords/processor.rs +14 -0
- data/vendor/kreuzberg/src/language_detection/processor.rs +10 -0
- data/vendor/kreuzberg/src/lib.rs +2 -2
- data/vendor/kreuzberg/src/mcp/errors.rs +312 -0
- data/vendor/kreuzberg/src/mcp/format.rs +211 -0
- data/vendor/kreuzberg/src/mcp/mod.rs +9 -3
- data/vendor/kreuzberg/src/mcp/params.rs +196 -0
- data/vendor/kreuzberg/src/mcp/server.rs +39 -1438
- data/vendor/kreuzberg/src/mcp/tools/cache.rs +179 -0
- data/vendor/kreuzberg/src/mcp/tools/extraction.rs +403 -0
- data/vendor/kreuzberg/src/mcp/tools/mime.rs +150 -0
- data/vendor/kreuzberg/src/mcp/tools/mod.rs +11 -0
- data/vendor/kreuzberg/src/ocr/backends/easyocr.rs +96 -0
- data/vendor/kreuzberg/src/ocr/backends/mod.rs +7 -0
- data/vendor/kreuzberg/src/ocr/backends/paddleocr.rs +27 -0
- data/vendor/kreuzberg/src/ocr/backends/tesseract.rs +134 -0
- data/vendor/kreuzberg/src/ocr/hocr.rs +60 -16
- data/vendor/kreuzberg/src/ocr/language_registry.rs +11 -235
- data/vendor/kreuzberg/src/ocr/mod.rs +1 -0
- data/vendor/kreuzberg/src/ocr/processor/config.rs +203 -0
- data/vendor/kreuzberg/src/ocr/processor/execution.rs +494 -0
- data/vendor/kreuzberg/src/ocr/processor/mod.rs +265 -0
- data/vendor/kreuzberg/src/ocr/processor/validation.rs +145 -0
- data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +41 -24
- data/vendor/kreuzberg/src/pdf/bindings.rs +21 -8
- data/vendor/kreuzberg/src/pdf/hierarchy/bounding_box.rs +289 -0
- data/vendor/kreuzberg/src/pdf/hierarchy/clustering.rs +199 -0
- data/vendor/kreuzberg/src/pdf/{hierarchy.rs → hierarchy/extraction.rs} +6 -346
- data/vendor/kreuzberg/src/pdf/hierarchy/mod.rs +18 -0
- data/vendor/kreuzberg/src/plugins/extractor/mod.rs +319 -0
- data/vendor/kreuzberg/src/plugins/extractor/registry.rs +434 -0
- data/vendor/kreuzberg/src/plugins/extractor/trait.rs +391 -0
- data/vendor/kreuzberg/src/plugins/mod.rs +13 -0
- data/vendor/kreuzberg/src/plugins/ocr.rs +11 -0
- data/vendor/kreuzberg/src/plugins/processor/mod.rs +365 -0
- data/vendor/kreuzberg/src/plugins/processor/registry.rs +37 -0
- data/vendor/kreuzberg/src/plugins/processor/trait.rs +284 -0
- data/vendor/kreuzberg/src/plugins/registry/extractor.rs +416 -0
- data/vendor/kreuzberg/src/plugins/registry/mod.rs +116 -0
- data/vendor/kreuzberg/src/plugins/registry/ocr.rs +293 -0
- data/vendor/kreuzberg/src/plugins/registry/processor.rs +304 -0
- data/vendor/kreuzberg/src/plugins/registry/validator.rs +238 -0
- data/vendor/kreuzberg/src/plugins/validator/mod.rs +424 -0
- data/vendor/kreuzberg/src/plugins/validator/registry.rs +355 -0
- data/vendor/kreuzberg/src/plugins/validator/trait.rs +276 -0
- data/vendor/kreuzberg/src/stopwords/languages/asian.rs +40 -0
- data/vendor/kreuzberg/src/stopwords/languages/germanic.rs +36 -0
- data/vendor/kreuzberg/src/stopwords/languages/mod.rs +10 -0
- data/vendor/kreuzberg/src/stopwords/languages/other.rs +44 -0
- data/vendor/kreuzberg/src/stopwords/languages/romance.rs +36 -0
- data/vendor/kreuzberg/src/stopwords/languages/slavic.rs +36 -0
- data/vendor/kreuzberg/src/stopwords/mod.rs +7 -33
- data/vendor/kreuzberg/src/text/quality.rs +1 -1
- data/vendor/kreuzberg/src/text/quality_processor.rs +10 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/analysis.rs +238 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/mod.rs +8 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/punctuation.rs +54 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/reducer.rs +384 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/sentence_selection.rs +68 -0
- data/vendor/kreuzberg/src/text/token_reduction/core/word_filtering.rs +156 -0
- data/vendor/kreuzberg/src/text/token_reduction/filters/general.rs +377 -0
- data/vendor/kreuzberg/src/text/token_reduction/filters/html.rs +51 -0
- data/vendor/kreuzberg/src/text/token_reduction/filters/markdown.rs +285 -0
- data/vendor/kreuzberg/src/text/token_reduction/filters.rs +131 -246
- data/vendor/kreuzberg/src/types/djot.rs +209 -0
- data/vendor/kreuzberg/src/types/extraction.rs +301 -0
- data/vendor/kreuzberg/src/types/formats.rs +443 -0
- data/vendor/kreuzberg/src/types/metadata.rs +560 -0
- data/vendor/kreuzberg/src/types/mod.rs +281 -0
- data/vendor/kreuzberg/src/types/page.rs +182 -0
- data/vendor/kreuzberg/src/types/serde_helpers.rs +132 -0
- data/vendor/kreuzberg/src/types/tables.rs +39 -0
- data/vendor/kreuzberg/src/utils/quality/heuristics.rs +58 -0
- data/vendor/kreuzberg/src/utils/{quality.rs → quality/mod.rs} +168 -489
- data/vendor/kreuzberg/src/utils/quality/patterns.rs +117 -0
- data/vendor/kreuzberg/src/utils/quality/scoring.rs +178 -0
- data/vendor/kreuzberg/src/utils/string_pool/buffer_pool.rs +325 -0
- data/vendor/kreuzberg/src/utils/string_pool/interned.rs +102 -0
- data/vendor/kreuzberg/src/utils/string_pool/language_pool.rs +119 -0
- data/vendor/kreuzberg/src/utils/string_pool/mime_pool.rs +235 -0
- data/vendor/kreuzberg/src/utils/string_pool/mod.rs +41 -0
- data/vendor/kreuzberg/tests/api_chunk.rs +313 -0
- data/vendor/kreuzberg/tests/api_embed.rs +6 -9
- data/vendor/kreuzberg/tests/batch_orchestration.rs +1 -0
- data/vendor/kreuzberg/tests/concurrency_stress.rs +7 -0
- data/vendor/kreuzberg/tests/core_integration.rs +1 -0
- data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +130 -0
- data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +5 -14
- data/vendor/kreuzberg/tests/format_integration.rs +2 -0
- data/vendor/kreuzberg/tests/helpers/mod.rs +1 -0
- data/vendor/kreuzberg/tests/html_table_test.rs +11 -11
- data/vendor/kreuzberg/tests/ocr_configuration.rs +16 -0
- data/vendor/kreuzberg/tests/ocr_errors.rs +18 -0
- data/vendor/kreuzberg/tests/ocr_quality.rs +9 -0
- data/vendor/kreuzberg/tests/ocr_stress.rs +1 -0
- data/vendor/kreuzberg/tests/pipeline_integration.rs +50 -0
- data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +13 -0
- data/vendor/kreuzberg/tests/plugin_system.rs +12 -0
- data/vendor/kreuzberg/tests/registry_integration_tests.rs +2 -0
- data/vendor/kreuzberg-ffi/Cargo.toml +2 -1
- data/vendor/kreuzberg-ffi/benches/result_view_benchmark.rs +2 -0
- data/vendor/kreuzberg-ffi/kreuzberg.h +347 -178
- data/vendor/kreuzberg-ffi/src/config/html.rs +318 -0
- data/vendor/kreuzberg-ffi/src/config/loader.rs +154 -0
- data/vendor/kreuzberg-ffi/src/config/merge.rs +104 -0
- data/vendor/kreuzberg-ffi/src/config/mod.rs +385 -0
- data/vendor/kreuzberg-ffi/src/config/parse.rs +91 -0
- data/vendor/kreuzberg-ffi/src/config/serialize.rs +118 -0
- data/vendor/kreuzberg-ffi/src/config_builder.rs +598 -0
- data/vendor/kreuzberg-ffi/src/error.rs +46 -14
- data/vendor/kreuzberg-ffi/src/helpers.rs +10 -0
- data/vendor/kreuzberg-ffi/src/html_options.rs +421 -0
- data/vendor/kreuzberg-ffi/src/lib.rs +16 -0
- data/vendor/kreuzberg-ffi/src/panic_shield.rs +11 -0
- data/vendor/kreuzberg-ffi/src/plugins/ocr_backend.rs +2 -0
- data/vendor/kreuzberg-ffi/src/result.rs +148 -122
- data/vendor/kreuzberg-ffi/src/result_view.rs +4 -0
- data/vendor/kreuzberg-tesseract/Cargo.toml +2 -2
- metadata +200 -28
- data/vendor/kreuzberg/src/api/server.rs +0 -518
- data/vendor/kreuzberg/src/core/config.rs +0 -1914
- data/vendor/kreuzberg/src/core/config_validation.rs +0 -949
- data/vendor/kreuzberg/src/core/extractor.rs +0 -1200
- data/vendor/kreuzberg/src/core/pipeline.rs +0 -1223
- data/vendor/kreuzberg/src/core/server_config.rs +0 -1220
- data/vendor/kreuzberg/src/extraction/html.rs +0 -1830
- data/vendor/kreuzberg/src/extraction/pptx.rs +0 -3102
- data/vendor/kreuzberg/src/extractors/epub.rs +0 -696
- data/vendor/kreuzberg/src/extractors/latex.rs +0 -653
- data/vendor/kreuzberg/src/extractors/opml.rs +0 -635
- data/vendor/kreuzberg/src/extractors/rtf.rs +0 -809
- data/vendor/kreuzberg/src/ocr/processor.rs +0 -858
- data/vendor/kreuzberg/src/plugins/extractor.rs +0 -1042
- data/vendor/kreuzberg/src/plugins/processor.rs +0 -650
- data/vendor/kreuzberg/src/plugins/registry.rs +0 -1339
- data/vendor/kreuzberg/src/plugins/validator.rs +0 -967
- data/vendor/kreuzberg/src/text/token_reduction/core.rs +0 -832
- data/vendor/kreuzberg/src/types.rs +0 -1713
- data/vendor/kreuzberg/src/utils/string_pool.rs +0 -762
- data/vendor/kreuzberg-ffi/src/config.rs +0 -1341
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//! Output format configuration and validation.
|
|
2
|
+
//!
|
|
3
|
+
//! This module defines the `OutputFormat` enum for controlling how extraction
|
|
4
|
+
//! results are formatted (plain text, markdown, HTML, etc.) and provides
|
|
5
|
+
//! serialization/deserialization support.
|
|
6
|
+
|
|
7
|
+
use serde::{Deserialize, Serialize};
|
|
8
|
+
use std::str::FromStr;
|
|
9
|
+
|
|
10
|
+
/// Output format for extraction results.
|
|
11
|
+
///
|
|
12
|
+
/// Controls the format of the `content` field in `ExtractionResult`.
|
|
13
|
+
/// When set to `Markdown`, `Djot`, or `Html`, the output will be formatted
|
|
14
|
+
/// accordingly. `Plain` returns the raw extracted text.
|
|
15
|
+
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
|
|
16
|
+
#[serde(rename_all = "lowercase")]
|
|
17
|
+
pub enum OutputFormat {
|
|
18
|
+
/// Plain text content only (default)
|
|
19
|
+
#[default]
|
|
20
|
+
Plain,
|
|
21
|
+
/// Markdown format
|
|
22
|
+
Markdown,
|
|
23
|
+
/// Djot markup format (requires djot feature)
|
|
24
|
+
Djot,
|
|
25
|
+
/// HTML format
|
|
26
|
+
Html,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
impl std::fmt::Display for OutputFormat {
|
|
30
|
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
31
|
+
match self {
|
|
32
|
+
OutputFormat::Plain => write!(f, "plain"),
|
|
33
|
+
OutputFormat::Markdown => write!(f, "markdown"),
|
|
34
|
+
OutputFormat::Djot => write!(f, "djot"),
|
|
35
|
+
OutputFormat::Html => write!(f, "html"),
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
impl FromStr for OutputFormat {
|
|
41
|
+
type Err = String;
|
|
42
|
+
|
|
43
|
+
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
|
44
|
+
match s.to_lowercase().as_str() {
|
|
45
|
+
"plain" | "text" => Ok(OutputFormat::Plain),
|
|
46
|
+
"markdown" | "md" => Ok(OutputFormat::Markdown),
|
|
47
|
+
"djot" => Ok(OutputFormat::Djot),
|
|
48
|
+
"html" => Ok(OutputFormat::Html),
|
|
49
|
+
_ => Err(format!(
|
|
50
|
+
"Invalid output format: '{}'. Valid formats: plain, text, markdown, md, djot, html",
|
|
51
|
+
s
|
|
52
|
+
)),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[cfg(test)]
|
|
58
|
+
mod tests {
|
|
59
|
+
use super::*;
|
|
60
|
+
|
|
61
|
+
#[test]
|
|
62
|
+
fn test_output_format_from_str_plain() {
|
|
63
|
+
assert_eq!("plain".parse::<OutputFormat>().unwrap(), OutputFormat::Plain);
|
|
64
|
+
assert_eq!("PLAIN".parse::<OutputFormat>().unwrap(), OutputFormat::Plain);
|
|
65
|
+
assert_eq!("text".parse::<OutputFormat>().unwrap(), OutputFormat::Plain);
|
|
66
|
+
assert_eq!("TEXT".parse::<OutputFormat>().unwrap(), OutputFormat::Plain);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#[test]
|
|
70
|
+
fn test_output_format_from_str_markdown() {
|
|
71
|
+
assert_eq!("markdown".parse::<OutputFormat>().unwrap(), OutputFormat::Markdown);
|
|
72
|
+
assert_eq!("MARKDOWN".parse::<OutputFormat>().unwrap(), OutputFormat::Markdown);
|
|
73
|
+
assert_eq!("md".parse::<OutputFormat>().unwrap(), OutputFormat::Markdown);
|
|
74
|
+
assert_eq!("MD".parse::<OutputFormat>().unwrap(), OutputFormat::Markdown);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#[test]
|
|
78
|
+
fn test_output_format_from_str_djot() {
|
|
79
|
+
assert_eq!("djot".parse::<OutputFormat>().unwrap(), OutputFormat::Djot);
|
|
80
|
+
assert_eq!("DJOT".parse::<OutputFormat>().unwrap(), OutputFormat::Djot);
|
|
81
|
+
assert_eq!("Djot".parse::<OutputFormat>().unwrap(), OutputFormat::Djot);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#[test]
|
|
85
|
+
fn test_output_format_from_str_html() {
|
|
86
|
+
assert_eq!("html".parse::<OutputFormat>().unwrap(), OutputFormat::Html);
|
|
87
|
+
assert_eq!("HTML".parse::<OutputFormat>().unwrap(), OutputFormat::Html);
|
|
88
|
+
assert_eq!("Html".parse::<OutputFormat>().unwrap(), OutputFormat::Html);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#[test]
|
|
92
|
+
fn test_output_format_from_str_invalid() {
|
|
93
|
+
let result = "invalid".parse::<OutputFormat>();
|
|
94
|
+
assert!(result.is_err());
|
|
95
|
+
let err = result.unwrap_err();
|
|
96
|
+
assert!(err.contains("Invalid output format"));
|
|
97
|
+
assert!(err.contains("invalid"));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#[test]
|
|
101
|
+
fn test_output_format_to_string() {
|
|
102
|
+
assert_eq!(OutputFormat::Plain.to_string(), "plain");
|
|
103
|
+
assert_eq!(OutputFormat::Markdown.to_string(), "markdown");
|
|
104
|
+
assert_eq!(OutputFormat::Djot.to_string(), "djot");
|
|
105
|
+
assert_eq!(OutputFormat::Html.to_string(), "html");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#[test]
|
|
109
|
+
fn test_output_format_default() {
|
|
110
|
+
let format = OutputFormat::default();
|
|
111
|
+
assert_eq!(format, OutputFormat::Plain);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn test_output_format_serde_roundtrip() {
|
|
116
|
+
for format in [
|
|
117
|
+
OutputFormat::Plain,
|
|
118
|
+
OutputFormat::Markdown,
|
|
119
|
+
OutputFormat::Djot,
|
|
120
|
+
OutputFormat::Html,
|
|
121
|
+
] {
|
|
122
|
+
let json = serde_json::to_string(&format).unwrap();
|
|
123
|
+
let deserialized: OutputFormat = serde_json::from_str(&json).unwrap();
|
|
124
|
+
assert_eq!(format, deserialized);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#[test]
|
|
129
|
+
fn test_output_format_serde_values() {
|
|
130
|
+
assert_eq!(serde_json::to_string(&OutputFormat::Plain).unwrap(), "\"plain\"");
|
|
131
|
+
assert_eq!(serde_json::to_string(&OutputFormat::Markdown).unwrap(), "\"markdown\"");
|
|
132
|
+
assert_eq!(serde_json::to_string(&OutputFormat::Djot).unwrap(), "\"djot\"");
|
|
133
|
+
assert_eq!(serde_json::to_string(&OutputFormat::Html).unwrap(), "\"html\"");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//! Configuration loading and management.
|
|
2
|
+
//!
|
|
3
|
+
//! This module provides utilities for loading extraction configuration from various
|
|
4
|
+
//! sources (TOML, YAML, JSON) and discovering configuration files in the project hierarchy.
|
|
5
|
+
|
|
6
|
+
pub mod extraction;
|
|
7
|
+
pub mod formats;
|
|
8
|
+
pub mod ocr;
|
|
9
|
+
pub mod page;
|
|
10
|
+
pub mod pdf;
|
|
11
|
+
pub mod processing;
|
|
12
|
+
|
|
13
|
+
// Re-export main types for backward compatibility
|
|
14
|
+
pub use extraction::{ExtractionConfig, ImageExtractionConfig, LanguageDetectionConfig, TokenReductionConfig};
|
|
15
|
+
pub use formats::OutputFormat;
|
|
16
|
+
pub use ocr::OcrConfig;
|
|
17
|
+
pub use page::PageConfig;
|
|
18
|
+
#[cfg(feature = "pdf")]
|
|
19
|
+
pub use pdf::{HierarchyConfig, PdfConfig};
|
|
20
|
+
pub use processing::{ChunkingConfig, EmbeddingConfig, EmbeddingModelType, PostProcessorConfig};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//! OCR configuration.
|
|
2
|
+
//!
|
|
3
|
+
//! Defines OCR-specific configuration including backend selection, language settings,
|
|
4
|
+
//! and Tesseract-specific parameters.
|
|
5
|
+
|
|
6
|
+
use serde::{Deserialize, Serialize};
|
|
7
|
+
|
|
8
|
+
use super::formats::OutputFormat;
|
|
9
|
+
|
|
10
|
+
/// OCR configuration.
|
|
11
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
12
|
+
pub struct OcrConfig {
|
|
13
|
+
/// OCR backend: tesseract, easyocr, paddleocr
|
|
14
|
+
#[serde(default = "default_tesseract_backend")]
|
|
15
|
+
pub backend: String,
|
|
16
|
+
|
|
17
|
+
/// Language code (e.g., "eng", "deu")
|
|
18
|
+
#[serde(default = "default_eng")]
|
|
19
|
+
pub language: String,
|
|
20
|
+
|
|
21
|
+
/// Tesseract-specific configuration (optional)
|
|
22
|
+
#[serde(default)]
|
|
23
|
+
pub tesseract_config: Option<crate::types::TesseractConfig>,
|
|
24
|
+
|
|
25
|
+
/// Output format for OCR results (optional, for format conversion)
|
|
26
|
+
#[serde(default)]
|
|
27
|
+
pub output_format: Option<OutputFormat>,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
impl Default for OcrConfig {
|
|
31
|
+
fn default() -> Self {
|
|
32
|
+
Self {
|
|
33
|
+
backend: default_tesseract_backend(),
|
|
34
|
+
language: default_eng(),
|
|
35
|
+
tesseract_config: None,
|
|
36
|
+
output_format: None,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fn default_tesseract_backend() -> String {
|
|
42
|
+
"tesseract".to_string()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fn default_eng() -> String {
|
|
46
|
+
"eng".to_string()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#[cfg(test)]
|
|
50
|
+
mod tests {
|
|
51
|
+
use super::*;
|
|
52
|
+
|
|
53
|
+
#[test]
|
|
54
|
+
fn test_ocr_config_default() {
|
|
55
|
+
let config = OcrConfig::default();
|
|
56
|
+
assert_eq!(config.backend, "tesseract");
|
|
57
|
+
assert_eq!(config.language, "eng");
|
|
58
|
+
assert!(config.tesseract_config.is_none());
|
|
59
|
+
assert!(config.output_format.is_none());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[test]
|
|
63
|
+
fn test_ocr_config_with_tesseract() {
|
|
64
|
+
let config = OcrConfig {
|
|
65
|
+
backend: "tesseract".to_string(),
|
|
66
|
+
language: "fra".to_string(),
|
|
67
|
+
tesseract_config: None,
|
|
68
|
+
output_format: None,
|
|
69
|
+
};
|
|
70
|
+
assert_eq!(config.backend, "tesseract");
|
|
71
|
+
assert_eq!(config.language, "fra");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//! Page extraction and tracking configuration.
|
|
2
|
+
//!
|
|
3
|
+
//! Controls how pages are extracted, tracked, and represented in extraction results.
|
|
4
|
+
//! When `None`, page tracking is disabled.
|
|
5
|
+
|
|
6
|
+
use serde::{Deserialize, Serialize};
|
|
7
|
+
|
|
8
|
+
/// Page extraction and tracking configuration.
|
|
9
|
+
///
|
|
10
|
+
/// Controls how pages are extracted, tracked, and represented in the extraction results.
|
|
11
|
+
/// When `None`, page tracking is disabled.
|
|
12
|
+
///
|
|
13
|
+
/// Page range tracking in chunk metadata (first_page/last_page) is automatically enabled
|
|
14
|
+
/// when page boundaries are available and chunking is configured.
|
|
15
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
16
|
+
#[serde(default)]
|
|
17
|
+
pub struct PageConfig {
|
|
18
|
+
/// Extract pages as separate array (ExtractionResult.pages)
|
|
19
|
+
#[serde(default)]
|
|
20
|
+
pub extract_pages: bool,
|
|
21
|
+
|
|
22
|
+
/// Insert page markers in main content string
|
|
23
|
+
#[serde(default)]
|
|
24
|
+
pub insert_page_markers: bool,
|
|
25
|
+
|
|
26
|
+
/// Page marker format (use {page_num} placeholder)
|
|
27
|
+
/// Default: "\n\n<!-- PAGE {page_num} -->\n\n"
|
|
28
|
+
#[serde(default = "default_page_marker_format")]
|
|
29
|
+
pub marker_format: String,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
impl Default for PageConfig {
|
|
33
|
+
fn default() -> Self {
|
|
34
|
+
Self {
|
|
35
|
+
extract_pages: false,
|
|
36
|
+
insert_page_markers: false,
|
|
37
|
+
marker_format: "\n\n<!-- PAGE {page_num} -->\n\n".to_string(),
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fn default_page_marker_format() -> String {
|
|
43
|
+
"\n\n<!-- PAGE {page_num} -->\n\n".to_string()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[cfg(test)]
|
|
47
|
+
mod tests {
|
|
48
|
+
use super::*;
|
|
49
|
+
|
|
50
|
+
#[test]
|
|
51
|
+
fn test_page_config_default() {
|
|
52
|
+
let config = PageConfig::default();
|
|
53
|
+
assert!(!config.extract_pages);
|
|
54
|
+
assert!(!config.insert_page_markers);
|
|
55
|
+
assert_eq!(config.marker_format, "\n\n<!-- PAGE {page_num} -->\n\n");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//! PDF-specific configuration.
|
|
2
|
+
//!
|
|
3
|
+
//! Defines PDF extraction options including metadata handling, image extraction,
|
|
4
|
+
//! password management, and hierarchy extraction for document structure analysis.
|
|
5
|
+
|
|
6
|
+
use serde::{Deserialize, Serialize};
|
|
7
|
+
|
|
8
|
+
/// PDF-specific configuration.
|
|
9
|
+
#[cfg(feature = "pdf")]
|
|
10
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
11
|
+
pub struct PdfConfig {
|
|
12
|
+
/// Extract images from PDF
|
|
13
|
+
#[serde(default)]
|
|
14
|
+
pub extract_images: bool,
|
|
15
|
+
|
|
16
|
+
/// List of passwords to try when opening encrypted PDFs
|
|
17
|
+
#[serde(default)]
|
|
18
|
+
pub passwords: Option<Vec<String>>,
|
|
19
|
+
|
|
20
|
+
/// Extract PDF metadata
|
|
21
|
+
#[serde(default = "default_true")]
|
|
22
|
+
pub extract_metadata: bool,
|
|
23
|
+
|
|
24
|
+
/// Hierarchy extraction configuration (None = hierarchy extraction disabled)
|
|
25
|
+
#[serde(default)]
|
|
26
|
+
pub hierarchy: Option<HierarchyConfig>,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Hierarchy extraction configuration for PDF text structure analysis.
|
|
30
|
+
///
|
|
31
|
+
/// Enables extraction of document hierarchy levels (H1-H6) based on font size
|
|
32
|
+
/// clustering and semantic analysis. When enabled, hierarchical blocks are
|
|
33
|
+
/// included in page content.
|
|
34
|
+
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
35
|
+
pub struct HierarchyConfig {
|
|
36
|
+
/// Enable hierarchy extraction
|
|
37
|
+
#[serde(default = "default_true")]
|
|
38
|
+
pub enabled: bool,
|
|
39
|
+
|
|
40
|
+
/// Number of font size clusters to use for hierarchy levels (1-7)
|
|
41
|
+
///
|
|
42
|
+
/// Default: 6, which provides H1-H6 heading levels with body text.
|
|
43
|
+
/// Larger values create more fine-grained hierarchy levels.
|
|
44
|
+
#[serde(default = "default_k_clusters")]
|
|
45
|
+
pub k_clusters: usize,
|
|
46
|
+
|
|
47
|
+
/// Include bounding box information in hierarchy blocks
|
|
48
|
+
#[serde(default = "default_true")]
|
|
49
|
+
pub include_bbox: bool,
|
|
50
|
+
|
|
51
|
+
/// OCR coverage threshold for smart OCR triggering (0.0-1.0)
|
|
52
|
+
///
|
|
53
|
+
/// Determines when OCR should be triggered based on text block coverage.
|
|
54
|
+
/// OCR is triggered when text blocks cover less than this fraction of the page.
|
|
55
|
+
/// Default: 0.5 (trigger OCR if less than 50% of page has text)
|
|
56
|
+
#[serde(default = "default_ocr_coverage_threshold")]
|
|
57
|
+
pub ocr_coverage_threshold: Option<f32>,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
impl Default for HierarchyConfig {
|
|
61
|
+
fn default() -> Self {
|
|
62
|
+
Self {
|
|
63
|
+
enabled: true,
|
|
64
|
+
k_clusters: 6,
|
|
65
|
+
include_bbox: true,
|
|
66
|
+
ocr_coverage_threshold: None,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn default_true() -> bool {
|
|
72
|
+
true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn default_k_clusters() -> usize {
|
|
76
|
+
6
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn default_ocr_coverage_threshold() -> Option<f32> {
|
|
80
|
+
None
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[cfg(test)]
|
|
84
|
+
mod tests {
|
|
85
|
+
use super::*;
|
|
86
|
+
|
|
87
|
+
#[test]
|
|
88
|
+
#[cfg(feature = "pdf")]
|
|
89
|
+
fn test_hierarchy_config_default() {
|
|
90
|
+
let config = HierarchyConfig::default();
|
|
91
|
+
assert!(config.enabled);
|
|
92
|
+
assert_eq!(config.k_clusters, 6);
|
|
93
|
+
assert!(config.include_bbox);
|
|
94
|
+
assert!(config.ocr_coverage_threshold.is_none());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#[test]
|
|
98
|
+
#[cfg(feature = "pdf")]
|
|
99
|
+
fn test_hierarchy_config_disabled() {
|
|
100
|
+
let config = HierarchyConfig {
|
|
101
|
+
enabled: false,
|
|
102
|
+
k_clusters: 3,
|
|
103
|
+
include_bbox: false,
|
|
104
|
+
ocr_coverage_threshold: Some(0.7),
|
|
105
|
+
};
|
|
106
|
+
assert!(!config.enabled);
|
|
107
|
+
assert_eq!(config.k_clusters, 3);
|
|
108
|
+
assert!(!config.include_bbox);
|
|
109
|
+
assert_eq!(config.ocr_coverage_threshold, Some(0.7));
|
|
110
|
+
}
|
|
111
|
+
}
|