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.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +1 -1
  4. data/ext/kreuzberg_rb/native/Cargo.lock +94 -98
  5. data/ext/kreuzberg_rb/native/Cargo.toml +4 -2
  6. data/ext/kreuzberg_rb/native/src/batch.rs +139 -0
  7. data/ext/kreuzberg_rb/native/src/config/mod.rs +10 -0
  8. data/ext/kreuzberg_rb/native/src/config/types.rs +1058 -0
  9. data/ext/kreuzberg_rb/native/src/error_handling.rs +125 -0
  10. data/ext/kreuzberg_rb/native/src/extraction.rs +79 -0
  11. data/ext/kreuzberg_rb/native/src/gc_guarded_value.rs +35 -0
  12. data/ext/kreuzberg_rb/native/src/helpers.rs +176 -0
  13. data/ext/kreuzberg_rb/native/src/lib.rs +342 -3622
  14. data/ext/kreuzberg_rb/native/src/metadata.rs +34 -0
  15. data/ext/kreuzberg_rb/native/src/plugins/mod.rs +92 -0
  16. data/ext/kreuzberg_rb/native/src/plugins/ocr_backend.rs +159 -0
  17. data/ext/kreuzberg_rb/native/src/plugins/post_processor.rs +126 -0
  18. data/ext/kreuzberg_rb/native/src/plugins/validator.rs +99 -0
  19. data/ext/kreuzberg_rb/native/src/result.rs +326 -0
  20. data/ext/kreuzberg_rb/native/src/validation.rs +4 -0
  21. data/lib/kreuzberg/config.rb +66 -0
  22. data/lib/kreuzberg/result.rb +107 -2
  23. data/lib/kreuzberg/types.rb +104 -0
  24. data/lib/kreuzberg/version.rb +1 -1
  25. data/lib/kreuzberg.rb +0 -4
  26. data/sig/kreuzberg.rbs +105 -1
  27. data/vendor/Cargo.toml +3 -3
  28. data/vendor/kreuzberg/Cargo.toml +4 -3
  29. data/vendor/kreuzberg/README.md +1 -1
  30. data/vendor/kreuzberg/src/api/config.rs +69 -0
  31. data/vendor/kreuzberg/src/api/handlers.rs +99 -2
  32. data/vendor/kreuzberg/src/api/mod.rs +14 -7
  33. data/vendor/kreuzberg/src/api/router.rs +214 -0
  34. data/vendor/kreuzberg/src/api/startup.rs +243 -0
  35. data/vendor/kreuzberg/src/api/types.rs +78 -0
  36. data/vendor/kreuzberg/src/cache/cleanup.rs +277 -0
  37. data/vendor/kreuzberg/src/cache/core.rs +428 -0
  38. data/vendor/kreuzberg/src/cache/mod.rs +21 -843
  39. data/vendor/kreuzberg/src/cache/utilities.rs +156 -0
  40. data/vendor/kreuzberg/src/chunking/boundaries.rs +301 -0
  41. data/vendor/kreuzberg/src/chunking/builder.rs +294 -0
  42. data/vendor/kreuzberg/src/chunking/config.rs +52 -0
  43. data/vendor/kreuzberg/src/chunking/core.rs +1017 -0
  44. data/vendor/kreuzberg/src/chunking/mod.rs +14 -2211
  45. data/vendor/kreuzberg/src/chunking/processor.rs +10 -0
  46. data/vendor/kreuzberg/src/chunking/validation.rs +686 -0
  47. data/vendor/kreuzberg/src/core/config/extraction/core.rs +169 -0
  48. data/vendor/kreuzberg/src/core/config/extraction/env.rs +179 -0
  49. data/vendor/kreuzberg/src/core/config/extraction/loaders.rs +204 -0
  50. data/vendor/kreuzberg/src/core/config/extraction/mod.rs +42 -0
  51. data/vendor/kreuzberg/src/core/config/extraction/types.rs +93 -0
  52. data/vendor/kreuzberg/src/core/config/formats.rs +135 -0
  53. data/vendor/kreuzberg/src/core/config/mod.rs +20 -0
  54. data/vendor/kreuzberg/src/core/config/ocr.rs +73 -0
  55. data/vendor/kreuzberg/src/core/config/page.rs +57 -0
  56. data/vendor/kreuzberg/src/core/config/pdf.rs +111 -0
  57. data/vendor/kreuzberg/src/core/config/processing.rs +312 -0
  58. data/vendor/kreuzberg/src/core/config_validation/dependencies.rs +187 -0
  59. data/vendor/kreuzberg/src/core/config_validation/mod.rs +386 -0
  60. data/vendor/kreuzberg/src/core/config_validation/sections.rs +401 -0
  61. data/vendor/kreuzberg/src/core/extractor/batch.rs +246 -0
  62. data/vendor/kreuzberg/src/core/extractor/bytes.rs +116 -0
  63. data/vendor/kreuzberg/src/core/extractor/file.rs +240 -0
  64. data/vendor/kreuzberg/src/core/extractor/helpers.rs +71 -0
  65. data/vendor/kreuzberg/src/core/extractor/legacy.rs +62 -0
  66. data/vendor/kreuzberg/src/core/extractor/mod.rs +490 -0
  67. data/vendor/kreuzberg/src/core/extractor/sync.rs +208 -0
  68. data/vendor/kreuzberg/src/core/mod.rs +4 -1
  69. data/vendor/kreuzberg/src/core/pipeline/cache.rs +60 -0
  70. data/vendor/kreuzberg/src/core/pipeline/execution.rs +89 -0
  71. data/vendor/kreuzberg/src/core/pipeline/features.rs +108 -0
  72. data/vendor/kreuzberg/src/core/pipeline/format.rs +392 -0
  73. data/vendor/kreuzberg/src/core/pipeline/initialization.rs +67 -0
  74. data/vendor/kreuzberg/src/core/pipeline/mod.rs +135 -0
  75. data/vendor/kreuzberg/src/core/pipeline/tests.rs +975 -0
  76. data/vendor/kreuzberg/src/core/server_config/env.rs +90 -0
  77. data/vendor/kreuzberg/src/core/server_config/loader.rs +202 -0
  78. data/vendor/kreuzberg/src/core/server_config/mod.rs +380 -0
  79. data/vendor/kreuzberg/src/core/server_config/tests/basic_tests.rs +124 -0
  80. data/vendor/kreuzberg/src/core/server_config/tests/env_tests.rs +216 -0
  81. data/vendor/kreuzberg/src/core/server_config/tests/file_loading_tests.rs +341 -0
  82. data/vendor/kreuzberg/src/core/server_config/tests/mod.rs +5 -0
  83. data/vendor/kreuzberg/src/core/server_config/validation.rs +17 -0
  84. data/vendor/kreuzberg/src/embeddings.rs +136 -13
  85. data/vendor/kreuzberg/src/extraction/{archive.rs → archive/mod.rs} +45 -239
  86. data/vendor/kreuzberg/src/extraction/archive/sevenz.rs +98 -0
  87. data/vendor/kreuzberg/src/extraction/archive/tar.rs +118 -0
  88. data/vendor/kreuzberg/src/extraction/archive/zip.rs +101 -0
  89. data/vendor/kreuzberg/src/extraction/html/converter.rs +592 -0
  90. data/vendor/kreuzberg/src/extraction/html/image_handling.rs +95 -0
  91. data/vendor/kreuzberg/src/extraction/html/mod.rs +53 -0
  92. data/vendor/kreuzberg/src/extraction/html/processor.rs +659 -0
  93. data/vendor/kreuzberg/src/extraction/html/stack_management.rs +103 -0
  94. data/vendor/kreuzberg/src/extraction/html/types.rs +28 -0
  95. data/vendor/kreuzberg/src/extraction/mod.rs +6 -2
  96. data/vendor/kreuzberg/src/extraction/pptx/container.rs +159 -0
  97. data/vendor/kreuzberg/src/extraction/pptx/content_builder.rs +168 -0
  98. data/vendor/kreuzberg/src/extraction/pptx/elements.rs +132 -0
  99. data/vendor/kreuzberg/src/extraction/pptx/image_handling.rs +57 -0
  100. data/vendor/kreuzberg/src/extraction/pptx/metadata.rs +160 -0
  101. data/vendor/kreuzberg/src/extraction/pptx/mod.rs +558 -0
  102. data/vendor/kreuzberg/src/extraction/pptx/parser.rs +379 -0
  103. data/vendor/kreuzberg/src/extraction/transform/content.rs +205 -0
  104. data/vendor/kreuzberg/src/extraction/transform/elements.rs +211 -0
  105. data/vendor/kreuzberg/src/extraction/transform/mod.rs +480 -0
  106. data/vendor/kreuzberg/src/extraction/transform/types.rs +27 -0
  107. data/vendor/kreuzberg/src/extractors/archive.rs +2 -0
  108. data/vendor/kreuzberg/src/extractors/bibtex.rs +2 -0
  109. data/vendor/kreuzberg/src/extractors/djot_format/attributes.rs +134 -0
  110. data/vendor/kreuzberg/src/extractors/djot_format/conversion.rs +223 -0
  111. data/vendor/kreuzberg/src/extractors/djot_format/extractor.rs +172 -0
  112. data/vendor/kreuzberg/src/extractors/djot_format/mod.rs +24 -0
  113. data/vendor/kreuzberg/src/extractors/djot_format/parsing/block_handlers.rs +271 -0
  114. data/vendor/kreuzberg/src/extractors/djot_format/parsing/content_extraction.rs +257 -0
  115. data/vendor/kreuzberg/src/extractors/djot_format/parsing/event_handlers.rs +101 -0
  116. data/vendor/kreuzberg/src/extractors/djot_format/parsing/inline_handlers.rs +201 -0
  117. data/vendor/kreuzberg/src/extractors/djot_format/parsing/mod.rs +16 -0
  118. data/vendor/kreuzberg/src/extractors/djot_format/parsing/state.rs +78 -0
  119. data/vendor/kreuzberg/src/extractors/djot_format/parsing/table_extraction.rs +68 -0
  120. data/vendor/kreuzberg/src/extractors/djot_format/parsing/text_extraction.rs +61 -0
  121. data/vendor/kreuzberg/src/extractors/djot_format/rendering.rs +452 -0
  122. data/vendor/kreuzberg/src/extractors/docbook.rs +2 -0
  123. data/vendor/kreuzberg/src/extractors/docx.rs +12 -1
  124. data/vendor/kreuzberg/src/extractors/email.rs +2 -0
  125. data/vendor/kreuzberg/src/extractors/epub/content.rs +333 -0
  126. data/vendor/kreuzberg/src/extractors/epub/metadata.rs +137 -0
  127. data/vendor/kreuzberg/src/extractors/epub/mod.rs +186 -0
  128. data/vendor/kreuzberg/src/extractors/epub/parsing.rs +86 -0
  129. data/vendor/kreuzberg/src/extractors/excel.rs +4 -0
  130. data/vendor/kreuzberg/src/extractors/fictionbook.rs +2 -0
  131. data/vendor/kreuzberg/src/extractors/frontmatter_utils.rs +466 -0
  132. data/vendor/kreuzberg/src/extractors/html.rs +80 -8
  133. data/vendor/kreuzberg/src/extractors/image.rs +8 -1
  134. data/vendor/kreuzberg/src/extractors/jats/elements.rs +350 -0
  135. data/vendor/kreuzberg/src/extractors/jats/metadata.rs +21 -0
  136. data/vendor/kreuzberg/src/extractors/{jats.rs → jats/mod.rs} +10 -412
  137. data/vendor/kreuzberg/src/extractors/jats/parser.rs +52 -0
  138. data/vendor/kreuzberg/src/extractors/jupyter.rs +2 -0
  139. data/vendor/kreuzberg/src/extractors/latex/commands.rs +93 -0
  140. data/vendor/kreuzberg/src/extractors/latex/environments.rs +157 -0
  141. data/vendor/kreuzberg/src/extractors/latex/metadata.rs +27 -0
  142. data/vendor/kreuzberg/src/extractors/latex/mod.rs +146 -0
  143. data/vendor/kreuzberg/src/extractors/latex/parser.rs +231 -0
  144. data/vendor/kreuzberg/src/extractors/latex/utilities.rs +126 -0
  145. data/vendor/kreuzberg/src/extractors/markdown.rs +39 -162
  146. data/vendor/kreuzberg/src/extractors/mod.rs +9 -1
  147. data/vendor/kreuzberg/src/extractors/odt.rs +2 -0
  148. data/vendor/kreuzberg/src/extractors/opml/core.rs +165 -0
  149. data/vendor/kreuzberg/src/extractors/opml/mod.rs +31 -0
  150. data/vendor/kreuzberg/src/extractors/opml/parser.rs +479 -0
  151. data/vendor/kreuzberg/src/extractors/orgmode.rs +2 -0
  152. data/vendor/kreuzberg/src/extractors/pdf/extraction.rs +106 -0
  153. data/vendor/kreuzberg/src/extractors/{pdf.rs → pdf/mod.rs} +25 -324
  154. data/vendor/kreuzberg/src/extractors/pdf/ocr.rs +214 -0
  155. data/vendor/kreuzberg/src/extractors/pdf/pages.rs +51 -0
  156. data/vendor/kreuzberg/src/extractors/pptx.rs +9 -2
  157. data/vendor/kreuzberg/src/extractors/rst.rs +2 -0
  158. data/vendor/kreuzberg/src/extractors/rtf/encoding.rs +116 -0
  159. data/vendor/kreuzberg/src/extractors/rtf/formatting.rs +24 -0
  160. data/vendor/kreuzberg/src/extractors/rtf/images.rs +72 -0
  161. data/vendor/kreuzberg/src/extractors/rtf/metadata.rs +216 -0
  162. data/vendor/kreuzberg/src/extractors/rtf/mod.rs +142 -0
  163. data/vendor/kreuzberg/src/extractors/rtf/parser.rs +259 -0
  164. data/vendor/kreuzberg/src/extractors/rtf/tables.rs +83 -0
  165. data/vendor/kreuzberg/src/extractors/structured.rs +2 -0
  166. data/vendor/kreuzberg/src/extractors/text.rs +4 -0
  167. data/vendor/kreuzberg/src/extractors/typst.rs +2 -0
  168. data/vendor/kreuzberg/src/extractors/xml.rs +2 -0
  169. data/vendor/kreuzberg/src/keywords/processor.rs +14 -0
  170. data/vendor/kreuzberg/src/language_detection/processor.rs +10 -0
  171. data/vendor/kreuzberg/src/lib.rs +2 -2
  172. data/vendor/kreuzberg/src/mcp/errors.rs +312 -0
  173. data/vendor/kreuzberg/src/mcp/format.rs +211 -0
  174. data/vendor/kreuzberg/src/mcp/mod.rs +9 -3
  175. data/vendor/kreuzberg/src/mcp/params.rs +196 -0
  176. data/vendor/kreuzberg/src/mcp/server.rs +39 -1438
  177. data/vendor/kreuzberg/src/mcp/tools/cache.rs +179 -0
  178. data/vendor/kreuzberg/src/mcp/tools/extraction.rs +403 -0
  179. data/vendor/kreuzberg/src/mcp/tools/mime.rs +150 -0
  180. data/vendor/kreuzberg/src/mcp/tools/mod.rs +11 -0
  181. data/vendor/kreuzberg/src/ocr/backends/easyocr.rs +96 -0
  182. data/vendor/kreuzberg/src/ocr/backends/mod.rs +7 -0
  183. data/vendor/kreuzberg/src/ocr/backends/paddleocr.rs +27 -0
  184. data/vendor/kreuzberg/src/ocr/backends/tesseract.rs +134 -0
  185. data/vendor/kreuzberg/src/ocr/hocr.rs +60 -16
  186. data/vendor/kreuzberg/src/ocr/language_registry.rs +11 -235
  187. data/vendor/kreuzberg/src/ocr/mod.rs +1 -0
  188. data/vendor/kreuzberg/src/ocr/processor/config.rs +203 -0
  189. data/vendor/kreuzberg/src/ocr/processor/execution.rs +494 -0
  190. data/vendor/kreuzberg/src/ocr/processor/mod.rs +265 -0
  191. data/vendor/kreuzberg/src/ocr/processor/validation.rs +145 -0
  192. data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +41 -24
  193. data/vendor/kreuzberg/src/pdf/bindings.rs +21 -8
  194. data/vendor/kreuzberg/src/pdf/hierarchy/bounding_box.rs +289 -0
  195. data/vendor/kreuzberg/src/pdf/hierarchy/clustering.rs +199 -0
  196. data/vendor/kreuzberg/src/pdf/{hierarchy.rs → hierarchy/extraction.rs} +6 -346
  197. data/vendor/kreuzberg/src/pdf/hierarchy/mod.rs +18 -0
  198. data/vendor/kreuzberg/src/plugins/extractor/mod.rs +319 -0
  199. data/vendor/kreuzberg/src/plugins/extractor/registry.rs +434 -0
  200. data/vendor/kreuzberg/src/plugins/extractor/trait.rs +391 -0
  201. data/vendor/kreuzberg/src/plugins/mod.rs +13 -0
  202. data/vendor/kreuzberg/src/plugins/ocr.rs +11 -0
  203. data/vendor/kreuzberg/src/plugins/processor/mod.rs +365 -0
  204. data/vendor/kreuzberg/src/plugins/processor/registry.rs +37 -0
  205. data/vendor/kreuzberg/src/plugins/processor/trait.rs +284 -0
  206. data/vendor/kreuzberg/src/plugins/registry/extractor.rs +416 -0
  207. data/vendor/kreuzberg/src/plugins/registry/mod.rs +116 -0
  208. data/vendor/kreuzberg/src/plugins/registry/ocr.rs +293 -0
  209. data/vendor/kreuzberg/src/plugins/registry/processor.rs +304 -0
  210. data/vendor/kreuzberg/src/plugins/registry/validator.rs +238 -0
  211. data/vendor/kreuzberg/src/plugins/validator/mod.rs +424 -0
  212. data/vendor/kreuzberg/src/plugins/validator/registry.rs +355 -0
  213. data/vendor/kreuzberg/src/plugins/validator/trait.rs +276 -0
  214. data/vendor/kreuzberg/src/stopwords/languages/asian.rs +40 -0
  215. data/vendor/kreuzberg/src/stopwords/languages/germanic.rs +36 -0
  216. data/vendor/kreuzberg/src/stopwords/languages/mod.rs +10 -0
  217. data/vendor/kreuzberg/src/stopwords/languages/other.rs +44 -0
  218. data/vendor/kreuzberg/src/stopwords/languages/romance.rs +36 -0
  219. data/vendor/kreuzberg/src/stopwords/languages/slavic.rs +36 -0
  220. data/vendor/kreuzberg/src/stopwords/mod.rs +7 -33
  221. data/vendor/kreuzberg/src/text/quality.rs +1 -1
  222. data/vendor/kreuzberg/src/text/quality_processor.rs +10 -0
  223. data/vendor/kreuzberg/src/text/token_reduction/core/analysis.rs +238 -0
  224. data/vendor/kreuzberg/src/text/token_reduction/core/mod.rs +8 -0
  225. data/vendor/kreuzberg/src/text/token_reduction/core/punctuation.rs +54 -0
  226. data/vendor/kreuzberg/src/text/token_reduction/core/reducer.rs +384 -0
  227. data/vendor/kreuzberg/src/text/token_reduction/core/sentence_selection.rs +68 -0
  228. data/vendor/kreuzberg/src/text/token_reduction/core/word_filtering.rs +156 -0
  229. data/vendor/kreuzberg/src/text/token_reduction/filters/general.rs +377 -0
  230. data/vendor/kreuzberg/src/text/token_reduction/filters/html.rs +51 -0
  231. data/vendor/kreuzberg/src/text/token_reduction/filters/markdown.rs +285 -0
  232. data/vendor/kreuzberg/src/text/token_reduction/filters.rs +131 -246
  233. data/vendor/kreuzberg/src/types/djot.rs +209 -0
  234. data/vendor/kreuzberg/src/types/extraction.rs +301 -0
  235. data/vendor/kreuzberg/src/types/formats.rs +443 -0
  236. data/vendor/kreuzberg/src/types/metadata.rs +560 -0
  237. data/vendor/kreuzberg/src/types/mod.rs +281 -0
  238. data/vendor/kreuzberg/src/types/page.rs +182 -0
  239. data/vendor/kreuzberg/src/types/serde_helpers.rs +132 -0
  240. data/vendor/kreuzberg/src/types/tables.rs +39 -0
  241. data/vendor/kreuzberg/src/utils/quality/heuristics.rs +58 -0
  242. data/vendor/kreuzberg/src/utils/{quality.rs → quality/mod.rs} +168 -489
  243. data/vendor/kreuzberg/src/utils/quality/patterns.rs +117 -0
  244. data/vendor/kreuzberg/src/utils/quality/scoring.rs +178 -0
  245. data/vendor/kreuzberg/src/utils/string_pool/buffer_pool.rs +325 -0
  246. data/vendor/kreuzberg/src/utils/string_pool/interned.rs +102 -0
  247. data/vendor/kreuzberg/src/utils/string_pool/language_pool.rs +119 -0
  248. data/vendor/kreuzberg/src/utils/string_pool/mime_pool.rs +235 -0
  249. data/vendor/kreuzberg/src/utils/string_pool/mod.rs +41 -0
  250. data/vendor/kreuzberg/tests/api_chunk.rs +313 -0
  251. data/vendor/kreuzberg/tests/api_embed.rs +6 -9
  252. data/vendor/kreuzberg/tests/batch_orchestration.rs +1 -0
  253. data/vendor/kreuzberg/tests/concurrency_stress.rs +7 -0
  254. data/vendor/kreuzberg/tests/core_integration.rs +1 -0
  255. data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +130 -0
  256. data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +5 -14
  257. data/vendor/kreuzberg/tests/format_integration.rs +2 -0
  258. data/vendor/kreuzberg/tests/helpers/mod.rs +1 -0
  259. data/vendor/kreuzberg/tests/html_table_test.rs +11 -11
  260. data/vendor/kreuzberg/tests/ocr_configuration.rs +16 -0
  261. data/vendor/kreuzberg/tests/ocr_errors.rs +18 -0
  262. data/vendor/kreuzberg/tests/ocr_quality.rs +9 -0
  263. data/vendor/kreuzberg/tests/ocr_stress.rs +1 -0
  264. data/vendor/kreuzberg/tests/pipeline_integration.rs +50 -0
  265. data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +13 -0
  266. data/vendor/kreuzberg/tests/plugin_system.rs +12 -0
  267. data/vendor/kreuzberg/tests/registry_integration_tests.rs +2 -0
  268. data/vendor/kreuzberg-ffi/Cargo.toml +2 -1
  269. data/vendor/kreuzberg-ffi/benches/result_view_benchmark.rs +2 -0
  270. data/vendor/kreuzberg-ffi/kreuzberg.h +347 -178
  271. data/vendor/kreuzberg-ffi/src/config/html.rs +318 -0
  272. data/vendor/kreuzberg-ffi/src/config/loader.rs +154 -0
  273. data/vendor/kreuzberg-ffi/src/config/merge.rs +104 -0
  274. data/vendor/kreuzberg-ffi/src/config/mod.rs +385 -0
  275. data/vendor/kreuzberg-ffi/src/config/parse.rs +91 -0
  276. data/vendor/kreuzberg-ffi/src/config/serialize.rs +118 -0
  277. data/vendor/kreuzberg-ffi/src/config_builder.rs +598 -0
  278. data/vendor/kreuzberg-ffi/src/error.rs +46 -14
  279. data/vendor/kreuzberg-ffi/src/helpers.rs +10 -0
  280. data/vendor/kreuzberg-ffi/src/html_options.rs +421 -0
  281. data/vendor/kreuzberg-ffi/src/lib.rs +16 -0
  282. data/vendor/kreuzberg-ffi/src/panic_shield.rs +11 -0
  283. data/vendor/kreuzberg-ffi/src/plugins/ocr_backend.rs +2 -0
  284. data/vendor/kreuzberg-ffi/src/result.rs +148 -122
  285. data/vendor/kreuzberg-ffi/src/result_view.rs +4 -0
  286. data/vendor/kreuzberg-tesseract/Cargo.toml +2 -2
  287. metadata +200 -28
  288. data/vendor/kreuzberg/src/api/server.rs +0 -518
  289. data/vendor/kreuzberg/src/core/config.rs +0 -1914
  290. data/vendor/kreuzberg/src/core/config_validation.rs +0 -949
  291. data/vendor/kreuzberg/src/core/extractor.rs +0 -1200
  292. data/vendor/kreuzberg/src/core/pipeline.rs +0 -1223
  293. data/vendor/kreuzberg/src/core/server_config.rs +0 -1220
  294. data/vendor/kreuzberg/src/extraction/html.rs +0 -1830
  295. data/vendor/kreuzberg/src/extraction/pptx.rs +0 -3102
  296. data/vendor/kreuzberg/src/extractors/epub.rs +0 -696
  297. data/vendor/kreuzberg/src/extractors/latex.rs +0 -653
  298. data/vendor/kreuzberg/src/extractors/opml.rs +0 -635
  299. data/vendor/kreuzberg/src/extractors/rtf.rs +0 -809
  300. data/vendor/kreuzberg/src/ocr/processor.rs +0 -858
  301. data/vendor/kreuzberg/src/plugins/extractor.rs +0 -1042
  302. data/vendor/kreuzberg/src/plugins/processor.rs +0 -650
  303. data/vendor/kreuzberg/src/plugins/registry.rs +0 -1339
  304. data/vendor/kreuzberg/src/plugins/validator.rs +0 -967
  305. data/vendor/kreuzberg/src/text/token_reduction/core.rs +0 -832
  306. data/vendor/kreuzberg/src/types.rs +0 -1713
  307. data/vendor/kreuzberg/src/utils/string_pool.rs +0 -762
  308. data/vendor/kreuzberg-ffi/src/config.rs +0 -1341
