mindee-lite 5.0.0.beta1
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 +7 -0
- data/.editorconfig +24 -0
- data/.gitattributes +14 -0
- data/.gitignore +76 -0
- data/.gitmodules +3 -0
- data/.pre-commit-config.yaml +36 -0
- data/.rubocop.yml +49 -0
- data/.yardopts +4 -0
- data/CHANGELOG.md +515 -0
- data/CODE_OF_CONDUCT.md +129 -0
- data/CONTRIBUTING.md +107 -0
- data/Gemfile +14 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/Rakefile +40 -0
- data/Steepfile +30 -0
- data/bin/console +14 -0
- data/bin/mindee.rb +30 -0
- data/bin/v1/parser.rb +153 -0
- data/bin/v1/products.rb +88 -0
- data/bin/v2/parser.rb +235 -0
- data/bin/v2/products.rb +34 -0
- data/docs/code_samples/bank_account_details_v1.txt +24 -0
- data/docs/code_samples/bank_account_details_v2.txt +24 -0
- data/docs/code_samples/bank_statement_fr_v2_async.txt +24 -0
- data/docs/code_samples/barcode_reader_v1.txt +24 -0
- data/docs/code_samples/cropper_v1.txt +21 -0
- data/docs/code_samples/default.txt +30 -0
- data/docs/code_samples/default_async.txt +29 -0
- data/docs/code_samples/expense_receipts_v5.txt +25 -0
- data/docs/code_samples/expense_receipts_v5_async.txt +24 -0
- data/docs/code_samples/financial_document_v1.txt +25 -0
- data/docs/code_samples/financial_document_v1_async.txt +24 -0
- data/docs/code_samples/idcard_fr_v1.txt +24 -0
- data/docs/code_samples/idcard_fr_v2.txt +24 -0
- data/docs/code_samples/international_id_v2_async.txt +24 -0
- data/docs/code_samples/invoice_splitter_v1_async.txt +24 -0
- data/docs/code_samples/invoices_v4.txt +25 -0
- data/docs/code_samples/invoices_v4_async.txt +24 -0
- data/docs/code_samples/multi_receipts_detector_v1.txt +24 -0
- data/docs/code_samples/passport_v1.txt +24 -0
- data/docs/code_samples/resume_v1_async.txt +24 -0
- data/docs/code_samples/v2_classification.txt +30 -0
- data/docs/code_samples/v2_crop.txt +30 -0
- data/docs/code_samples/v2_extraction.txt +42 -0
- data/docs/code_samples/v2_extraction_webhook.txt +45 -0
- data/docs/code_samples/v2_ocr.txt +30 -0
- data/docs/code_samples/v2_split.txt +30 -0
- data/docs/code_samples/workflow_execution.txt +28 -0
- data/docs/code_samples/workflow_polling.txt +35 -0
- data/examples/auto_invoice_splitter_extraction.rb +48 -0
- data/examples/auto_multi_receipts_detector_extraction.rb +30 -0
- data/lib/mindee/dependency.rb +29 -0
- data/lib/mindee/error/mindee_error.rb +17 -0
- data/lib/mindee/error/mindee_http_error.rb +36 -0
- data/lib/mindee/error/mindee_http_error_v2.rb +45 -0
- data/lib/mindee/error/mindee_http_unknown_error_v2.rb +18 -0
- data/lib/mindee/error/mindee_input_error.rb +30 -0
- data/lib/mindee/error.rb +6 -0
- data/lib/mindee/geometry/min_max.rb +23 -0
- data/lib/mindee/geometry/point.rb +41 -0
- data/lib/mindee/geometry/polygon.rb +37 -0
- data/lib/mindee/geometry/quadrilateral.rb +50 -0
- data/lib/mindee/geometry/utils.rb +88 -0
- data/lib/mindee/geometry.rb +7 -0
- data/lib/mindee/http/.rubocop.yml +7 -0
- data/lib/mindee/http/http_error_handler.rb +106 -0
- data/lib/mindee/http/response_validation.rb +81 -0
- data/lib/mindee/http.rb +3 -0
- data/lib/mindee/image/extracted_image.rb +89 -0
- data/lib/mindee/image/image_compressor.rb +29 -0
- data/lib/mindee/image/image_extractor.rb +118 -0
- data/lib/mindee/image/image_utils.rb +165 -0
- data/lib/mindee/image.rb +6 -0
- data/lib/mindee/input/base_parameters.rb +149 -0
- data/lib/mindee/input/local_response.rb +80 -0
- data/lib/mindee/input/polling_options.rb +26 -0
- data/lib/mindee/input/sources/base64_input_source.rb +31 -0
- data/lib/mindee/input/sources/bytes_input_source.rb +21 -0
- data/lib/mindee/input/sources/file_input_source.rb +20 -0
- data/lib/mindee/input/sources/local_input_source.rb +216 -0
- data/lib/mindee/input/sources/path_input_source.rb +20 -0
- data/lib/mindee/input/sources/url_input_source.rb +130 -0
- data/lib/mindee/input/sources.rb +8 -0
- data/lib/mindee/input.rb +4 -0
- data/lib/mindee/logging/logger.rb +24 -0
- data/lib/mindee/logging.rb +3 -0
- data/lib/mindee/page_options.rb +24 -0
- data/lib/mindee/pdf/extracted_pdf.rb +70 -0
- data/lib/mindee/pdf/pdf_compressor.rb +121 -0
- data/lib/mindee/pdf/pdf_extractor.rb +121 -0
- data/lib/mindee/pdf/pdf_processor.rb +91 -0
- data/lib/mindee/pdf/pdf_tools.rb +201 -0
- data/lib/mindee/pdf.rb +7 -0
- data/lib/mindee/v1/client.rb +490 -0
- data/lib/mindee/v1/extraction/multi_receipts_extractor.rb +32 -0
- data/lib/mindee/v1/extraction.rb +3 -0
- data/lib/mindee/v1/http/.rubocop.yml +7 -0
- data/lib/mindee/v1/http/endpoint.rb +221 -0
- data/lib/mindee/v1/http/workflow_endpoint.rb +93 -0
- data/lib/mindee/v1/http.rb +4 -0
- data/lib/mindee/v1/parsing/common/api_request.rb +38 -0
- data/lib/mindee/v1/parsing/common/api_response.rb +63 -0
- data/lib/mindee/v1/parsing/common/document.rb +86 -0
- data/lib/mindee/v1/parsing/common/execution.rb +78 -0
- data/lib/mindee/v1/parsing/common/execution_file.rb +26 -0
- data/lib/mindee/v1/parsing/common/execution_priority.rb +38 -0
- data/lib/mindee/v1/parsing/common/extras/cropper_extra.rb +32 -0
- data/lib/mindee/v1/parsing/common/extras/extras.rb +62 -0
- data/lib/mindee/v1/parsing/common/extras/full_text_ocr_extra.rb +35 -0
- data/lib/mindee/v1/parsing/common/extras/rag_extra.rb +28 -0
- data/lib/mindee/v1/parsing/common/extras.rb +6 -0
- data/lib/mindee/v1/parsing/common/inference.rb +69 -0
- data/lib/mindee/v1/parsing/common/job.rb +48 -0
- data/lib/mindee/v1/parsing/common/ocr/mvision_v1.rb +52 -0
- data/lib/mindee/v1/parsing/common/ocr/ocr.rb +180 -0
- data/lib/mindee/v1/parsing/common/ocr.rb +3 -0
- data/lib/mindee/v1/parsing/common/orientation.rb +28 -0
- data/lib/mindee/v1/parsing/common/page.rb +49 -0
- data/lib/mindee/v1/parsing/common/prediction.rb +19 -0
- data/lib/mindee/v1/parsing/common/product.rb +26 -0
- data/lib/mindee/v1/parsing/common/workflow_response.rb +30 -0
- data/lib/mindee/v1/parsing/common.rb +15 -0
- data/lib/mindee/v1/parsing/standard/abstract_field.rb +74 -0
- data/lib/mindee/v1/parsing/standard/address_field.rb +51 -0
- data/lib/mindee/v1/parsing/standard/amount_field.rb +28 -0
- data/lib/mindee/v1/parsing/standard/base_field.rb +30 -0
- data/lib/mindee/v1/parsing/standard/boolean_field.rb +29 -0
- data/lib/mindee/v1/parsing/standard/classification_field.rb +18 -0
- data/lib/mindee/v1/parsing/standard/company_registration_field.rb +45 -0
- data/lib/mindee/v1/parsing/standard/date_field.rb +40 -0
- data/lib/mindee/v1/parsing/standard/feature_field.rb +26 -0
- data/lib/mindee/v1/parsing/standard/locale_field.rb +52 -0
- data/lib/mindee/v1/parsing/standard/payment_details_field.rb +44 -0
- data/lib/mindee/v1/parsing/standard/position_field.rb +61 -0
- data/lib/mindee/v1/parsing/standard/string_field.rb +26 -0
- data/lib/mindee/v1/parsing/standard/tax_field.rb +110 -0
- data/lib/mindee/v1/parsing/standard.rb +15 -0
- data/lib/mindee/v1/parsing/universal/universal_list_field.rb +60 -0
- data/lib/mindee/v1/parsing/universal/universal_object_field.rb +123 -0
- data/lib/mindee/v1/parsing/universal.rb +4 -0
- data/lib/mindee/v1/parsing.rb +5 -0
- data/lib/mindee/v1/product/.rubocop.yml +12 -0
- data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1.rb +47 -0
- data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rb +47 -0
- data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rb +38 -0
- data/lib/mindee/v1/product/cropper/cropper_v1.rb +47 -0
- data/lib/mindee/v1/product/cropper/cropper_v1_document.rb +15 -0
- data/lib/mindee/v1/product/cropper/cropper_v1_page.rb +55 -0
- data/lib/mindee/v1/product/financial_document/financial_document_v1.rb +47 -0
- data/lib/mindee/v1/product/financial_document/financial_document_v1_document.rb +329 -0
- data/lib/mindee/v1/product/financial_document/financial_document_v1_line_item.rb +124 -0
- data/lib/mindee/v1/product/financial_document/financial_document_v1_line_items.rb +64 -0
- data/lib/mindee/v1/product/financial_document/financial_document_v1_page.rb +38 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rb +49 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rb +49 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rb +40 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2.rb +49 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_bban.rb +63 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_document.rb +60 -0
- data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_page.rb +40 -0
- data/lib/mindee/v1/product/fr/bank_statement/bank_statement_v2.rb +49 -0
- data/lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_document.rb +169 -0
- data/lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_page.rb +40 -0
- data/lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_transaction.rb +78 -0
- data/lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_transactions.rb +56 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v1.rb +49 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v1_document.rb +106 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v1_page.rb +57 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v2.rb +49 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v2_document.rb +143 -0
- data/lib/mindee/v1/product/fr/id_card/id_card_v2_page.rb +65 -0
- data/lib/mindee/v1/product/international_id/international_id_v2.rb +47 -0
- data/lib/mindee/v1/product/international_id/international_id_v2_document.rb +164 -0
- data/lib/mindee/v1/product/international_id/international_id_v2_page.rb +38 -0
- data/lib/mindee/v1/product/invoice/invoice_v4.rb +47 -0
- data/lib/mindee/v1/product/invoice/invoice_v4_document.rb +300 -0
- data/lib/mindee/v1/product/invoice/invoice_v4_line_item.rb +124 -0
- data/lib/mindee/v1/product/invoice/invoice_v4_line_items.rb +64 -0
- data/lib/mindee/v1/product/invoice/invoice_v4_page.rb +38 -0
- data/lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1.rb +47 -0
- data/lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1_document.rb +66 -0
- data/lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rb +58 -0
- data/lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rb +50 -0
- data/lib/mindee/v1/product/invoice_splitter/invoice_splitter_v1_page.rb +38 -0
- data/lib/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1.rb +47 -0
- data/lib/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +38 -0
- data/lib/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +38 -0
- data/lib/mindee/v1/product/passport/passport_v1.rb +47 -0
- data/lib/mindee/v1/product/passport/passport_v1_document.rb +112 -0
- data/lib/mindee/v1/product/passport/passport_v1_page.rb +38 -0
- data/lib/mindee/v1/product/receipt/receipt_v5.rb +47 -0
- data/lib/mindee/v1/product/receipt/receipt_v5_document.rb +187 -0
- data/lib/mindee/v1/product/receipt/receipt_v5_line_item.rb +88 -0
- data/lib/mindee/v1/product/receipt/receipt_v5_line_items.rb +56 -0
- data/lib/mindee/v1/product/receipt/receipt_v5_page.rb +38 -0
- data/lib/mindee/v1/product/resume/resume_v1.rb +47 -0
- data/lib/mindee/v1/product/resume/resume_v1_certificate.rb +82 -0
- data/lib/mindee/v1/product/resume/resume_v1_certificates.rb +60 -0
- data/lib/mindee/v1/product/resume/resume_v1_document.rb +340 -0
- data/lib/mindee/v1/product/resume/resume_v1_education.rb +106 -0
- data/lib/mindee/v1/product/resume/resume_v1_educations.rb +66 -0
- data/lib/mindee/v1/product/resume/resume_v1_language.rb +66 -0
- data/lib/mindee/v1/product/resume/resume_v1_languages.rb +56 -0
- data/lib/mindee/v1/product/resume/resume_v1_page.rb +38 -0
- data/lib/mindee/v1/product/resume/resume_v1_professional_experience.rb +122 -0
- data/lib/mindee/v1/product/resume/resume_v1_professional_experiences.rb +70 -0
- data/lib/mindee/v1/product/resume/resume_v1_social_networks_url.rb +66 -0
- data/lib/mindee/v1/product/resume/resume_v1_social_networks_urls.rb +56 -0
- data/lib/mindee/v1/product/universal/universal.rb +48 -0
- data/lib/mindee/v1/product/universal/universal_document.rb +35 -0
- data/lib/mindee/v1/product/universal/universal_page.rb +54 -0
- data/lib/mindee/v1/product/universal/universal_prediction.rb +128 -0
- data/lib/mindee/v1/product.rb +18 -0
- data/lib/mindee/v1.rb +7 -0
- data/lib/mindee/v2/client.rb +132 -0
- data/lib/mindee/v2/file_operation/crop.rb +51 -0
- data/lib/mindee/v2/file_operation/crop_files.rb +25 -0
- data/lib/mindee/v2/file_operation/split.rb +37 -0
- data/lib/mindee/v2/file_operation/split_files.rb +25 -0
- data/lib/mindee/v2/file_operation.rb +6 -0
- data/lib/mindee/v2/http/.rubocop.yml +7 -0
- data/lib/mindee/v2/http/api_v2_settings.rb +65 -0
- data/lib/mindee/v2/http/mindee_api_v2.rb +230 -0
- data/lib/mindee/v2/http.rb +4 -0
- data/lib/mindee/v2/parsing/base_inference.rb +44 -0
- data/lib/mindee/v2/parsing/base_response.rb +15 -0
- data/lib/mindee/v2/parsing/common_response.rb +20 -0
- data/lib/mindee/v2/parsing/error_item.rb +21 -0
- data/lib/mindee/v2/parsing/error_response.rb +51 -0
- data/lib/mindee/v2/parsing/field/base_field.rb +63 -0
- data/lib/mindee/v2/parsing/field/field_confidence.rb +128 -0
- data/lib/mindee/v2/parsing/field/field_location.rb +33 -0
- data/lib/mindee/v2/parsing/field/inference_fields.rb +105 -0
- data/lib/mindee/v2/parsing/field/list_field.rb +79 -0
- data/lib/mindee/v2/parsing/field/object_field.rb +138 -0
- data/lib/mindee/v2/parsing/field/simple_field.rb +60 -0
- data/lib/mindee/v2/parsing/field.rb +9 -0
- data/lib/mindee/v2/parsing/inference_active_options.rb +67 -0
- data/lib/mindee/v2/parsing/inference_file.rb +38 -0
- data/lib/mindee/v2/parsing/inference_job.rb +25 -0
- data/lib/mindee/v2/parsing/inference_model.rb +30 -0
- data/lib/mindee/v2/parsing/job.rb +93 -0
- data/lib/mindee/v2/parsing/job_response.rb +30 -0
- data/lib/mindee/v2/parsing/job_webhook.rb +59 -0
- data/lib/mindee/v2/parsing/rag_metadata.rb +17 -0
- data/lib/mindee/v2/parsing/raw_text.rb +27 -0
- data/lib/mindee/v2/parsing/raw_text_page.rb +24 -0
- data/lib/mindee/v2/parsing/search/pagination_metadata.rb +44 -0
- data/lib/mindee/v2/parsing/search/search_model.rb +38 -0
- data/lib/mindee/v2/parsing/search/search_models.rb +34 -0
- data/lib/mindee/v2/parsing/search/search_response.rb +38 -0
- data/lib/mindee/v2/parsing/search.rb +6 -0
- data/lib/mindee/v2/parsing.rb +16 -0
- data/lib/mindee/v2/product/base_product.rb +28 -0
- data/lib/mindee/v2/product/classification/classification.rb +20 -0
- data/lib/mindee/v2/product/classification/classification_classifier.rb +25 -0
- data/lib/mindee/v2/product/classification/classification_inference.rb +35 -0
- data/lib/mindee/v2/product/classification/classification_response.rb +32 -0
- data/lib/mindee/v2/product/classification/classification_result.rb +27 -0
- data/lib/mindee/v2/product/classification/params/classification_parameters.rb +47 -0
- data/lib/mindee/v2/product/crop/crop.rb +20 -0
- data/lib/mindee/v2/product/crop/crop_inference.rb +34 -0
- data/lib/mindee/v2/product/crop/crop_item.rb +39 -0
- data/lib/mindee/v2/product/crop/crop_response.rb +40 -0
- data/lib/mindee/v2/product/crop/crop_result.rb +34 -0
- data/lib/mindee/v2/product/crop/params/crop_parameters.rb +47 -0
- data/lib/mindee/v2/product/extraction/extraction.rb +21 -0
- data/lib/mindee/v2/product/extraction/extraction_inference.rb +40 -0
- data/lib/mindee/v2/product/extraction/extraction_response.rb +32 -0
- data/lib/mindee/v2/product/extraction/extraction_result.rb +44 -0
- data/lib/mindee/v2/product/extraction/params/data_schema.rb +51 -0
- data/lib/mindee/v2/product/extraction/params/data_schema_field.rb +69 -0
- data/lib/mindee/v2/product/extraction/params/data_schema_replace.rb +39 -0
- data/lib/mindee/v2/product/extraction/params/extraction_parameters.rb +125 -0
- data/lib/mindee/v2/product/ocr/ocr.rb +20 -0
- data/lib/mindee/v2/product/ocr/ocr_inference.rb +34 -0
- data/lib/mindee/v2/product/ocr/ocr_page.rb +33 -0
- data/lib/mindee/v2/product/ocr/ocr_response.rb +32 -0
- data/lib/mindee/v2/product/ocr/ocr_result.rb +34 -0
- data/lib/mindee/v2/product/ocr/ocr_word.rb +29 -0
- data/lib/mindee/v2/product/ocr/params/ocr_parameters.rb +47 -0
- data/lib/mindee/v2/product/split/params/split_parameters.rb +48 -0
- data/lib/mindee/v2/product/split/split.rb +19 -0
- data/lib/mindee/v2/product/split/split_inference.rb +34 -0
- data/lib/mindee/v2/product/split/split_range.rb +38 -0
- data/lib/mindee/v2/product/split/split_response.rb +40 -0
- data/lib/mindee/v2/product/split/split_result.rb +34 -0
- data/lib/mindee/v2/product.rb +7 -0
- data/lib/mindee/v2.rb +7 -0
- data/lib/mindee/version.rb +26 -0
- data/lib/mindee.rb +135 -0
- data/mindee-lite.gemspec +36 -0
- data/mindee.gemspec +44 -0
- data/sig/custom/marcel.rbs +3 -0
- data/sig/custom/mini_magick.rbs +31 -0
- data/sig/custom/net_http.rbs +43 -0
- data/sig/custom/origami.rbs +59 -0
- data/sig/mindee/dependency.rbs +13 -0
- data/sig/mindee/error/mindee_error.rbs +13 -0
- data/sig/mindee/error/mindee_http_error.rbs +17 -0
- data/sig/mindee/error/mindee_http_error_v2.rbs +15 -0
- data/sig/mindee/error/mindee_http_unknown_error_v2.rbs +9 -0
- data/sig/mindee/error/mindee_input_error.rbs +18 -0
- data/sig/mindee/geometry/min_max.rbs +11 -0
- data/sig/mindee/geometry/point.rbs +14 -0
- data/sig/mindee/geometry/polygon.rbs +12 -0
- data/sig/mindee/geometry/quadrilateral.rbs +15 -0
- data/sig/mindee/geometry/utils.rbs +13 -0
- data/sig/mindee/http/http_error_handler.rbs +15 -0
- data/sig/mindee/http/response_validation.rbs +11 -0
- data/sig/mindee/image/extracted_image.rbs +21 -0
- data/sig/mindee/image/image_compressor.rbs +8 -0
- data/sig/mindee/image/image_extractor.rbs +13 -0
- data/sig/mindee/image/image_utils.rbs +19 -0
- data/sig/mindee/input/base_parameters.rbs +35 -0
- data/sig/mindee/input/local_response.rbs +14 -0
- data/sig/mindee/input/polling_options.rbs +12 -0
- data/sig/mindee/input/sources/base64_input_source.rbs +11 -0
- data/sig/mindee/input/sources/bytes_input_source.rbs +10 -0
- data/sig/mindee/input/sources/file_input_source.rbs +10 -0
- data/sig/mindee/input/sources/local_input_source.rbs +30 -0
- data/sig/mindee/input/sources/path_input_source.rbs +10 -0
- data/sig/mindee/input/sources/url_input_source.rbs +20 -0
- data/sig/mindee/logging/logger.rbs +11 -0
- data/sig/mindee/page_options.rbs +11 -0
- data/sig/mindee/pdf/extracted_pdf.rbs +17 -0
- data/sig/mindee/pdf/pdf_compressor.rbs +15 -0
- data/sig/mindee/pdf/pdf_extractor.rbs +19 -0
- data/sig/mindee/pdf/pdf_processor.rbs +12 -0
- data/sig/mindee/pdf/pdf_tools.rbs +31 -0
- data/sig/mindee/v1/client.rbs +84 -0
- data/sig/mindee/v1/extraction/multi_receipts_extractor.rbs +8 -0
- data/sig/mindee/v1/http/endpoint.rbs +41 -0
- data/sig/mindee/v1/http/workflow_endpoint.rbs +22 -0
- data/sig/mindee/v1/parsing/common/api_request.rbs +22 -0
- data/sig/mindee/v1/parsing/common/api_response.rbs +31 -0
- data/sig/mindee/v1/parsing/common/document.rbs +32 -0
- data/sig/mindee/v1/parsing/common/execution.rbs +26 -0
- data/sig/mindee/v1/parsing/common/execution_file.rbs +16 -0
- data/sig/mindee/v1/parsing/common/execution_priority.rbs +16 -0
- data/sig/mindee/v1/parsing/common/extras/cropper_extra.rbs +18 -0
- data/sig/mindee/v1/parsing/common/extras/extras.rbs +24 -0
- data/sig/mindee/v1/parsing/common/extras/full_text_ocr_extra.rbs +22 -0
- data/sig/mindee/v1/parsing/common/extras/rag_extra.rbs +19 -0
- data/sig/mindee/v1/parsing/common/inference.rbs +31 -0
- data/sig/mindee/v1/parsing/common/job.rbs +24 -0
- data/sig/mindee/v1/parsing/common/ocr/mvision_v1.rbs +20 -0
- data/sig/mindee/v1/parsing/common/ocr/ocr.rbs +56 -0
- data/sig/mindee/v1/parsing/common/orientation.rbs +15 -0
- data/sig/mindee/v1/parsing/common/page.rbs +19 -0
- data/sig/mindee/v1/parsing/common/prediction.rbs +14 -0
- data/sig/mindee/v1/parsing/common/product.rbs +16 -0
- data/sig/mindee/v1/parsing/common/workflow_response.rbs +22 -0
- data/sig/mindee/v1/parsing/standard/abstract_field.rbs +30 -0
- data/sig/mindee/v1/parsing/standard/address_field.rbs +28 -0
- data/sig/mindee/v1/parsing/standard/amount_field.rbs +16 -0
- data/sig/mindee/v1/parsing/standard/base_field.rbs +16 -0
- data/sig/mindee/v1/parsing/standard/boolean_field.rbs +16 -0
- data/sig/mindee/v1/parsing/standard/classification_field.rbs +12 -0
- data/sig/mindee/v1/parsing/standard/company_registration_field.rbs +20 -0
- data/sig/mindee/v1/parsing/standard/date_field.rbs +20 -0
- data/sig/mindee/v1/parsing/standard/feature_field.rbs +12 -0
- data/sig/mindee/v1/parsing/standard/locale_field.rbs +24 -0
- data/sig/mindee/v1/parsing/standard/payment_details_field.rbs +19 -0
- data/sig/mindee/v1/parsing/standard/position_field.rbs +26 -0
- data/sig/mindee/v1/parsing/standard/string_field.rbs +16 -0
- data/sig/mindee/v1/parsing/standard/tax_field.rbs +33 -0
- data/sig/mindee/v1/parsing/universal/universal_list_field.rbs +21 -0
- data/sig/mindee/v1/parsing/universal/universal_object_field.rbs +38 -0
- data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1.rbs +13 -0
- data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rbs +16 -0
- data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rbs +17 -0
- data/sig/mindee/v1/product/cropper/cropper_v1.rbs +13 -0
- data/sig/mindee/v1/product/cropper/cropper_v1_document.rbs +14 -0
- data/sig/mindee/v1/product/cropper/cropper_v1_page.rbs +19 -0
- data/sig/mindee/v1/product/financial_document/financial_document_v1.rbs +13 -0
- data/sig/mindee/v1/product/financial_document/financial_document_v1_document.rbs +49 -0
- data/sig/mindee/v1/product/financial_document/financial_document_v1_line_item.rbs +35 -0
- data/sig/mindee/v1/product/financial_document/financial_document_v1_line_items.rbs +15 -0
- data/sig/mindee/v1/product/financial_document/financial_document_v1_page.rbs +17 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rbs +15 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rbs +19 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rbs +19 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2.rbs +15 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_bban.rbs +25 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_document.rbs +20 -0
- data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_page.rbs +19 -0
- data/sig/mindee/v1/product/fr/bank_statement/bank_statement_v2.rbs +15 -0
- data/sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_document.rbs +31 -0
- data/sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_page.rbs +19 -0
- data/sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_transaction.rbs +27 -0
- data/sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_transactions.rbs +17 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v1.rbs +15 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v1_document.rbs +26 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v1_page.rbs +20 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v2.rbs +15 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v2_document.rbs +31 -0
- data/sig/mindee/v1/product/fr/id_card/id_card_v2_page.rbs +21 -0
- data/sig/mindee/v1/product/international_id/international_id_v2.rbs +13 -0
- data/sig/mindee/v1/product/international_id/international_id_v2_document.rbs +31 -0
- data/sig/mindee/v1/product/international_id/international_id_v2_page.rbs +17 -0
- data/sig/mindee/v1/product/invoice/invoice_v4.rbs +13 -0
- data/sig/mindee/v1/product/invoice/invoice_v4_document.rbs +45 -0
- data/sig/mindee/v1/product/invoice/invoice_v4_line_item.rbs +35 -0
- data/sig/mindee/v1/product/invoice/invoice_v4_line_items.rbs +15 -0
- data/sig/mindee/v1/product/invoice/invoice_v4_page.rbs +17 -0
- data/sig/mindee/v1/product/invoice_splitter/invoice_splitter_v1.rbs +13 -0
- data/sig/mindee/v1/product/invoice_splitter/invoice_splitter_v1_document.rbs +17 -0
- data/sig/mindee/v1/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rbs +21 -0
- data/sig/mindee/v1/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rbs +15 -0
- data/sig/mindee/v1/product/invoice_splitter/invoice_splitter_v1_page.rbs +17 -0
- data/sig/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1.rbs +14 -0
- data/sig/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1_document.rbs +15 -0
- data/sig/mindee/v1/product/multi_receipts_detector/multi_receipts_detector_v1_page.rbs +17 -0
- data/sig/mindee/v1/product/passport/passport_v1.rbs +13 -0
- data/sig/mindee/v1/product/passport/passport_v1_document.rbs +25 -0
- data/sig/mindee/v1/product/passport/passport_v1_page.rbs +17 -0
- data/sig/mindee/v1/product/receipt/receipt_v5.rbs +13 -0
- data/sig/mindee/v1/product/receipt/receipt_v5_document.rbs +33 -0
- data/sig/mindee/v1/product/receipt/receipt_v5_line_item.rbs +27 -0
- data/sig/mindee/v1/product/receipt/receipt_v5_line_items.rbs +15 -0
- data/sig/mindee/v1/product/receipt/receipt_v5_page.rbs +17 -0
- data/sig/mindee/v1/product/resume/resume_v1.rbs +13 -0
- data/sig/mindee/v1/product/resume/resume_v1_certificate.rbs +27 -0
- data/sig/mindee/v1/product/resume/resume_v1_certificates.rbs +17 -0
- data/sig/mindee/v1/product/resume/resume_v1_document.rbs +69 -0
- data/sig/mindee/v1/product/resume/resume_v1_education.rbs +33 -0
- data/sig/mindee/v1/product/resume/resume_v1_educations.rbs +17 -0
- data/sig/mindee/v1/product/resume/resume_v1_language.rbs +23 -0
- data/sig/mindee/v1/product/resume/resume_v1_languages.rbs +17 -0
- data/sig/mindee/v1/product/resume/resume_v1_page.rbs +19 -0
- data/sig/mindee/v1/product/resume/resume_v1_professional_experience.rbs +37 -0
- data/sig/mindee/v1/product/resume/resume_v1_professional_experiences.rbs +17 -0
- data/sig/mindee/v1/product/resume/resume_v1_social_networks_url.rbs +23 -0
- data/sig/mindee/v1/product/resume/resume_v1_social_networks_urls.rbs +17 -0
- data/sig/mindee/v1/product/universal/universal.rbs +16 -0
- data/sig/mindee/v1/product/universal/universal_document.rbs +12 -0
- data/sig/mindee/v1/product/universal/universal_page.rbs +18 -0
- data/sig/mindee/v1/product/universal/universal_prediction.rbs +30 -0
- data/sig/mindee/v2/client.rbs +29 -0
- data/sig/mindee/v2/file_operation/crop.rbs +10 -0
- data/sig/mindee/v2/file_operation/crop_files.rbs +9 -0
- data/sig/mindee/v2/file_operation/split.rbs +11 -0
- data/sig/mindee/v2/file_operation/split_files.rbs +9 -0
- data/sig/mindee/v2/http/api_v2_settings.rbs +27 -0
- data/sig/mindee/v2/http/mindee_api_v2.rbs +52 -0
- data/sig/mindee/v2/parsing/base_inference.rbs +18 -0
- data/sig/mindee/v2/parsing/base_response.rbs +11 -0
- data/sig/mindee/v2/parsing/common_response.rbs +12 -0
- data/sig/mindee/v2/parsing/error_item.rbs +13 -0
- data/sig/mindee/v2/parsing/error_response.rbs +20 -0
- data/sig/mindee/v2/parsing/field/base_field.rbs +17 -0
- data/sig/mindee/v2/parsing/field/field_confidence.rbs +30 -0
- data/sig/mindee/v2/parsing/field/field_location.rbs +16 -0
- data/sig/mindee/v2/parsing/field/inference_fields.rbs +20 -0
- data/sig/mindee/v2/parsing/field/list_field.rbs +23 -0
- data/sig/mindee/v2/parsing/field/object_field.rbs +27 -0
- data/sig/mindee/v2/parsing/field/simple_field.rbs +16 -0
- data/sig/mindee/v2/parsing/inference_active_options.rbs +26 -0
- data/sig/mindee/v2/parsing/inference_file.rbs +17 -0
- data/sig/mindee/v2/parsing/inference_job.rbs +13 -0
- data/sig/mindee/v2/parsing/inference_model.rbs +12 -0
- data/sig/mindee/v2/parsing/job.rbs +24 -0
- data/sig/mindee/v2/parsing/job_response.rbs +14 -0
- data/sig/mindee/v2/parsing/job_webhook.rbs +19 -0
- data/sig/mindee/v2/parsing/rag_metadata.rbs +13 -0
- data/sig/mindee/v2/parsing/raw_text.rbs +12 -0
- data/sig/mindee/v2/parsing/raw_text_page.rbs +11 -0
- data/sig/mindee/v2/parsing/search/pagination_metadata.rbs +20 -0
- data/sig/mindee/v2/parsing/search/search_model.rbs +19 -0
- data/sig/mindee/v2/parsing/search/search_response.rbs +17 -0
- data/sig/mindee/v2/parsing/search_models.rbs +14 -0
- data/sig/mindee/v2/product/base_product.rbs +19 -0
- data/sig/mindee/v2/product/classification/classification.rbs +10 -0
- data/sig/mindee/v2/product/classification/classification_classifier.rbs +15 -0
- data/sig/mindee/v2/product/classification/classification_inference.rbs +15 -0
- data/sig/mindee/v2/product/classification/classification_response.rbs +23 -0
- data/sig/mindee/v2/product/classification/classification_result.rbs +15 -0
- data/sig/mindee/v2/product/classification/params/classification_parameters/classification_parameters.rbs +23 -0
- data/sig/mindee/v2/product/crop/crop.rbs +10 -0
- data/sig/mindee/v2/product/crop/crop_inference.rbs +14 -0
- data/sig/mindee/v2/product/crop/crop_item.rbs +18 -0
- data/sig/mindee/v2/product/crop/crop_response.rbs +25 -0
- data/sig/mindee/v2/product/crop/crop_result.rbs +14 -0
- data/sig/mindee/v2/product/crop/params/crop_parameters/crop_parameters.rbs +23 -0
- data/sig/mindee/v2/product/extraction/extraction.rbs +15 -0
- data/sig/mindee/v2/product/extraction/extraction_inference.rbs +19 -0
- data/sig/mindee/v2/product/extraction/extraction_response.rbs +24 -0
- data/sig/mindee/v2/product/extraction/extraction_result.rbs +18 -0
- data/sig/mindee/v2/product/extraction/params/data_schema.rbs +21 -0
- data/sig/mindee/v2/product/extraction/params/data_schema_field.rbs +29 -0
- data/sig/mindee/v2/product/extraction/params/data_schema_replace.rbs +21 -0
- data/sig/mindee/v2/product/extraction/params/extraction_parameters.rbs +38 -0
- data/sig/mindee/v2/product/ocr/ocr.rbs +10 -0
- data/sig/mindee/v2/product/ocr/ocr_inference.rbs +14 -0
- data/sig/mindee/v2/product/ocr/ocr_page.rbs +15 -0
- data/sig/mindee/v2/product/ocr/ocr_response.rbs +23 -0
- data/sig/mindee/v2/product/ocr/ocr_result.rbs +14 -0
- data/sig/mindee/v2/product/ocr/ocr_word.rbs +15 -0
- data/sig/mindee/v2/product/ocr/params/ocr_parameters/ocr_parameters.rbs +24 -0
- data/sig/mindee/v2/product/split/params/split_parameters/split_parameters.rbs +23 -0
- data/sig/mindee/v2/product/split/split.rbs +10 -0
- data/sig/mindee/v2/product/split/split_inference.rbs +14 -0
- data/sig/mindee/v2/product/split/split_range.rbs +18 -0
- data/sig/mindee/v2/product/split/split_response.rbs +25 -0
- data/sig/mindee/v2/product/split/split_result.rbs +14 -0
- data/sig/mindee/version.rbs +6 -0
- data/sig/mindee.rbs +62 -0
- metadata +600 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../../input/base_parameters'
|
|
4
|
+
require_relative 'data_schema'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
module Extraction
|
|
10
|
+
module Params
|
|
11
|
+
# Parameters accepted by the extraction v2 endpoint.
|
|
12
|
+
class ExtractionParameters < Mindee::Input::BaseParameters
|
|
13
|
+
# @return [Boolean, nil] Enhance extraction accuracy with Retrieval-Augmented Generation.
|
|
14
|
+
attr_reader :rag
|
|
15
|
+
|
|
16
|
+
# @return [Boolean, nil] Extract the full text content from the document as strings,
|
|
17
|
+
# and fill the raw_text` attribute.
|
|
18
|
+
attr_reader :raw_text
|
|
19
|
+
|
|
20
|
+
# @return [Boolean, nil] Calculate bounding box polygons for all fields,
|
|
21
|
+
# and fill their `locations` attribute.
|
|
22
|
+
attr_reader :polygon
|
|
23
|
+
|
|
24
|
+
# @return [Boolean, nil] Boost the precision and accuracy of all extractions.
|
|
25
|
+
# Calculate confidence scores for all fields, and fill their confidence attribute.
|
|
26
|
+
attr_reader :confidence
|
|
27
|
+
|
|
28
|
+
# @return [String, nil] Additional text context used by the model during inference.
|
|
29
|
+
# Not recommended, for specific use only.
|
|
30
|
+
attr_reader :text_context
|
|
31
|
+
|
|
32
|
+
# @return [DataSchemaField]
|
|
33
|
+
attr_reader :data_schema
|
|
34
|
+
|
|
35
|
+
# @return [String] Slug for the endpoint.
|
|
36
|
+
def self.slug
|
|
37
|
+
'extraction'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# rubocop:disable Metrics/ParameterLists
|
|
41
|
+
# @param [String] model_id ID of the model
|
|
42
|
+
# @param [Boolean, nil] rag Whether to enable RAG.
|
|
43
|
+
# @param [Boolean, nil] raw_text Whether to enable rax text.
|
|
44
|
+
# @param [Boolean, nil] polygon Whether to enable polygons.
|
|
45
|
+
# @param [Boolean, nil] confidence Whether to enable confidence scores.
|
|
46
|
+
# @param [String, nil] file_alias File alias, if applicable.
|
|
47
|
+
# @param [Array<String>, nil] webhook_ids
|
|
48
|
+
# @param [String, nil] text_context
|
|
49
|
+
# @param [Hash, nil] polling_options
|
|
50
|
+
# @param [Boolean, nil] close_file
|
|
51
|
+
# @param [DataSchemaField, String, Hash nil] data_schema
|
|
52
|
+
def initialize(
|
|
53
|
+
model_id,
|
|
54
|
+
rag: nil,
|
|
55
|
+
raw_text: nil,
|
|
56
|
+
polygon: nil,
|
|
57
|
+
confidence: nil,
|
|
58
|
+
file_alias: nil,
|
|
59
|
+
webhook_ids: nil,
|
|
60
|
+
text_context: nil,
|
|
61
|
+
polling_options: nil,
|
|
62
|
+
close_file: true,
|
|
63
|
+
data_schema: nil
|
|
64
|
+
)
|
|
65
|
+
super(
|
|
66
|
+
model_id,
|
|
67
|
+
file_alias: file_alias,
|
|
68
|
+
webhook_ids: webhook_ids,
|
|
69
|
+
polling_options: polling_options,
|
|
70
|
+
close_file: close_file
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
@rag = rag
|
|
74
|
+
@raw_text = raw_text
|
|
75
|
+
@polygon = polygon
|
|
76
|
+
@confidence = confidence
|
|
77
|
+
@text_context = text_context
|
|
78
|
+
@data_schema = DataSchema.new(data_schema) unless data_schema.nil?
|
|
79
|
+
# rubocop:enable Metrics/ParameterLists
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Appends inference-specific form data to the provided array.
|
|
83
|
+
# @param [Array] form_data Array of form fields
|
|
84
|
+
# @return [Array]
|
|
85
|
+
def append_form_data(form_data)
|
|
86
|
+
new_form_data = super
|
|
87
|
+
|
|
88
|
+
new_form_data.push(['rag', @rag.to_s]) unless @rag.nil?
|
|
89
|
+
new_form_data.push(['raw_text', @raw_text.to_s]) unless @raw_text.nil?
|
|
90
|
+
new_form_data.push(['polygon', @polygon.to_s]) unless @polygon.nil?
|
|
91
|
+
new_form_data.push(['confidence', @confidence.to_s]) unless @confidence.nil?
|
|
92
|
+
new_form_data.push(['text_context', @text_context]) if @text_context
|
|
93
|
+
new_form_data.push(['data_schema', @data_schema.to_s]) if @data_schema
|
|
94
|
+
|
|
95
|
+
new_form_data
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Loads a prediction from a Hash.
|
|
99
|
+
# @param [Hash] params Parameters to provide as a hash.
|
|
100
|
+
# @return [ExtractionParameters]
|
|
101
|
+
def self.from_hash(params: {})
|
|
102
|
+
rag = params.fetch(:rag, nil)
|
|
103
|
+
raw_text = params.fetch(:raw_text, nil)
|
|
104
|
+
polygon = params.fetch(:polygon, nil)
|
|
105
|
+
confidence = params.fetch(:confidence, nil)
|
|
106
|
+
base_params = load_from_hash(params: params)
|
|
107
|
+
new_params = base_params.merge(rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence)
|
|
108
|
+
model_id = new_params.fetch(:model_id)
|
|
109
|
+
|
|
110
|
+
ExtractionParameters.new(
|
|
111
|
+
model_id, rag: rag,
|
|
112
|
+
raw_text: raw_text,
|
|
113
|
+
polygon: polygon,
|
|
114
|
+
confidence: confidence,
|
|
115
|
+
file_alias: params.fetch(:file_alias, nil),
|
|
116
|
+
webhook_ids: params.fetch(:webhook_ids, nil),
|
|
117
|
+
close_file: params.fetch(:close_file, true)
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'ocr_response'
|
|
4
|
+
require_relative 'params/ocr_parameters'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
# OCR module.
|
|
10
|
+
module OCR
|
|
11
|
+
# OCR product.
|
|
12
|
+
class OCR < BaseProduct
|
|
13
|
+
@slug = 'ocr'
|
|
14
|
+
@params_type = Mindee::V2::Product::OCR::Params::OCRParameters
|
|
15
|
+
@response_type = Mindee::V2::Product::OCR::OCRResponse
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'ocr_result'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module OCR
|
|
9
|
+
# The inference result for an OCR utility request.
|
|
10
|
+
class OCRInference < Mindee::V2::Parsing::BaseInference
|
|
11
|
+
# @return [OCRResult] Parsed inference payload.
|
|
12
|
+
attr_reader :result
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@result = OCRResult.new(server_response['result'])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# String representation.
|
|
22
|
+
# @return [String]
|
|
23
|
+
def to_s
|
|
24
|
+
[
|
|
25
|
+
super,
|
|
26
|
+
@result.to_s,
|
|
27
|
+
'',
|
|
28
|
+
].join("\n")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'ocr_word'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module OCR
|
|
9
|
+
# OCR result for a single page.
|
|
10
|
+
class OCRPage
|
|
11
|
+
# @return [Array<OCRWord>] List of words extracted from the document page.
|
|
12
|
+
attr_reader :words
|
|
13
|
+
# @return [String] Full text content extracted from the document page.
|
|
14
|
+
attr_reader :content
|
|
15
|
+
|
|
16
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
17
|
+
def initialize(server_response)
|
|
18
|
+
@words = server_response['words'].map { |word| OCRWord.new(word) }
|
|
19
|
+
@content = server_response['content']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# String representation.
|
|
23
|
+
# @return [String]
|
|
24
|
+
def to_s
|
|
25
|
+
ocr_words = "\n"
|
|
26
|
+
ocr_words += @words.join("\n\n") if @words&.any?
|
|
27
|
+
"OCR Words\n======#{ocr_words}\n\n:Content: #{@content}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing/base_response'
|
|
4
|
+
require_relative 'params/ocr_parameters'
|
|
5
|
+
require_relative 'ocr_inference'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module V2
|
|
9
|
+
module Product
|
|
10
|
+
module OCR
|
|
11
|
+
# HTTP response wrapper that embeds a V2 Inference.
|
|
12
|
+
class OCRResponse < Mindee::V2::Parsing::BaseResponse
|
|
13
|
+
# @return [OCRInference] Parsed inference payload.
|
|
14
|
+
attr_reader :inference
|
|
15
|
+
|
|
16
|
+
# @param server_response [Hash] Hash parsed from the API JSON response.
|
|
17
|
+
def initialize(server_response)
|
|
18
|
+
super
|
|
19
|
+
|
|
20
|
+
@inference = OCRInference.new(server_response['inference'])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# String representation.
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
@inference.to_s
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'ocr_page'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module OCR
|
|
9
|
+
# Result of a ocr utility inference.
|
|
10
|
+
class OCRResult
|
|
11
|
+
# @return [Array<OCRPage>] List of OCR results for each page in the document.
|
|
12
|
+
attr_reader :pages
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@pages = if server_response.key?('pages')
|
|
17
|
+
server_response['pages'].map do |pages|
|
|
18
|
+
OCRPage.new(pages)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# String representation.
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
pages_str = @pages.join("\n")
|
|
27
|
+
|
|
28
|
+
"Pages\n======\n#{pages_str}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module OCR
|
|
7
|
+
# OCR result for a single word extracted from the document page.
|
|
8
|
+
class OCRWord
|
|
9
|
+
# @return [String] Text content of the word.
|
|
10
|
+
attr_reader :content
|
|
11
|
+
# @return [Mindee::Geometry::Polygon] Position information as a list of points in clockwise order.
|
|
12
|
+
attr_reader :polygon
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@content = server_response['content']
|
|
17
|
+
@polygon = Mindee::Geometry::Polygon.new(server_response['polygon'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# String representation.
|
|
21
|
+
# @return [String]
|
|
22
|
+
def to_s
|
|
23
|
+
@content
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module OCR
|
|
7
|
+
# OCR Parameters.
|
|
8
|
+
module Params
|
|
9
|
+
# Parameters accepted by the ocr utility v2 endpoint.
|
|
10
|
+
class OCRParameters < Mindee::Input::BaseParameters
|
|
11
|
+
# @return [String] Slug for the endpoint.
|
|
12
|
+
def self.slug
|
|
13
|
+
'ocr'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @param [String] model_id ID of the model
|
|
17
|
+
# @param [String, nil] file_alias File alias, if applicable.
|
|
18
|
+
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
19
|
+
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
20
|
+
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
21
|
+
def initialize(
|
|
22
|
+
model_id,
|
|
23
|
+
file_alias: nil,
|
|
24
|
+
webhook_ids: nil,
|
|
25
|
+
polling_options: nil,
|
|
26
|
+
close_file: true
|
|
27
|
+
)
|
|
28
|
+
super
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Loads the parameters from a Hash.
|
|
32
|
+
# @param [Hash] params Parameters to provide as a hash.
|
|
33
|
+
# @return [OCRParameters]
|
|
34
|
+
def self.from_hash(params: {})
|
|
35
|
+
OCRParameters.new(
|
|
36
|
+
params.fetch(:model_id),
|
|
37
|
+
file_alias: params.fetch(:file_alias, nil),
|
|
38
|
+
webhook_ids: params.fetch(:webhook_ids, nil),
|
|
39
|
+
close_file: params.fetch(:close_file, true)
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
# Split module.
|
|
7
|
+
module Split
|
|
8
|
+
# Split parameters.
|
|
9
|
+
module Params
|
|
10
|
+
# Parameters accepted by the split utility v2 endpoint.
|
|
11
|
+
class SplitParameters < Mindee::Input::BaseParameters
|
|
12
|
+
# @return [String] Slug for the endpoint.
|
|
13
|
+
def self.slug
|
|
14
|
+
'split'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @param [String] model_id ID of the model
|
|
18
|
+
# @param [String, nil] file_alias File alias, if applicable.
|
|
19
|
+
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
20
|
+
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
21
|
+
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
22
|
+
def initialize(
|
|
23
|
+
model_id,
|
|
24
|
+
file_alias: nil,
|
|
25
|
+
webhook_ids: nil,
|
|
26
|
+
polling_options: nil,
|
|
27
|
+
close_file: true
|
|
28
|
+
)
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Loads the parameters from a Hash.
|
|
33
|
+
# @param [Hash] params Parameters to provide as a hash.
|
|
34
|
+
# @return [SplitParameters]
|
|
35
|
+
def self.from_hash(params: {})
|
|
36
|
+
SplitParameters.new(
|
|
37
|
+
params.fetch(:model_id),
|
|
38
|
+
file_alias: params.fetch(:file_alias, nil),
|
|
39
|
+
webhook_ids: params.fetch(:webhook_ids, nil),
|
|
40
|
+
close_file: params.fetch(:close_file, true)
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'split_response'
|
|
4
|
+
require_relative 'params/split_parameters'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
module Split
|
|
10
|
+
# Split product.
|
|
11
|
+
class Split < BaseProduct
|
|
12
|
+
@slug = 'split'
|
|
13
|
+
@params_type = Mindee::V2::Product::Split::Params::SplitParameters
|
|
14
|
+
@response_type = Mindee::V2::Product::Split::SplitResponse
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'split_result'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Split
|
|
9
|
+
# Split inference result.
|
|
10
|
+
class SplitInference < Mindee::V2::Parsing::BaseInference
|
|
11
|
+
# @return [SplitResult] Result of a split inference.
|
|
12
|
+
attr_reader :result
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@result = SplitResult.new(server_response['result'])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# String representation.
|
|
22
|
+
# @return [String]
|
|
23
|
+
def to_s
|
|
24
|
+
[
|
|
25
|
+
super,
|
|
26
|
+
@result.to_s,
|
|
27
|
+
'',
|
|
28
|
+
].join("\n")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module Split
|
|
7
|
+
# Split inference result.
|
|
8
|
+
class SplitRange
|
|
9
|
+
# @return [Array<Integer>] 0-based page indexes, where the first integer indicates the start page and the
|
|
10
|
+
# second integer indicates the end page.
|
|
11
|
+
attr_reader :page_range
|
|
12
|
+
# @return [String] The document type, as identified on given classification values.
|
|
13
|
+
attr_reader :document_type
|
|
14
|
+
|
|
15
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
16
|
+
def initialize(server_response)
|
|
17
|
+
@page_range = server_response['page_range']
|
|
18
|
+
@document_type = server_response['document_type']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# String representation.
|
|
22
|
+
# @return [String]
|
|
23
|
+
def to_s
|
|
24
|
+
"* :Page Range: #{@page_range}\n :Document Type: #{@document_type}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Apply the split range inference to a file and return a single extracted PDF.
|
|
28
|
+
#
|
|
29
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
30
|
+
# @return [PDF::ExtractedPDF]
|
|
31
|
+
def extract_from_file(input_source)
|
|
32
|
+
FileOperation::Split.extract_single_split(input_source, @page_range)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing/base_response'
|
|
4
|
+
require_relative 'params/split_parameters'
|
|
5
|
+
require_relative 'split_inference'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module V2
|
|
9
|
+
module Product
|
|
10
|
+
module Split
|
|
11
|
+
# HTTP response wrapper that embeds a V2 Inference.
|
|
12
|
+
class SplitResponse < Mindee::V2::Parsing::BaseResponse
|
|
13
|
+
# @return [SplitInference] Parsed inference payload.
|
|
14
|
+
attr_reader :inference
|
|
15
|
+
|
|
16
|
+
# @param server_response [Hash] Hash parsed from the API JSON response.
|
|
17
|
+
def initialize(server_response)
|
|
18
|
+
super
|
|
19
|
+
|
|
20
|
+
@inference = SplitInference.new(server_response['inference'])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# String representation.
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
@inference.to_s
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Extracts the crops from the input source.
|
|
30
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Path to the file or a File object.
|
|
31
|
+
# @return [FileOperation::SplitFiles]
|
|
32
|
+
def extract_from_file(input_source)
|
|
33
|
+
splits = @inference.result.splits.map(&:page_range)
|
|
34
|
+
FileOperation::Split.extract_splits(input_source, splits)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'split_range'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Split
|
|
9
|
+
# Result of a split utility inference.
|
|
10
|
+
class SplitResult
|
|
11
|
+
# @return [Array<SplitRange>] List of results of splitped document regions.
|
|
12
|
+
attr_reader :splits
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@splits = if server_response.key?('splits')
|
|
17
|
+
server_response['splits'].map do |split|
|
|
18
|
+
SplitRange.new(split)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# String representation.
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
splits_str = @splits.join("\n")
|
|
27
|
+
|
|
28
|
+
"Splits\n======\n#{splits_str}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/mindee/v2.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Mindee
|
|
4
|
+
module Mindee
|
|
5
|
+
# Current version.
|
|
6
|
+
VERSION = '5.0.0.beta1'
|
|
7
|
+
|
|
8
|
+
# Finds and return the current platform.
|
|
9
|
+
# @return [Symbol, Hash[String | Symbol, Regexp], Nil?]
|
|
10
|
+
def self.find_platform
|
|
11
|
+
host = RbConfig::CONFIG['host_os']
|
|
12
|
+
platforms = {
|
|
13
|
+
linux: %r{linux|cygwin},
|
|
14
|
+
windows: %r{mswin|mingw|bccwin|wince|emx|win32},
|
|
15
|
+
macos: %r{mac|darwin},
|
|
16
|
+
bsd: %r{bsd},
|
|
17
|
+
solaris: %r{solaris|sunos},
|
|
18
|
+
}
|
|
19
|
+
platforms.each do |os, regexp|
|
|
20
|
+
return os unless (regexp =~ host).nil?
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Current platform.
|
|
25
|
+
PLATFORM = find_platform.freeze
|
|
26
|
+
end
|