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,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'classification_result'
|
|
4
|
+
require_relative '../../parsing/base_inference'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
module Classification
|
|
10
|
+
# The inference result for a classification utility request.
|
|
11
|
+
class ClassificationInference < Mindee::V2::Parsing::BaseInference
|
|
12
|
+
# @return [ClassificationResult] Parsed inference payload.
|
|
13
|
+
attr_reader :result
|
|
14
|
+
|
|
15
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
16
|
+
def initialize(server_response)
|
|
17
|
+
super
|
|
18
|
+
|
|
19
|
+
@result = ClassificationResult.new(server_response['result'])
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# String representation.
|
|
23
|
+
# @return [String]
|
|
24
|
+
def to_s
|
|
25
|
+
[
|
|
26
|
+
super,
|
|
27
|
+
@result.to_s,
|
|
28
|
+
'',
|
|
29
|
+
].join("\n")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing/base_response'
|
|
4
|
+
require_relative 'classification_inference'
|
|
5
|
+
require_relative 'params/classification_parameters'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module V2
|
|
9
|
+
module Product
|
|
10
|
+
module Classification
|
|
11
|
+
# HTTP response wrapper that embeds a V2 Inference.
|
|
12
|
+
class ClassificationResponse < Mindee::V2::Parsing::BaseResponse
|
|
13
|
+
# @return [ClassificationInference] 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 = ClassificationInference.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,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'classification_classifier'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Classification
|
|
9
|
+
# Result of the document classifier inference.
|
|
10
|
+
class ClassificationResult
|
|
11
|
+
# @return [ClassificationClassifier] The document type, as identified on given classification values.
|
|
12
|
+
attr_reader :classification
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@classification = ClassificationClassifier.new(server_response['classification'])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @return [String] String representation.
|
|
20
|
+
def to_s
|
|
21
|
+
"Classification\n==============\n#{@classification}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module Classification
|
|
7
|
+
# Classification parameters.
|
|
8
|
+
module Params
|
|
9
|
+
# Parameters accepted by the classification utility v2 endpoint.
|
|
10
|
+
class ClassificationParameters < Mindee::Input::BaseParameters
|
|
11
|
+
# @return [String] Slug for the endpoint.
|
|
12
|
+
def self.slug
|
|
13
|
+
'classification'
|
|
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 [ClassificationParameters]
|
|
34
|
+
def self.from_hash(params: {})
|
|
35
|
+
ClassificationParameters.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,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'crop_response'
|
|
4
|
+
require_relative 'params/crop_parameters'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
# Crop module.
|
|
10
|
+
module Crop
|
|
11
|
+
# Crop product.
|
|
12
|
+
class Crop < BaseProduct
|
|
13
|
+
@slug = 'crop'
|
|
14
|
+
@params_type = Mindee::V2::Product::Crop::Params::CropParameters
|
|
15
|
+
@response_type = Mindee::V2::Product::Crop::CropResponse
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'crop_result'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Crop
|
|
9
|
+
# The inference result for a crop utility request.
|
|
10
|
+
class CropInference < Mindee::V2::Parsing::BaseInference
|
|
11
|
+
# @return [CropResult] 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 = CropResult.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,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module Crop
|
|
7
|
+
# Result of a cropped document region.
|
|
8
|
+
class CropItem
|
|
9
|
+
# @return [String] Type or classification of the detected object.
|
|
10
|
+
attr_reader :object_type
|
|
11
|
+
# @return [V2::Parsing::Field::FieldLocation] Coordinates of the detected object on the document.
|
|
12
|
+
attr_reader :location
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@object_type = server_response['object_type']
|
|
17
|
+
@location = Mindee::V2::Parsing::Field::FieldLocation.new(server_response['location'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# String representation.
|
|
21
|
+
# @return [String]
|
|
22
|
+
def to_s
|
|
23
|
+
"* :Location: #{location}\n :Object Type: #{object_type}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Extract all crop items from this page
|
|
27
|
+
#
|
|
28
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
29
|
+
# @return [ExtractedImage]
|
|
30
|
+
def extract_from_file(input_source)
|
|
31
|
+
Image::ImageExtractor.extract_multiple_images_from_source(
|
|
32
|
+
input_source, @location.page, [@location.polygon]
|
|
33
|
+
)[0]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing/base_response'
|
|
4
|
+
require_relative 'params/crop_parameters'
|
|
5
|
+
require_relative 'crop_inference'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module V2
|
|
9
|
+
module Product
|
|
10
|
+
module Crop
|
|
11
|
+
# HTTP response wrapper that embeds a V2 Inference.
|
|
12
|
+
class CropResponse < Mindee::V2::Parsing::BaseResponse
|
|
13
|
+
# @return [CropInference] 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 = CropInference.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
|
+
# Apply the crop inference to a file and return a list of extracted images.
|
|
30
|
+
#
|
|
31
|
+
# @param input_source [Mindee::Input::Source::LocalInputSource] Local file to extract from
|
|
32
|
+
# @return [FileOperation::CropFiles] List of extracted PDFs
|
|
33
|
+
def extract_from_file(input_source)
|
|
34
|
+
FileOperation::Crop.extract_crops(input_source, @inference.result.crops)
|
|
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 'crop_item'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Crop
|
|
9
|
+
# Result of a crop utility inference.
|
|
10
|
+
class CropResult
|
|
11
|
+
# @return [Array<Cropitem>] List of results of cropped document regions.
|
|
12
|
+
attr_reader :crops
|
|
13
|
+
|
|
14
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
15
|
+
def initialize(server_response)
|
|
16
|
+
@crops = if server_response.key?('crops')
|
|
17
|
+
server_response['crops'].map do |crop|
|
|
18
|
+
CropItem.new(crop)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# String representation.
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
crops_str = @crops.join("\n")
|
|
27
|
+
|
|
28
|
+
"Crops\n=====\n#{crops_str}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module Crop
|
|
7
|
+
# Crop parameters.
|
|
8
|
+
module Params
|
|
9
|
+
# Parameters accepted by the crop utility v2 endpoint.
|
|
10
|
+
class CropParameters < Mindee::Input::BaseParameters
|
|
11
|
+
# @return [String] Slug for the endpoint.
|
|
12
|
+
def self.slug
|
|
13
|
+
'crop'
|
|
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 [CropParameters]
|
|
34
|
+
def self.from_hash(params: {})
|
|
35
|
+
CropParameters.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,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'extraction_response'
|
|
4
|
+
require_relative 'params/extraction_parameters'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module V2
|
|
8
|
+
module Product
|
|
9
|
+
# Extraction module.
|
|
10
|
+
module Extraction
|
|
11
|
+
# Extraction product.
|
|
12
|
+
# Note: currently a placeholder for the `Inference` class.
|
|
13
|
+
class Extraction < Product::BaseProduct
|
|
14
|
+
@slug = 'extraction'
|
|
15
|
+
@params_type = Product::Extraction::Params::ExtractionParameters
|
|
16
|
+
@response_type = Product::Extraction::ExtractionResponse
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'extraction_response'
|
|
4
|
+
require_relative 'extraction_result'
|
|
5
|
+
require_relative 'params/extraction_parameters'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module V2
|
|
9
|
+
module Product
|
|
10
|
+
module Extraction
|
|
11
|
+
# Extraction inference.
|
|
12
|
+
class ExtractionInference < Mindee::V2::Parsing::BaseInference
|
|
13
|
+
# @return [InferenceActiveOptions] Options which were activated during the inference.
|
|
14
|
+
attr_reader :active_options
|
|
15
|
+
# @return [ExtractionResult] Result contents.
|
|
16
|
+
attr_reader :result
|
|
17
|
+
|
|
18
|
+
# @param server_response [Hash] Hash representation of the JSON returned by the service.
|
|
19
|
+
def initialize(server_response)
|
|
20
|
+
super
|
|
21
|
+
|
|
22
|
+
@active_options = V2::Parsing::InferenceActiveOptions.new(server_response['active_options'])
|
|
23
|
+
@result = ExtractionResult.new(server_response['result'])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# String representation.
|
|
27
|
+
# @return [String]
|
|
28
|
+
def to_s
|
|
29
|
+
[
|
|
30
|
+
super,
|
|
31
|
+
@active_options.to_s,
|
|
32
|
+
@result.to_s,
|
|
33
|
+
'',
|
|
34
|
+
].join("\n")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'extraction_inference'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Extraction
|
|
9
|
+
# HTTP response wrapper that embeds a V2 Inference.
|
|
10
|
+
class ExtractionResponse < Mindee::V2::Parsing::BaseResponse
|
|
11
|
+
# @return [ExtractionInference] Parsed inference payload.
|
|
12
|
+
attr_reader :inference
|
|
13
|
+
|
|
14
|
+
@slug = 'extraction'
|
|
15
|
+
@_params_type = Params::ExtractionParameters
|
|
16
|
+
|
|
17
|
+
def initialize(server_response)
|
|
18
|
+
super
|
|
19
|
+
|
|
20
|
+
@inference = Mindee::V2::Product::Extraction::ExtractionInference.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,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Extraction
|
|
9
|
+
# Result of an extraction utility inference.
|
|
10
|
+
class ExtractionResult
|
|
11
|
+
# @return [Mindee::V2::Parsing::Field::InferenceFields] Fields produced by the model.
|
|
12
|
+
attr_reader :fields
|
|
13
|
+
# @return [Mindee::V2::Parsing::RawText, nil] Optional extra data.
|
|
14
|
+
attr_reader :raw_text
|
|
15
|
+
# @return [Mindee::V2::Parsing::RAGMetadata, nil] Optional RAG metadata.
|
|
16
|
+
attr_reader :rag
|
|
17
|
+
|
|
18
|
+
# @param server_response [Hash] Hash version of the JSON returned by the API.
|
|
19
|
+
def initialize(server_response)
|
|
20
|
+
raise ArgumentError, 'server_response must be a Hash' unless server_response.is_a?(Hash)
|
|
21
|
+
|
|
22
|
+
@fields = Parsing::Field::InferenceFields.new(server_response['fields'])
|
|
23
|
+
|
|
24
|
+
@raw_text = server_response['raw_text'] ? Parsing::RawText.new(server_response['raw_text']) : nil
|
|
25
|
+
return unless server_response.key?('rag') && server_response['rag']
|
|
26
|
+
|
|
27
|
+
@rag = Parsing::RAGMetadata.new(server_response['rag'])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# String representation.
|
|
31
|
+
# @return [String]
|
|
32
|
+
def to_s
|
|
33
|
+
parts = [
|
|
34
|
+
'Fields',
|
|
35
|
+
'======',
|
|
36
|
+
@fields.to_s,
|
|
37
|
+
]
|
|
38
|
+
parts.join("\n")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'data_schema_replace'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Extraction
|
|
9
|
+
# Extraction parameters.
|
|
10
|
+
module Params
|
|
11
|
+
# Modify the Data Schema.
|
|
12
|
+
class DataSchema
|
|
13
|
+
# @return [Mindee::V2::Product::Extraction::Params::DataSchemaReplace]
|
|
14
|
+
attr_reader :replace
|
|
15
|
+
|
|
16
|
+
# @param data_schema [Hash, String]
|
|
17
|
+
def initialize(data_schema)
|
|
18
|
+
case data_schema
|
|
19
|
+
when String
|
|
20
|
+
parsed = JSON.parse(data_schema.to_s, object_class: Hash)
|
|
21
|
+
parsed.transform_keys!(&:to_sym)
|
|
22
|
+
@replace = DataSchemaReplace.new(parsed[:replace])
|
|
23
|
+
when Hash
|
|
24
|
+
data_schema.transform_keys!(&:to_sym)
|
|
25
|
+
@replace = if data_schema[:replace].is_a?(DataSchemaReplace)
|
|
26
|
+
data_schema[:replace]
|
|
27
|
+
else
|
|
28
|
+
DataSchemaReplace.new(data_schema[:replace])
|
|
29
|
+
end
|
|
30
|
+
when DataSchema
|
|
31
|
+
@replace = data_schema.replace
|
|
32
|
+
else
|
|
33
|
+
raise TypeError, 'Invalid Data Schema provided.'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @return [Hash]
|
|
38
|
+
def to_hash
|
|
39
|
+
{ replace: @replace.to_hash }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @return [String]
|
|
43
|
+
def to_s
|
|
44
|
+
to_hash.to_json
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Product
|
|
6
|
+
module Extraction
|
|
7
|
+
module Params
|
|
8
|
+
# Data Schema Field.
|
|
9
|
+
class DataSchemaField
|
|
10
|
+
# @return [String] Display name for the field, also impacts inference results.
|
|
11
|
+
attr_reader :title
|
|
12
|
+
# @return [String] Name of the field in the data schema.
|
|
13
|
+
attr_reader :name
|
|
14
|
+
# @return [Boolean] Whether this field can contain multiple values.
|
|
15
|
+
attr_reader :is_array
|
|
16
|
+
# @return [String] Data type of the field.
|
|
17
|
+
attr_reader :type
|
|
18
|
+
# @return [Array<String>, nil] Allowed values when type is `classification`. Leave empty for other types.
|
|
19
|
+
attr_reader :classification_values
|
|
20
|
+
# @return [Boolean, nil] Whether to remove duplicate values in the array.
|
|
21
|
+
# Only applicable if `is_array` is True.
|
|
22
|
+
attr_reader :unique_values
|
|
23
|
+
# @return [String, nil] Detailed description of what this field represents.
|
|
24
|
+
attr_reader :description
|
|
25
|
+
# @return [String, nil] Optional extraction guidelines.
|
|
26
|
+
attr_reader :guidelines
|
|
27
|
+
# @return [Array<Hash>, nil] Nested fields.
|
|
28
|
+
attr_reader :nested_fields
|
|
29
|
+
|
|
30
|
+
# @param field [Hash]
|
|
31
|
+
def initialize(field)
|
|
32
|
+
field.transform_keys!(&:to_sym)
|
|
33
|
+
@name = field[:name]
|
|
34
|
+
@title = field[:title]
|
|
35
|
+
@is_array = field[:is_array]
|
|
36
|
+
@type = field[:type]
|
|
37
|
+
@classification_values = field[:classification_values]
|
|
38
|
+
@unique_values = field[:unique_values]
|
|
39
|
+
@description = field[:description]
|
|
40
|
+
@guidelines = field[:guidelines]
|
|
41
|
+
@nested_fields = field[:nested_fields]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [Hash]
|
|
45
|
+
def to_hash
|
|
46
|
+
out = {
|
|
47
|
+
name: @name,
|
|
48
|
+
title: @title,
|
|
49
|
+
is_array: @is_array,
|
|
50
|
+
type: @type,
|
|
51
|
+
} # @type var out: Hash[Symbol, untyped]
|
|
52
|
+
out[:classification_values] = @classification_values unless @classification_values.nil?
|
|
53
|
+
out[:unique_values] = @unique_values unless @unique_values.nil?
|
|
54
|
+
out[:description] = @description unless @description.nil?
|
|
55
|
+
out[:guidelines] = @guidelines unless @guidelines.nil?
|
|
56
|
+
out[:nested_fields] = @nested_fields unless @nested_fields.nil?
|
|
57
|
+
out
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [String]
|
|
61
|
+
def to_s
|
|
62
|
+
to_hash.to_json
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'data_schema_field'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module V2
|
|
7
|
+
module Product
|
|
8
|
+
module Extraction
|
|
9
|
+
module Params
|
|
10
|
+
# The structure to completely replace the data schema of the model.
|
|
11
|
+
class DataSchemaReplace
|
|
12
|
+
# @return [Array<DataSchemaField>] Subfields when type is `nested_object`. Leave empty for other types.
|
|
13
|
+
attr_reader :fields
|
|
14
|
+
|
|
15
|
+
# @param data_schema_replace [Hash]
|
|
16
|
+
def initialize(data_schema_replace)
|
|
17
|
+
data_schema_replace.transform_keys!(&:to_sym)
|
|
18
|
+
fields_list = data_schema_replace[:fields]
|
|
19
|
+
raise Mindee::Error::MindeeError, 'Invalid Data Schema provided.' if fields_list.nil?
|
|
20
|
+
raise TypeError, 'Data Schema replacement fields cannot be empty.' if fields_list.empty?
|
|
21
|
+
|
|
22
|
+
@fields = fields_list.map { |field| DataSchemaField.new(field) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [Hash]
|
|
26
|
+
def to_hash
|
|
27
|
+
{ fields: @fields.map(&:to_hash) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [String]
|
|
31
|
+
def to_s
|
|
32
|
+
to_hash.to_json
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|