@@ -44,7 +44,11 @@ impl ImageExtractor {
44
44
  registry.get(&ocr_config.backend)?
45
45
  };
46
46
 
47
- let ocr_result = backend.process_image(content, ocr_config).await?;
47
+ // Thread output_format from ExtractionConfig to OcrConfig
48
+ let mut ocr_config_with_format = ocr_config.clone();
49
+ ocr_config_with_format.output_format = Some(config.output_format);
50
+
51
+ let ocr_result = backend.process_image(content, &ocr_config_with_format).await?;
48
52
 
49
53
  let ocr_text = ocr_result.content.clone();
50
54
  let ocr_extraction_result = crate::extraction::image::extract_text_from_image_with_ocr(
@@ -147,6 +151,7 @@ impl DocumentExtractor for ImageExtractor {
147
151
  detected_languages: None,
148
152
  chunks: None,
149
153
  images: None,
154
+ djot_content: None,
150
155
  });
151
156
  }
152
157
  }
@@ -166,6 +171,8 @@ impl DocumentExtractor for ImageExtractor {
166
171
  detected_languages: None,
167
172
  chunks: None,
168
173
  images: None,
174
+ djot_content: None,
175
+ elements: None,
169
176
  })
170
177
  }
171
178
 
@@ -0,0 +1,350 @@
1
+ //! Element extraction (title, abstract, body, references, tables).
2
+
3
+ use super::metadata::JatsMetadataExtracted;
4
+ use super::parser::extract_text_content;
5
+ use crate::Result;
6
+ use crate::extraction::cells_to_markdown;
7
+ use crate::types::Table;
8
+ use quick_xml::Reader;
9
+ use quick_xml::events::Event;
10
+
11
+ /// Extract all content in a single optimized pass.
12
+ /// Combines metadata extraction, content parsing, and table extraction into one pass.
13
+ pub(super) fn extract_jats_all_in_one(content: &str) -> Result<(JatsMetadataExtracted, String, String, Vec<Table>)> {
14
+ let mut reader = Reader::from_str(content);
15
+ let mut metadata = JatsMetadataExtracted::default();
16
+ let mut body_content = String::new();
17
+ let mut title = String::new();
18
+
19
+ let mut in_article_meta = false;
20
+ let mut in_article_title = false;
21
+ let mut in_subtitle = false;
22
+ let mut in_contrib = false;
23
+ let mut in_name = false;
24
+ let mut in_aff = false;
25
+ let mut in_abstract = false;
26
+ let mut in_kwd_group = false;
27
+ let mut in_kwd = false;
28
+ let mut current_author = String::new();
29
+ let mut current_aff = String::new();
30
+ let mut abstract_content = String::new();
31
+
32
+ let mut in_body = false;
33
+ let mut in_section = false;
34
+ let mut in_para = false;
35
+
36
+ let mut in_table = false;
37
+ let mut in_thead = false;
38
+ let mut in_tbody = false;
39
+ let mut in_row = false;
40
+ let mut current_table: Vec<Vec<String>> = Vec::new();
41
+ let mut current_row: Vec<String> = Vec::new();
42
+ let mut tables = Vec::new();
43
+ let mut table_index = 0;
44
+
45
+ loop {
46
+ match reader.read_event() {
47
+ Ok(Event::Start(e)) => {
48
+ let tag = String::from_utf8_lossy(e.name().as_ref()).to_string();
49
+
50
+ match tag.as_str() {
51
+ "article" => {
52
+ for attr in e.attributes() {
53
+ if let Ok(attr) = attr
54
+ && String::from_utf8_lossy(attr.key.as_ref()) == "article-type"
55
+ {
56
+ metadata.article_type = Some(String::from_utf8_lossy(attr.value.as_ref()).to_string());
57
+ }
58
+ }
59
+ }
60
+ "article-meta" => {
61
+ in_article_meta = true;
62
+ }
63
+ "article-title" if in_article_meta => {
64
+ in_article_title = true;
65
+ }
66
+ "subtitle" if in_article_meta => {
67
+ in_subtitle = true;
68
+ }
69
+ "contrib" if in_article_meta => {
70
+ in_contrib = true;
71
+ current_author.clear();
72
+ }
73
+ "name" if in_contrib => {
74
+ in_name = true;
75
+ }
76
+ "aff" if in_article_meta => {
77
+ in_aff = true;
78
+ current_aff.clear();
79
+ }
80
+ "article-id" if in_article_meta => {
81
+ let mut id_type = String::new();
82
+ for attr in e.attributes() {
83
+ if let Ok(attr) = attr
84
+ && String::from_utf8_lossy(attr.key.as_ref()) == "pub-id-type"
85
+ {
86
+ id_type = String::from_utf8_lossy(attr.value.as_ref()).to_string();
87
+ }
88
+ }
89
+
90
+ let id_text = extract_text_content(&mut reader)?;
91
+ match id_type.as_str() {
92
+ "doi" => metadata.doi = Some(id_text),
93
+ "pii" => metadata.pii = Some(id_text),
94
+ _ => {}
95
+ }
96
+ continue;
97
+ }
98
+ "volume" if in_article_meta => {
99
+ let vol_text = extract_text_content(&mut reader)?;
100
+ metadata.volume = Some(vol_text);
101
+ continue;
102
+ }
103
+ "issue" if in_article_meta => {
104
+ let issue_text = extract_text_content(&mut reader)?;
105
+ metadata.issue = Some(issue_text);
106
+ continue;
107
+ }
108
+ "fpage" | "lpage" if in_article_meta => {
109
+ let page_text = extract_text_content(&mut reader)?;
110
+ if let Some(pages) = &mut metadata.pages {
111
+ pages.push('-');
112
+ pages.push_str(&page_text);
113
+ } else {
114
+ metadata.pages = Some(page_text);
115
+ }
116
+ continue;
117
+ }
118
+ "pub-date" if in_article_meta => {
119
+ let date_text = extract_text_content(&mut reader)?;
120
+ if metadata.publication_date.is_none() {
121
+ metadata.publication_date = Some(date_text);
122
+ }
123
+ continue;
124
+ }
125
+ "journal-title" if in_article_meta => {
126
+ let journal_text = extract_text_content(&mut reader)?;
127
+ if metadata.journal_title.is_none() {
128
+ metadata.journal_title = Some(journal_text);
129
+ }
130
+ continue;
131
+ }
132
+ "abstract" if in_article_meta => {
133
+ in_abstract = true;
134
+ abstract_content.clear();
135
+ }
136
+ "kwd-group" if in_article_meta => {
137
+ in_kwd_group = true;
138
+ }
139
+ "kwd" if in_kwd_group => {
140
+ in_kwd = true;
141
+ }
142
+ "corresp" if in_article_meta => {
143
+ let corresp_text = extract_text_content(&mut reader)?;
144
+ metadata.corresponding_author = Some(corresp_text);
145
+ continue;
146
+ }
147
+ "body" => {
148
+ in_body = true;
149
+ }
150
+ "sec" if in_body => {
151
+ in_section = true;
152
+ }
153
+ "title" if (in_section || in_body) && !in_article_title => {
154
+ let section_title = extract_text_content(&mut reader)?;
155
+ if !section_title.is_empty() {
156
+ body_content.push_str("## ");
157
+ body_content.push_str(&section_title);
158
+ body_content.push_str("\n\n");
159
+ }
160
+ continue;
161
+ }
162
+ "p" if in_body || in_section => {
163
+ in_para = true;
164
+ }
165
+ "table" => {
166
+ in_table = true;
167
+ current_table.clear();
168
+ }
169
+ "thead" if in_table => {
170
+ in_thead = true;
171
+ }
172
+ "tbody" if in_table => {
173
+ in_tbody = true;
174
+ }
175
+ "tr" if (in_thead || in_tbody) && in_table => {
176
+ in_row = true;
177
+ current_row.clear();
178
+ }
179
+ "td" | "th" if in_row => {
180
+ let mut cell_text = String::new();
181
+ let mut cell_depth = 0;
182
+
183
+ loop {
184
+ match reader.read_event() {
185
+ Ok(Event::Start(_)) => {
186
+ cell_depth += 1;
187
+ }
188
+ Ok(Event::End(e)) => {
189
+ let tag = String::from_utf8_lossy(e.name().as_ref()).to_string();
190
+ if (tag == "td" || tag == "th") && cell_depth == 0 {
191
+ break;
192
+ }
193
+ if cell_depth > 0 {
194
+ cell_depth -= 1;
195
+ }
196
+ }
197
+ Ok(Event::Text(t)) => {
198
+ let decoded = String::from_utf8_lossy(t.as_ref()).to_string();
199
+ if !decoded.trim().is_empty() {
200
+ if !cell_text.is_empty() {
201
+ cell_text.push(' ');
202
+ }
203
+ cell_text.push_str(decoded.trim());
204
+ }
205
+ }
206
+ Ok(Event::Eof) => break,
207
+ Err(e) => {
208
+ return Err(crate::error::KreuzbergError::parsing(format!(
209
+ "XML parsing error: {}",
210
+ e
211
+ )));
212
+ }
213
+ _ => {}
214
+ }
215
+ }
216
+
217
+ current_row.push(cell_text);
218
+ }
219
+ _ => {}
220
+ }
221
+ }
222
+ Ok(Event::End(e)) => {
223
+ let tag = String::from_utf8_lossy(e.name().as_ref()).to_string();
224
+
225
+ match tag.as_str() {
226
+ "article-meta" => {
227
+ in_article_meta = false;
228
+ }
229
+ "article-title" if in_article_title => {
230
+ in_article_title = false;
231
+ }
232
+ "subtitle" if in_subtitle => {
233
+ in_subtitle = false;
234
+ }
235
+ "contrib" if in_contrib => {
236
+ if !current_author.is_empty() {
237
+ metadata.authors.push(current_author.clone());
238
+ }
239
+ in_contrib = false;
240
+ current_author.clear();
241
+ }
242
+ "name" if in_name => {
243
+ in_name = false;
244
+ }
245
+ "aff" if in_aff => {
246
+ if !current_aff.is_empty() {
247
+ metadata.affiliations.push(current_aff.clone());
248
+ }
249
+ in_aff = false;
250
+ current_aff.clear();
251
+ }
252
+ "abstract" if in_abstract => {
253
+ in_abstract = false;
254
+ metadata.abstract_text = Some(abstract_content.trim().to_string());
255
+ }
256
+ "kwd-group" if in_kwd_group => {
257
+ in_kwd_group = false;
258
+ }
259
+ "kwd" if in_kwd => {
260
+ in_kwd = false;
261
+ }
262
+ "body" => {
263
+ in_body = false;
264
+ }
265
+ "sec" if in_section => {
266
+ in_section = false;
267
+ }
268
+ "p" if in_para => {
269
+ in_para = false;
270
+ }
271
+ "table" if in_table => {
272
+ if !current_table.is_empty() {
273
+ let markdown = cells_to_markdown(&current_table);
274
+ tables.push(Table {
275
+ cells: current_table.clone(),
276
+ markdown,
277
+ page_number: table_index + 1,
278
+ });
279
+ table_index += 1;
280
+ current_table.clear();
281
+ }
282
+ in_table = false;
283
+ }
284
+ "thead" if in_thead => {
285
+ in_thead = false;
286
+ }
287
+ "tbody" if in_tbody => {
288
+ in_tbody = false;
289
+ }
290
+ "tr" if in_row => {
291
+ if !current_row.is_empty() {
292
+ current_table.push(current_row.clone());
293
+ current_row.clear();
294
+ }
295
+ in_row = false;
296
+ }
297
+ _ => {}
298
+ }
299
+ }
300
+ Ok(Event::Text(t)) => {
301
+ let decoded = String::from_utf8_lossy(t.as_ref()).to_string();
302
+ let trimmed = decoded.trim();
303
+
304
+ if !trimmed.is_empty() {
305
+ if in_article_title && metadata.title.is_empty() {
306
+ metadata.title.push_str(trimmed);
307
+ } else if in_subtitle && metadata.subtitle.is_none() {
308
+ metadata.subtitle = Some(trimmed.to_string());
309
+ } else if in_name {
310
+ if !current_author.is_empty() {
311
+ current_author.push(' ');
312
+ }
313
+ current_author.push_str(trimmed);
314
+ } else if in_aff {
315
+ if !current_aff.is_empty() {
316
+ current_aff.push(' ');
317
+ }
318
+ current_aff.push_str(trimmed);
319
+ } else if in_abstract {
320
+ if !abstract_content.is_empty() {
321
+ abstract_content.push(' ');
322
+ }
323
+ abstract_content.push_str(trimmed);
324
+ } else if in_kwd {
325
+ metadata.keywords.push(trimmed.to_string());
326
+ } else if in_para && in_body {
327
+ body_content.push_str(trimmed);
328
+ body_content.push_str("\n\n");
329
+ }
330
+ }
331
+ }
332
+ Ok(Event::Eof) => break,
333
+ Err(e) => {
334
+ return Err(crate::error::KreuzbergError::parsing(format!(
335
+ "XML parsing error: {}",
336
+ e
337
+ )));
338
+ }
339
+ _ => {}
340
+ }
341
+ }
342
+
343
+ let mut final_output = body_content;
344
+ if !metadata.title.is_empty() {
345
+ final_output = format!("# {}\n\n{}", metadata.title, final_output);
346
+ title = metadata.title.clone();
347
+ }
348
+
349
+ Ok((metadata, final_output.trim().to_string(), title, tables))
350
+ }
@@ -0,0 +1,21 @@
1
+ //! JATS metadata extraction (authors, DOI, dates, journal information).
2
+
3
+ /// Structure to hold extracted JATS metadata.
4
+ #[derive(Debug, Clone, Default)]
5
+ pub(super) struct JatsMetadataExtracted {
6
+ pub(super) title: String,
7
+ pub(super) subtitle: Option<String>,
8
+ pub(super) authors: Vec<String>,
9
+ pub(super) affiliations: Vec<String>,
10
+ pub(super) doi: Option<String>,
11
+ pub(super) pii: Option<String>,
12
+ pub(super) keywords: Vec<String>,
13
+ pub(super) publication_date: Option<String>,
14
+ pub(super) volume: Option<String>,
15
+ pub(super) issue: Option<String>,
16
+ pub(super) pages: Option<String>,
17
+ pub(super) journal_title: Option<String>,
18
+ pub(super) article_type: Option<String>,
19
+ pub(super) abstract_text: Option<String>,
20
+ pub(super) corresponding_author: Option<String>,
21
+ }