|
17 | 17 | max_retries: 80 |
18 | 18 | ) |
19 | 19 |
|
20 | | - params = Mindee::Input::InferenceParameters.new(model_id, |
21 | | - rag: false, |
22 | | - file_alias: 'ruby-integration-test', |
23 | | - polling_options: polling) |
| 20 | + params = Mindee::Input::InferenceParameters.new( |
| 21 | + model_id, |
| 22 | + rag: false, |
| 23 | + raw_text: true, |
| 24 | + polygon: false, |
| 25 | + confidence: false, |
| 26 | + file_alias: 'ruby-integration-test', |
| 27 | + polling_options: polling |
| 28 | + ) |
24 | 29 |
|
25 | 30 | response = client.enqueue_and_get_inference(input, params) |
26 | 31 |
|
27 | 32 | expect(response).not_to be_nil |
28 | 33 | expect(response.inference).not_to be_nil |
29 | 34 |
|
30 | | - expect(response.inference.file).not_to be_nil |
31 | | - expect(response.inference.file.name).to eq('multipage_cut-2.pdf') |
| 35 | + file = response.inference.file |
| 36 | + expect(file).not_to be_nil |
| 37 | + expect(file).to be_a(Mindee::Parsing::V2::InferenceFile) |
| 38 | + expect(file.name).to eq('multipage_cut-2.pdf') |
| 39 | + expect(file.page_count).to eq(2) |
| 40 | + |
| 41 | + model = response.inference.model |
| 42 | + expect(model).not_to be_nil |
| 43 | + expect(model).to be_a(Mindee::Parsing::V2::InferenceModel) |
| 44 | + expect(model.id).to eq(model_id) |
32 | 45 |
|
33 | | - expect(response.inference.model).not_to be_nil |
34 | | - expect(response.inference.model.id).to eq(model_id) |
| 46 | + active_options = response.inference.active_options |
| 47 | + expect(active_options).not_to be_nil |
| 48 | + expect(active_options).to be_a(Mindee::Parsing::V2::InferenceActiveOptions) |
| 49 | + expect(active_options.raw_text).to eq(true) |
| 50 | + expect(active_options.polygon).to eq(false) |
| 51 | + expect(active_options.confidence).to eq(false) |
| 52 | + expect(active_options.rag).to eq(false) |
35 | 53 |
|
36 | | - expect(response.inference.active_options).not_to be_nil |
| 54 | + result = response.inference.result |
| 55 | + expect(result).not_to be_nil |
37 | 56 |
|
38 | | - expect(response.inference.result).not_to be_nil |
39 | | - expect(response.inference.result.raw_text).to be_nil |
40 | | - expect(response.inference.result.fields).not_to be_nil |
| 57 | + expect(result.raw_text).not_to be_nil |
| 58 | + expect(result.raw_text.pages.length).to eq(2) |
| 59 | + |
| 60 | + expect(result.fields).not_to be_nil |
41 | 61 | end |
42 | 62 |
|
43 | 63 | it 'parses a filled single-page image successfully' do |
44 | 64 | src_path = File.join(__dir__ || './', 'data', 'products', 'financial_document', 'default_sample.jpg') |
45 | 65 | input = Mindee::Input::Source::FileInputSource.new(File.open(src_path, 'rb'), 'default_sample.jpg') |
46 | 66 |
|
47 | | - params = Mindee::Input::InferenceParameters.new(model_id, |
48 | | - rag: false, |
49 | | - file_alias: 'ruby-integration-test') |
| 67 | + params = Mindee::Input::InferenceParameters.new( |
| 68 | + model_id, |
| 69 | + raw_text: false, |
| 70 | + polygon: false, |
| 71 | + confidence: false, |
| 72 | + rag: false, |
| 73 | + file_alias: 'ruby-integration-test' |
| 74 | + ) |
50 | 75 |
|
51 | 76 | response = client.enqueue_and_get_inference(input, params) |
52 | 77 | expect(response).not_to be_nil |
53 | 78 |
|
54 | | - expect(response.inference).not_to be_nil |
55 | | - expect(response.inference.file.name).to eq('default_sample.jpg') |
| 79 | + file = response.inference.file |
| 80 | + expect(file).not_to be_nil |
| 81 | + expect(file).to be_a(Mindee::Parsing::V2::InferenceFile) |
| 82 | + expect(file.name).to eq('default_sample.jpg') |
| 83 | + expect(file.page_count).to eq(1) |
| 84 | + |
| 85 | + model = response.inference.model |
| 86 | + expect(model).not_to be_nil |
| 87 | + expect(model).to be_a(Mindee::Parsing::V2::InferenceModel) |
| 88 | + expect(model.id).to eq(model_id) |
| 89 | + |
| 90 | + active_options = response.inference.active_options |
| 91 | + expect(active_options).not_to be_nil |
| 92 | + expect(active_options).to be_a(Mindee::Parsing::V2::InferenceActiveOptions) |
| 93 | + expect(active_options.raw_text).to eq(true) |
| 94 | + expect(active_options.polygon).to eq(false) |
| 95 | + expect(active_options.confidence).to eq(false) |
| 96 | + expect(active_options.rag).to eq(false) |
56 | 97 |
|
57 | | - expect(response.inference.model).not_to be_nil |
58 | | - expect(response.inference.model.id).to eq(model_id) |
| 98 | + result = response.inference.result |
| 99 | + expect(result).not_to be_nil |
59 | 100 |
|
60 | | - expect(response.inference.active_options).not_to be_nil |
| 101 | + expect(result.raw_text).to be_nil |
61 | 102 |
|
62 | | - fields = response.inference.result.fields |
| 103 | + fields = result.fields |
63 | 104 | expect(fields).not_to be_nil |
64 | 105 | expect(fields['supplier_name']).not_to be_nil |
65 | 106 | expect(fields['supplier_name'].value).to eq('John Smith') |
|
0 commit comments