kreuzberg 4.0.0.pre.rc.6 → 4.0.0.pre.rc.8
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 +5 -5
- data/README.md +15 -9
- data/ext/kreuzberg_rb/native/.cargo/config.toml +2 -0
- data/ext/kreuzberg_rb/native/Cargo.lock +511 -325
- data/ext/kreuzberg_rb/native/Cargo.toml +13 -3
- data/ext/kreuzberg_rb/native/src/lib.rs +139 -2
- data/kreuzberg.gemspec +38 -4
- data/lib/kreuzberg/config.rb +34 -1
- data/lib/kreuzberg/result.rb +77 -14
- data/lib/kreuzberg/version.rb +1 -1
- data/sig/kreuzberg.rbs +23 -6
- data/vendor/kreuzberg/Cargo.toml +32 -11
- data/vendor/kreuzberg/README.md +54 -8
- data/vendor/kreuzberg/build.rs +549 -132
- data/vendor/kreuzberg/src/chunking/mod.rs +1279 -79
- data/vendor/kreuzberg/src/chunking/processor.rs +220 -0
- data/vendor/kreuzberg/src/core/config.rs +49 -1
- data/vendor/kreuzberg/src/core/extractor.rs +134 -2
- data/vendor/kreuzberg/src/core/mod.rs +4 -2
- data/vendor/kreuzberg/src/core/pipeline.rs +188 -1
- data/vendor/kreuzberg/src/extraction/docx.rs +358 -0
- data/vendor/kreuzberg/src/extraction/html.rs +24 -8
- data/vendor/kreuzberg/src/extraction/image.rs +124 -1
- data/vendor/kreuzberg/src/extraction/libreoffice.rs +1 -2
- data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -3
- data/vendor/kreuzberg/src/extraction/pptx.rs +187 -87
- data/vendor/kreuzberg/src/extractors/archive.rs +1 -0
- data/vendor/kreuzberg/src/extractors/bibtex.rs +1 -0
- data/vendor/kreuzberg/src/extractors/docbook.rs +2 -0
- data/vendor/kreuzberg/src/extractors/docx.rs +50 -17
- data/vendor/kreuzberg/src/extractors/email.rs +29 -15
- data/vendor/kreuzberg/src/extractors/epub.rs +1 -0
- data/vendor/kreuzberg/src/extractors/excel.rs +2 -0
- data/vendor/kreuzberg/src/extractors/fictionbook.rs +1 -0
- data/vendor/kreuzberg/src/extractors/html.rs +29 -15
- data/vendor/kreuzberg/src/extractors/image.rs +25 -4
- data/vendor/kreuzberg/src/extractors/jats.rs +3 -0
- data/vendor/kreuzberg/src/extractors/jupyter.rs +1 -0
- data/vendor/kreuzberg/src/extractors/latex.rs +1 -0
- data/vendor/kreuzberg/src/extractors/markdown.rs +1 -0
- data/vendor/kreuzberg/src/extractors/mod.rs +78 -14
- data/vendor/kreuzberg/src/extractors/odt.rs +3 -3
- data/vendor/kreuzberg/src/extractors/opml.rs +1 -0
- data/vendor/kreuzberg/src/extractors/orgmode.rs +1 -0
- data/vendor/kreuzberg/src/extractors/pdf.rs +197 -17
- data/vendor/kreuzberg/src/extractors/pptx.rs +32 -13
- data/vendor/kreuzberg/src/extractors/rst.rs +1 -0
- data/vendor/kreuzberg/src/extractors/rtf.rs +3 -4
- data/vendor/kreuzberg/src/extractors/structured.rs +2 -0
- data/vendor/kreuzberg/src/extractors/text.rs +7 -2
- data/vendor/kreuzberg/src/extractors/typst.rs +1 -0
- data/vendor/kreuzberg/src/extractors/xml.rs +27 -15
- data/vendor/kreuzberg/src/keywords/processor.rs +9 -1
- data/vendor/kreuzberg/src/language_detection/mod.rs +43 -0
- data/vendor/kreuzberg/src/language_detection/processor.rs +219 -0
- data/vendor/kreuzberg/src/lib.rs +10 -2
- data/vendor/kreuzberg/src/mcp/mod.rs +3 -0
- data/vendor/kreuzberg/src/mcp/server.rs +120 -12
- data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +2 -0
- data/vendor/kreuzberg/src/pdf/bundled.rs +328 -0
- data/vendor/kreuzberg/src/pdf/error.rs +8 -0
- data/vendor/kreuzberg/src/pdf/metadata.rs +238 -95
- data/vendor/kreuzberg/src/pdf/mod.rs +18 -2
- data/vendor/kreuzberg/src/pdf/rendering.rs +1 -2
- data/vendor/kreuzberg/src/pdf/table.rs +26 -2
- data/vendor/kreuzberg/src/pdf/text.rs +89 -7
- data/vendor/kreuzberg/src/plugins/extractor.rs +34 -3
- data/vendor/kreuzberg/src/plugins/mod.rs +3 -0
- data/vendor/kreuzberg/src/plugins/ocr.rs +22 -3
- data/vendor/kreuzberg/src/plugins/processor.rs +8 -0
- data/vendor/kreuzberg/src/plugins/registry.rs +2 -0
- data/vendor/kreuzberg/src/plugins/validator.rs +11 -0
- data/vendor/kreuzberg/src/text/mod.rs +6 -0
- data/vendor/kreuzberg/src/text/quality_processor.rs +219 -0
- data/vendor/kreuzberg/src/types.rs +173 -21
- data/vendor/kreuzberg/tests/archive_integration.rs +2 -0
- data/vendor/kreuzberg/tests/batch_processing.rs +5 -3
- data/vendor/kreuzberg/tests/concurrency_stress.rs +14 -6
- data/vendor/kreuzberg/tests/config_features.rs +15 -1
- data/vendor/kreuzberg/tests/config_loading_tests.rs +1 -0
- data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +2 -0
- data/vendor/kreuzberg/tests/email_integration.rs +2 -0
- data/vendor/kreuzberg/tests/error_handling.rs +43 -34
- data/vendor/kreuzberg/tests/format_integration.rs +2 -0
- data/vendor/kreuzberg/tests/image_integration.rs +2 -0
- data/vendor/kreuzberg/tests/mime_detection.rs +17 -16
- data/vendor/kreuzberg/tests/ocr_configuration.rs +4 -0
- data/vendor/kreuzberg/tests/ocr_errors.rs +22 -0
- data/vendor/kreuzberg/tests/ocr_quality.rs +2 -0
- data/vendor/kreuzberg/tests/odt_extractor_tests.rs +0 -21
- data/vendor/kreuzberg/tests/pdf_integration.rs +2 -0
- data/vendor/kreuzberg/tests/pdfium_linking.rs +374 -0
- data/vendor/kreuzberg/tests/pipeline_integration.rs +25 -0
- data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +5 -0
- data/vendor/kreuzberg/tests/plugin_system.rs +6 -0
- data/vendor/kreuzberg/tests/registry_integration_tests.rs +1 -0
- data/vendor/kreuzberg/tests/rst_extractor_tests.rs +2 -0
- data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -1
- data/vendor/kreuzberg/tests/security_validation.rs +1 -0
- data/vendor/kreuzberg/tests/test_fastembed.rs +45 -23
- data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +1 -0
- data/vendor/kreuzberg/tests/typst_extractor_tests.rs +3 -2
- data/vendor/rb-sys/.cargo_vcs_info.json +2 -2
- data/vendor/rb-sys/Cargo.lock +15 -15
- data/vendor/rb-sys/Cargo.toml +4 -4
- data/vendor/rb-sys/Cargo.toml.orig +4 -4
- data/vendor/rb-sys/build/features.rs +5 -2
- data/vendor/rb-sys/build/main.rs +55 -15
- data/vendor/rb-sys/build/stable_api_config.rs +4 -2
- data/vendor/rb-sys/build/version.rs +3 -1
- data/vendor/rb-sys/src/lib.rs +1 -0
- data/vendor/rb-sys/src/macros.rs +2 -2
- data/vendor/rb-sys/src/special_consts.rs +1 -1
- data/vendor/rb-sys/src/stable_api/compiled.rs +1 -1
- data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +12 -4
- data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +12 -4
- data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +12 -4
- data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +12 -4
- data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +19 -6
- data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +17 -5
- data/vendor/rb-sys/src/stable_api.rs +0 -1
- data/vendor/rb-sys/src/tracking_allocator.rs +1 -3
- metadata +13 -10
- data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +0 -738
- data/vendor/rb-sys/.cargo-ok +0 -1
- data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +0 -316
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
//! Tests for .eml (RFC822) email extraction.
|
|
4
4
|
//! Validates metadata extraction, content extraction, HTML/plain text handling, and attachments.
|
|
5
5
|
|
|
6
|
+
#![cfg(feature = "email")]
|
|
7
|
+
|
|
6
8
|
use kreuzberg::core::config::ExtractionConfig;
|
|
7
9
|
use kreuzberg::core::extractor::extract_bytes;
|
|
8
10
|
|
|
@@ -12,6 +12,7 @@ mod helpers;
|
|
|
12
12
|
|
|
13
13
|
/// Test truncated PDF - incomplete PDF file.
|
|
14
14
|
#[tokio::test]
|
|
15
|
+
#[cfg(feature = "pdf")]
|
|
15
16
|
async fn test_truncated_pdf() {
|
|
16
17
|
let config = ExtractionConfig::default();
|
|
17
18
|
|
|
@@ -31,6 +32,7 @@ async fn test_truncated_pdf() {
|
|
|
31
32
|
|
|
32
33
|
/// Test corrupted ZIP - malformed archive.
|
|
33
34
|
#[tokio::test]
|
|
35
|
+
#[cfg(feature = "archives")]
|
|
34
36
|
async fn test_corrupted_zip() {
|
|
35
37
|
let config = ExtractionConfig::default();
|
|
36
38
|
|
|
@@ -50,6 +52,7 @@ async fn test_corrupted_zip() {
|
|
|
50
52
|
|
|
51
53
|
/// Test invalid XML - bad XML syntax.
|
|
52
54
|
#[tokio::test]
|
|
55
|
+
#[cfg(feature = "xml")]
|
|
53
56
|
async fn test_invalid_xml() {
|
|
54
57
|
let config = ExtractionConfig::default();
|
|
55
58
|
|
|
@@ -80,6 +83,7 @@ async fn test_invalid_xml() {
|
|
|
80
83
|
|
|
81
84
|
/// Test corrupted image - invalid image data.
|
|
82
85
|
#[tokio::test]
|
|
86
|
+
#[cfg(feature = "ocr")]
|
|
83
87
|
async fn test_corrupted_image() {
|
|
84
88
|
let config = ExtractionConfig::default();
|
|
85
89
|
|
|
@@ -112,27 +116,28 @@ async fn test_empty_file() {
|
|
|
112
116
|
|
|
113
117
|
let empty_data = b"";
|
|
114
118
|
|
|
115
|
-
let result_pdf = extract_bytes(empty_data, "application/pdf", &config).await;
|
|
116
119
|
let result_text = extract_bytes(empty_data, "text/plain", &config).await;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
#[cfg(feature = "pdf")]
|
|
121
|
+
{
|
|
122
|
+
let result_pdf = extract_bytes(empty_data, "application/pdf", &config).await;
|
|
123
|
+
match result_pdf {
|
|
124
|
+
Ok(extraction) => {
|
|
125
|
+
assert!(
|
|
126
|
+
extraction.content.is_empty(),
|
|
127
|
+
"Empty PDF should have empty content if it succeeds"
|
|
128
|
+
);
|
|
129
|
+
assert!(extraction.chunks.is_none(), "Chunks should be None");
|
|
130
|
+
}
|
|
131
|
+
Err(error) => {
|
|
132
|
+
assert!(
|
|
133
|
+
matches!(
|
|
134
|
+
error,
|
|
135
|
+
kreuzberg::KreuzbergError::Parsing { .. } | kreuzberg::KreuzbergError::Validation { .. }
|
|
136
|
+
),
|
|
137
|
+
"Empty PDF should produce Parsing or Validation error, got: {:?}",
|
|
138
|
+
error
|
|
139
|
+
);
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
|
|
@@ -149,20 +154,24 @@ async fn test_empty_file() {
|
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
#[cfg(feature = "xml")]
|
|
158
|
+
{
|
|
159
|
+
let result_xml = extract_bytes(empty_data, "application/xml", &config).await;
|
|
160
|
+
match result_xml {
|
|
161
|
+
Ok(extraction) => {
|
|
162
|
+
assert!(
|
|
163
|
+
extraction.content.is_empty(),
|
|
164
|
+
"Empty XML should have empty content if it succeeds"
|
|
165
|
+
);
|
|
166
|
+
assert!(extraction.chunks.is_none(), "Chunks should be None");
|
|
167
|
+
}
|
|
168
|
+
Err(error) => {
|
|
169
|
+
assert!(
|
|
170
|
+
matches!(error, kreuzberg::KreuzbergError::Parsing { .. }),
|
|
171
|
+
"Empty XML error should be Parsing type, got: {:?}",
|
|
172
|
+
error
|
|
173
|
+
);
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
//! asynchronous APIs or to graceful handling when optional system
|
|
6
6
|
//! dependencies are missing.
|
|
7
7
|
|
|
8
|
+
#![cfg(any(feature = "pdf", feature = "office", feature = "ocr"))]
|
|
9
|
+
|
|
8
10
|
mod helpers;
|
|
9
11
|
|
|
10
12
|
use helpers::{assert_mime_type, assert_non_empty_content, get_test_file_path, test_documents_available};
|
|
@@ -276,22 +276,23 @@ async fn test_no_extension() {
|
|
|
276
276
|
|
|
277
277
|
let detected = detect_mime_type(&temp_path, true);
|
|
278
278
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
279
|
+
match detected {
|
|
280
|
+
Err(error) => {
|
|
281
|
+
assert!(
|
|
282
|
+
matches!(
|
|
283
|
+
error,
|
|
284
|
+
kreuzberg::KreuzbergError::Validation { .. } | kreuzberg::KreuzbergError::UnsupportedFormat(_)
|
|
285
|
+
),
|
|
286
|
+
"Should return appropriate error for file without extension"
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
Ok(mime) => {
|
|
290
|
+
assert!(
|
|
291
|
+
mime.contains('/'),
|
|
292
|
+
"Detected MIME type should be valid format: {}",
|
|
293
|
+
mime
|
|
294
|
+
);
|
|
295
|
+
}
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
let _ = std::fs::remove_file(&temp_path);
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
//! - Verify configuration changes actually affect output
|
|
12
12
|
//! - Test table detection with various settings
|
|
13
13
|
|
|
14
|
+
#![cfg(feature = "ocr")]
|
|
15
|
+
|
|
14
16
|
mod helpers;
|
|
15
17
|
|
|
16
18
|
use helpers::*;
|
|
@@ -204,6 +206,7 @@ fn test_ocr_psm_single_line() {
|
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
#[test]
|
|
209
|
+
#[cfg(feature = "pdf")]
|
|
207
210
|
fn test_force_ocr_on_text_pdf() {
|
|
208
211
|
if skip_if_missing("pdfs/fake_memo.pdf") {
|
|
209
212
|
return;
|
|
@@ -233,6 +236,7 @@ fn test_force_ocr_on_text_pdf() {
|
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
#[test]
|
|
239
|
+
#[cfg(feature = "pdf")]
|
|
236
240
|
fn test_force_ocr_disabled() {
|
|
237
241
|
if skip_if_missing("pdfs/fake_memo.pdf") {
|
|
238
242
|
return;
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
//! - Test recovery from transient failures
|
|
14
14
|
//! - Validate resource limits and constraints
|
|
15
15
|
|
|
16
|
+
#![cfg(feature = "ocr")]
|
|
17
|
+
|
|
16
18
|
mod helpers;
|
|
17
19
|
|
|
18
20
|
use helpers::*;
|
|
@@ -451,6 +453,9 @@ fn test_ocr_cache_disabled_then_enabled() {
|
|
|
451
453
|
};
|
|
452
454
|
|
|
453
455
|
let result1 = extract_file_sync(&file_path, None, &config_no_cache);
|
|
456
|
+
if matches!(result1, Err(KreuzbergError::MissingDependency(_))) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
454
459
|
assert!(result1.is_ok(), "First extraction should succeed");
|
|
455
460
|
|
|
456
461
|
let config_with_cache = ExtractionConfig {
|
|
@@ -468,6 +473,9 @@ fn test_ocr_cache_disabled_then_enabled() {
|
|
|
468
473
|
};
|
|
469
474
|
|
|
470
475
|
let result2 = extract_file_sync(&file_path, None, &config_with_cache);
|
|
476
|
+
if matches!(result2, Err(KreuzbergError::MissingDependency(_))) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
471
479
|
assert!(result2.is_ok(), "Second extraction should succeed");
|
|
472
480
|
|
|
473
481
|
assert_non_empty_content(&result1.unwrap());
|
|
@@ -495,6 +503,13 @@ fn test_ocr_concurrent_same_file() {
|
|
|
495
503
|
..Default::default()
|
|
496
504
|
});
|
|
497
505
|
|
|
506
|
+
if matches!(
|
|
507
|
+
extract_file_sync(&*file_path, None, &config),
|
|
508
|
+
Err(KreuzbergError::MissingDependency(_))
|
|
509
|
+
) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
|
|
498
513
|
let mut handles = vec![];
|
|
499
514
|
for i in 0..5 {
|
|
500
515
|
let file_path_clone = Arc::clone(&file_path);
|
|
@@ -554,6 +569,13 @@ fn test_ocr_concurrent_different_files() {
|
|
|
554
569
|
..Default::default()
|
|
555
570
|
});
|
|
556
571
|
|
|
572
|
+
if matches!(
|
|
573
|
+
extract_file_sync(&files[0], None, &config),
|
|
574
|
+
Err(KreuzbergError::MissingDependency(_))
|
|
575
|
+
) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
|
|
557
579
|
let mut handles = vec![];
|
|
558
580
|
for (i, file_path) in files.iter().enumerate() {
|
|
559
581
|
let file_path_clone = file_path.clone();
|
|
@@ -69,16 +69,13 @@ async fn test_odt_metadata_extraction() {
|
|
|
69
69
|
"Should contain document title in content"
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
// Verify metadata extraction
|
|
73
72
|
let metadata = &result.metadata.additional;
|
|
74
73
|
println!("Extracted metadata: {:?}", metadata);
|
|
75
74
|
|
|
76
|
-
// Check title
|
|
77
75
|
if let Some(title) = metadata.get("title") {
|
|
78
76
|
assert_eq!(title.as_str(), Some("Test Metadata Document"), "Title should match");
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
// Check subject
|
|
82
79
|
if let Some(subject) = metadata.get("subject") {
|
|
83
80
|
assert_eq!(
|
|
84
81
|
subject.as_str(),
|
|
@@ -87,28 +84,23 @@ async fn test_odt_metadata_extraction() {
|
|
|
87
84
|
);
|
|
88
85
|
}
|
|
89
86
|
|
|
90
|
-
// Check creator/author
|
|
91
87
|
if let Some(created_by) = metadata.get("created_by") {
|
|
92
88
|
assert_eq!(created_by.as_str(), Some("John Doe"), "Creator should match");
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
// Check authors array
|
|
96
91
|
if let Some(authors) = metadata.get("authors") {
|
|
97
92
|
let authors_array = authors.as_array().expect("Authors should be an array");
|
|
98
93
|
assert_eq!(authors_array.len(), 1, "Should have one author");
|
|
99
94
|
assert_eq!(authors_array[0].as_str(), Some("John Doe"), "Author name should match");
|
|
100
95
|
}
|
|
101
96
|
|
|
102
|
-
// Check creation date (should exist)
|
|
103
97
|
assert!(metadata.get("created_at").is_some(), "Creation date should be present");
|
|
104
98
|
|
|
105
|
-
// Check modification date (should exist)
|
|
106
99
|
assert!(
|
|
107
100
|
metadata.get("modified_at").is_some(),
|
|
108
101
|
"Modification date should be present"
|
|
109
102
|
);
|
|
110
103
|
|
|
111
|
-
// Check generator
|
|
112
104
|
if let Some(generator) = metadata.get("generator") {
|
|
113
105
|
let gen_str = generator.as_str().expect("Generator should be a string");
|
|
114
106
|
assert!(gen_str.contains("Pandoc"), "Generator should be Pandoc");
|
|
@@ -604,18 +596,11 @@ async fn test_odt_table_no_duplicate_content() {
|
|
|
604
596
|
|
|
605
597
|
assert!(!result.content.is_empty(), "Content should not be empty");
|
|
606
598
|
|
|
607
|
-
// Count how many times we see "Content" in the output
|
|
608
|
-
// In a properly fixed version, it should appear only once in the markdown table
|
|
609
|
-
// or possibly twice if headers appear with the same name, but not multiple times
|
|
610
|
-
// for the same cell
|
|
611
599
|
let content_count = result.content.matches("Content").count();
|
|
612
600
|
|
|
613
|
-
// "Content" appears twice in the header "More content" in a simple table
|
|
614
|
-
// It should not appear more than 3 times (once in header, once in data cell, once in a different word like "More content")
|
|
615
601
|
println!(" 'Content' appears {} times in output", content_count);
|
|
616
602
|
println!(" Content preview:\n{}", result.content);
|
|
617
603
|
|
|
618
|
-
// This verifies that we're not getting duplicate cell content extracted
|
|
619
604
|
assert!(
|
|
620
605
|
content_count <= 3,
|
|
621
606
|
"Content should not appear excessively, indicating no duplicate table cell extraction"
|
|
@@ -628,7 +613,6 @@ async fn test_odt_table_no_duplicate_content() {
|
|
|
628
613
|
/// Uses the extraction_test document created with pandoc to ensure complete content
|
|
629
614
|
#[tokio::test]
|
|
630
615
|
async fn test_odt_comprehensive_table_extraction() {
|
|
631
|
-
// This test uses the pandoc-generated test document
|
|
632
616
|
let test_file = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
633
617
|
.parent()
|
|
634
618
|
.unwrap()
|
|
@@ -648,7 +632,6 @@ async fn test_odt_comprehensive_table_extraction() {
|
|
|
648
632
|
|
|
649
633
|
assert!(!result.content.is_empty(), "Content should not be empty");
|
|
650
634
|
|
|
651
|
-
// Verify all sections are present
|
|
652
635
|
assert!(result.content.contains("Comprehensive"), "Should contain heading");
|
|
653
636
|
assert!(
|
|
654
637
|
result.content.contains("First Section") || result.content.contains("First"),
|
|
@@ -663,14 +646,12 @@ async fn test_odt_comprehensive_table_extraction() {
|
|
|
663
646
|
"Should contain third section"
|
|
664
647
|
);
|
|
665
648
|
|
|
666
|
-
// Verify tables are present and formatted correctly (as markdown)
|
|
667
649
|
assert!(
|
|
668
650
|
result.content.contains("|"),
|
|
669
651
|
"Should contain pipe characters for markdown tables"
|
|
670
652
|
);
|
|
671
653
|
assert!(result.content.contains("---"), "Should contain table separator");
|
|
672
654
|
|
|
673
|
-
// Verify table content is extracted
|
|
674
655
|
assert!(
|
|
675
656
|
result.content.contains("Header 1") || result.content.contains("Cell 1A"),
|
|
676
657
|
"Should contain table data"
|
|
@@ -680,8 +661,6 @@ async fn test_odt_comprehensive_table_extraction() {
|
|
|
680
661
|
"Should contain second table data"
|
|
681
662
|
);
|
|
682
663
|
|
|
683
|
-
// Verify no excessive duplication of cells (a simple heuristic check)
|
|
684
|
-
// Count "Cell 1A" - should appear once or twice at most
|
|
685
664
|
let cell_count = result.content.matches("Cell 1A").count();
|
|
686
665
|
assert!(
|
|
687
666
|
cell_count <= 2,
|