From c00f8d2312b6f9cee0a5d76ff3195e135439631a Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Thu, 14 Nov 2024 10:11:47 +0100 Subject: [PATCH 1/2] :sparkles: add support for business cards, delivery notes, indian passport & update resume, invoice & findoc --- docs/business_card_v1.md | 169 +++++++++++ docs/code_samples/business_card_v1_async.txt | 19 ++ docs/code_samples/delivery_notes_v1_async.txt | 19 ++ docs/code_samples/ind_passport_v1_async.txt | 19 ++ docs/delivery_notes_v1.md | 143 +++++++++ docs/financial_document_v1.md | 8 +- docs/ind_passport_v1.md | 281 ++++++++++++++++++ docs/invoices_v4.md | 16 +- docs/resume_v1.md | 33 +- lib/mindee/product.rb | 17 +- .../product/business_card/business_card_v1.rb | 39 +++ .../business_card_v1_document.rb | 85 ++++++ .../business_card/business_card_v1_page.rb | 32 ++ .../product/delivery_note/delivery_note_v1.rb | 39 +++ .../delivery_note_v1_document.rb | 61 ++++ .../delivery_note/delivery_note_v1_page.rb | 32 ++ .../financial_document_v1_document.rb | 2 +- .../financial_document_v1_page.rb | 2 +- .../ind/indian_passport/indian_passport_v1.rb | 41 +++ .../indian_passport_v1_document.rb | 143 +++++++++ .../indian_passport_v1_page.rb | 34 +++ .../product/invoice/invoice_v4_document.rb | 2 +- lib/mindee/product/invoice/invoice_v4_page.rb | 2 +- .../product/resume/resume_v1_document.rb | 4 +- lib/mindee/product/resume/resume_v1_page.rb | 2 +- .../resume_v1_professional_experience.rb | 8 + spec/data | 2 +- spec/document/business_card_v1_spec.rb | 32 ++ spec/document/delivery_note_v1_spec.rb | 32 ++ spec/document/ind/indian_passport_v1_spec.rb | 32 ++ 30 files changed, 1308 insertions(+), 42 deletions(-) create mode 100644 docs/business_card_v1.md create mode 100644 docs/code_samples/business_card_v1_async.txt create mode 100644 docs/code_samples/delivery_notes_v1_async.txt create mode 100644 docs/code_samples/ind_passport_v1_async.txt create mode 100644 docs/delivery_notes_v1.md create mode 100644 docs/ind_passport_v1.md create mode 100644 lib/mindee/product/business_card/business_card_v1.rb create mode 100644 lib/mindee/product/business_card/business_card_v1_document.rb create mode 100644 lib/mindee/product/business_card/business_card_v1_page.rb create mode 100644 lib/mindee/product/delivery_note/delivery_note_v1.rb create mode 100644 lib/mindee/product/delivery_note/delivery_note_v1_document.rb create mode 100644 lib/mindee/product/delivery_note/delivery_note_v1_page.rb create mode 100644 lib/mindee/product/ind/indian_passport/indian_passport_v1.rb create mode 100644 lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb create mode 100644 lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb create mode 100644 spec/document/business_card_v1_spec.rb create mode 100644 spec/document/delivery_note_v1_spec.rb create mode 100644 spec/document/ind/indian_passport_v1_spec.rb diff --git a/docs/business_card_v1.md b/docs/business_card_v1.md new file mode 100644 index 00000000..bb770835 --- /dev/null +++ b/docs/business_card_v1.md @@ -0,0 +1,169 @@ +--- +title: Business Card OCR Ruby +category: 622b805aaec68102ea7fcbc2 +slug: ruby-business-card-ocr +parentDoc: 6294d97ee723f1008d2ab28e +--- +The Ruby OCR SDK supports the [Business Card API](https://platform.mindee.com/mindee/business_card). + +Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. +![Business Card sample](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg?raw=true) + +# Quick-Start +```rb +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::BusinessCard::BusinessCardV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction + +``` + +**Output (RST):** +```rst +######## +Document +######## +:Mindee ID: 6f9a261f-7609-4687-9af0-46a45156566e +:Filename: default_sample.jpg + +Inference +######### +:Product: mindee/business_card v1.0 +:Rotation applied: Yes + +Prediction +========== +:Firstname: Andrew +:Lastname: Morin +:Job Title: Founder & CEO +:Company: RemoteGlobal +:Email: amorin@remoteglobalconsulting.com +:Phone Number: +14015555555 +:Mobile Number: +13015555555 +:Fax Number: +14015555556 +:Address: 178 Main Avenue, Providence, RI 02111 +:Website: www.remoteglobalconsulting.com +:Social Media: https://www.linkedin.com/in/johndoe + https://twitter.com/johndoe +``` + +# Field Types +## Standard Fields +These fields are generic and used in several products. + +### Basic Field +Each prediction object contains a set of fields that inherit from the generic `Field` class. +A typical `Field` object will have the following attributes: + +* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted. +* **confidence** (Float, nil): the confidence score of the field prediction. +* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. +* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image. +* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level. +* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it). + + +Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string. + +### String Field +The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`). + +# Attributes +The following fields are extracted for Business Card V1: + +## Address +**address** ([StringField](#string-field)): The address of the person. + +```rb +puts result.document.inference.prediction.address.value +``` + +## Company +**company** ([StringField](#string-field)): The company the person works for. + +```rb +puts result.document.inference.prediction.company.value +``` + +## Email +**email** ([StringField](#string-field)): The email address of the person. + +```rb +puts result.document.inference.prediction.email.value +``` + +## Fax Number +**fax_number** ([StringField](#string-field)): The Fax number of the person. + +```rb +puts result.document.inference.prediction.fax_number.value +``` + +## Firstname +**firstname** ([StringField](#string-field)): The given name of the person. + +```rb +puts result.document.inference.prediction.firstname.value +``` + +## Job Title +**job_title** ([StringField](#string-field)): The job title of the person. + +```rb +puts result.document.inference.prediction.job_title.value +``` + +## Lastname +**lastname** ([StringField](#string-field)): The lastname of the person. + +```rb +puts result.document.inference.prediction.lastname.value +``` + +## Mobile Number +**mobile_number** ([StringField](#string-field)): The mobile number of the person. + +```rb +puts result.document.inference.prediction.mobile_number.value +``` + +## Phone Number +**phone_number** ([StringField](#string-field)): The phone number of the person. + +```rb +puts result.document.inference.prediction.phone_number.value +``` + +## Social Media +**social_media** (Array<[StringField](#string-field)>): The social media profiles of the person or company. + +```rb +for social_media_elem in result.document.inference.prediction.social_media do + puts social_media_elem.value +end +``` + +## Website +**website** ([StringField](#string-field)): The website of the person or company. + +```rb +puts result.document.inference.prediction.website.value +``` + +# Questions? +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/code_samples/business_card_v1_async.txt b/docs/code_samples/business_card_v1_async.txt new file mode 100644 index 00000000..cf71e928 --- /dev/null +++ b/docs/code_samples/business_card_v1_async.txt @@ -0,0 +1,19 @@ +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::BusinessCard::BusinessCardV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction diff --git a/docs/code_samples/delivery_notes_v1_async.txt b/docs/code_samples/delivery_notes_v1_async.txt new file mode 100644 index 00000000..3c38b76a --- /dev/null +++ b/docs/code_samples/delivery_notes_v1_async.txt @@ -0,0 +1,19 @@ +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::DeliveryNote::DeliveryNoteV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction diff --git a/docs/code_samples/ind_passport_v1_async.txt b/docs/code_samples/ind_passport_v1_async.txt new file mode 100644 index 00000000..f0e7a2e7 --- /dev/null +++ b/docs/code_samples/ind_passport_v1_async.txt @@ -0,0 +1,19 @@ +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::IND::IndianPassport::IndianPassportV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction diff --git a/docs/delivery_notes_v1.md b/docs/delivery_notes_v1.md new file mode 100644 index 00000000..88543d25 --- /dev/null +++ b/docs/delivery_notes_v1.md @@ -0,0 +1,143 @@ +--- +title: Delivery note OCR Ruby +category: 622b805aaec68102ea7fcbc2 +slug: ruby-delivery-note-ocr +parentDoc: 6294d97ee723f1008d2ab28e +--- +The Ruby OCR SDK supports the [Delivery note API](https://platform.mindee.com/mindee/delivery_notes). + +Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/delivery_notes/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. +![Delivery note sample](https://github.com/mindee/client-lib-test-data/blob/main/products/delivery_notes/default_sample.jpg?raw=true) + +# Quick-Start +```rb +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::DeliveryNote::DeliveryNoteV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction + +``` + +**Output (RST):** +```rst +######## +Document +######## +:Mindee ID: d5ead821-edec-4d31-a69a-cf3998d9a506 +:Filename: default_sample.jpg + +Inference +######### +:Product: mindee/delivery_notes v1.0 +:Rotation applied: Yes + +Prediction +========== +:Delivery Date: 2019-10-02 +:Delivery Number: INT-001 +:Supplier Name: John Smith +:Supplier Address: 4490 Oak Drive, Albany, NY 12210 +:Customer Name: Jessie M Horne +:Customer Address: 4312 Wood Road, New York, NY 10031 +:Total Amount: 204.75 +``` + +# Field Types +## Standard Fields +These fields are generic and used in several products. + +### Basic Field +Each prediction object contains a set of fields that inherit from the generic `Field` class. +A typical `Field` object will have the following attributes: + +* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted. +* **confidence** (Float, nil): the confidence score of the field prediction. +* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. +* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image. +* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level. +* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it). + + +Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string. + + +### Amount Field +The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`). + +### Date Field +Aside from the basic `Field` attributes, the date field `DateField` also implements the following: + +* **date_object** (`Date`): an accessible representation of the value as a JavaScript object. + +### String Field +The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`). + +# Attributes +The following fields are extracted for Delivery note V1: + +## Customer Address +**customer_address** ([StringField](#string-field)): The address of the customer receiving the goods. + +```rb +puts result.document.inference.prediction.customer_address.value +``` + +## Customer Name +**customer_name** ([StringField](#string-field)): The name of the customer receiving the goods. + +```rb +puts result.document.inference.prediction.customer_name.value +``` + +## Delivery Date +**delivery_date** ([DateField](#date-field)): The date on which the delivery is scheduled to arrive. + +```rb +puts result.document.inference.prediction.delivery_date.value +``` + +## Delivery Number +**delivery_number** ([StringField](#string-field)): A unique identifier for the delivery note. + +```rb +puts result.document.inference.prediction.delivery_number.value +``` + +## Supplier Address +**supplier_address** ([StringField](#string-field)): The address of the supplier providing the goods. + +```rb +puts result.document.inference.prediction.supplier_address.value +``` + +## Supplier Name +**supplier_name** ([StringField](#string-field)): The name of the supplier providing the goods. + +```rb +puts result.document.inference.prediction.supplier_name.value +``` + +## Total Amount +**total_amount** ([AmountField](#amount-field)): The total monetary value of the goods being delivered. + +```rb +puts result.document.inference.prediction.total_amount.value +``` + +# Questions? +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/financial_document_v1.md b/docs/financial_document_v1.md index 092b9ddb..ecdd3136 100644 --- a/docs/financial_document_v1.md +++ b/docs/financial_document_v1.md @@ -63,17 +63,17 @@ puts result.document ######## Document ######## -:Mindee ID: 340ee4ae-b4da-41f0-b5ea-81ae29852b57 +:Mindee ID: b26161ce-35d0-4984-b1ff-886645e160e6 :Filename: default_sample.jpg Inference ######### -:Product: mindee/financial_document v1.10 +:Product: mindee/financial_document v1.11 :Rotation applied: Yes Prediction ========== -:Locale: en; en; USD; +:Locale: en-US; en; US; USD; :Invoice Number: INT-001 :Purchase Order Number: 2412/2019 :Receipt Number: @@ -125,7 +125,7 @@ Page Predictions Page 0 ------ -:Locale: en; en; USD; +:Locale: en-US; en; US; USD; :Invoice Number: INT-001 :Purchase Order Number: 2412/2019 :Receipt Number: diff --git a/docs/ind_passport_v1.md b/docs/ind_passport_v1.md new file mode 100644 index 00000000..401f72d6 --- /dev/null +++ b/docs/ind_passport_v1.md @@ -0,0 +1,281 @@ +--- +title: IND Passport - India OCR Ruby +category: 622b805aaec68102ea7fcbc2 +slug: ruby-ind-passport---india-ocr +parentDoc: 6294d97ee723f1008d2ab28e +--- +The Ruby OCR SDK supports the [Passport - India API](https://platform.mindee.com/mindee/ind_passport). + +Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/ind_passport/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. +![Passport - India sample](https://github.com/mindee/client-lib-test-data/blob/main/products/ind_passport/default_sample.jpg?raw=true) + +# Quick-Start +```rb +require 'mindee' + +# Init a new client +mindee_client = Mindee::Client.new(api_key: 'my-api-key') + +# Load a file from disk +input_source = mindee_client.source_from_path('/path/to/the/file.ext') + +# Parse the file +result = mindee_client.enqueue_and_parse( + input_source, + Mindee::Product::IND::IndianPassport::IndianPassportV1 +) + +# Print a full summary of the parsed data in RST format +puts result.document + +# Print the document-level parsed data +# puts result.document.inference.prediction + +``` + +**Output (RST):** +```rst +######## +Document +######## +:Mindee ID: cf88fd43-eaa1-497a-ba29-a9569a4edaa7 +:Filename: default_sample.jpg + +Inference +######### +:Product: mindee/ind_passport v1.0 +:Rotation applied: Yes + +Prediction +========== +:Page Number: 1 +:Country: IND +:ID Number: J8369854 +:Given Names: JOCELYN MICHELLE +:Surname: DOE +:Birth Date: 1959-09-23 +:Birth Place: GUNDUGOLANU +:Issuance Place: HYDERABAD +:Gender: F +:Issuance Date: 2011-10-11 +:Expiry Date: 2021-10-10 +:MRZ Line 1: P Note: a classification field's `value is always a `String`. + +### Date Field +Aside from the basic `Field` attributes, the date field `DateField` also implements the following: + +* **date_object** (`Date`): an accessible representation of the value as a JavaScript object. + +### String Field +The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`). + +# Attributes +The following fields are extracted for Passport - India V1: + +## Address Line 1 +**address1** ([StringField](#string-field)): The first line of the address of the passport holder. + +```rb +puts result.document.inference.prediction.address1.value +``` + +## Address Line 2 +**address2** ([StringField](#string-field)): The second line of the address of the passport holder. + +```rb +puts result.document.inference.prediction.address2.value +``` + +## Address Line 3 +**address3** ([StringField](#string-field)): The third line of the address of the passport holder. + +```rb +puts result.document.inference.prediction.address3.value +``` + +## Birth Date +**birth_date** ([DateField](#date-field)): The birth date of the passport holder, ISO format: YYYY-MM-DD. + +```rb +puts result.document.inference.prediction.birth_date.value +``` + +## Birth Place +**birth_place** ([StringField](#string-field)): The birth place of the passport holder. + +```rb +puts result.document.inference.prediction.birth_place.value +``` + +## Country +**country** ([StringField](#string-field)): ISO 3166-1 alpha-3 country code (3 letters format). + +```rb +puts result.document.inference.prediction.country.value +``` + +## Expiry Date +**expiry_date** ([DateField](#date-field)): The date when the passport will expire, ISO format: YYYY-MM-DD. + +```rb +puts result.document.inference.prediction.expiry_date.value +``` + +## File Number +**file_number** ([StringField](#string-field)): The file number of the passport document. + +```rb +puts result.document.inference.prediction.file_number.value +``` + +## Gender +**gender** ([ClassificationField](#classification-field)): The gender of the passport holder. + +#### Possible values include: + - M + - F + +```rb +puts result.document.inference.prediction.gender.value +``` + +## Given Names +**given_names** ([StringField](#string-field)): The given names of the passport holder. + +```rb +puts result.document.inference.prediction.given_names.value +``` + +## ID Number +**id_number** ([StringField](#string-field)): The identification number of the passport document. + +```rb +puts result.document.inference.prediction.id_number.value +``` + +## Issuance Date +**issuance_date** ([DateField](#date-field)): The date when the passport was issued, ISO format: YYYY-MM-DD. + +```rb +puts result.document.inference.prediction.issuance_date.value +``` + +## Issuance Place +**issuance_place** ([StringField](#string-field)): The place where the passport was issued. + +```rb +puts result.document.inference.prediction.issuance_place.value +``` + +## Legal Guardian +**legal_guardian** ([StringField](#string-field)): The name of the legal guardian of the passport holder (if applicable). + +```rb +puts result.document.inference.prediction.legal_guardian.value +``` + +## MRZ Line 1 +**mrz1** ([StringField](#string-field)): The first line of the machine-readable zone (MRZ) of the passport document. + +```rb +puts result.document.inference.prediction.mrz1.value +``` + +## MRZ Line 2 +**mrz2** ([StringField](#string-field)): The second line of the machine-readable zone (MRZ) of the passport document. + +```rb +puts result.document.inference.prediction.mrz2.value +``` + +## Name of Mother +**name_of_mother** ([StringField](#string-field)): The name of the mother of the passport holder. + +```rb +puts result.document.inference.prediction.name_of_mother.value +``` + +## Name of Spouse +**name_of_spouse** ([StringField](#string-field)): The name of the spouse of the passport holder (if applicable). + +```rb +puts result.document.inference.prediction.name_of_spouse.value +``` + +## Old Passport Date of Issue +**old_passport_date_of_issue** ([DateField](#date-field)): The date of issue of the old passport (if applicable), ISO format: YYYY-MM-DD. + +```rb +puts result.document.inference.prediction.old_passport_date_of_issue.value +``` + +## Old Passport Number +**old_passport_number** ([StringField](#string-field)): The number of the old passport (if applicable). + +```rb +puts result.document.inference.prediction.old_passport_number.value +``` + +## Old Passport Place of Issue +**old_passport_place_of_issue** ([StringField](#string-field)): The place of issue of the old passport (if applicable). + +```rb +puts result.document.inference.prediction.old_passport_place_of_issue.value +``` + +## Page Number +**page_number** ([ClassificationField](#classification-field)): The page number of the passport document. + +#### Possible values include: + - 1 + - 2 + +```rb +puts result.document.inference.prediction.page_number.value +``` + +## Surname +**surname** ([StringField](#string-field)): The surname of the passport holder. + +```rb +puts result.document.inference.prediction.surname.value +``` + +# Questions? +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/invoices_v4.md b/docs/invoices_v4.md index a491f4d4..aa11008a 100644 --- a/docs/invoices_v4.md +++ b/docs/invoices_v4.md @@ -63,23 +63,23 @@ puts result.document ######## Document ######## -:Mindee ID: 651b6417-bc50-496e-aa81-207219f0b9f4 +:Mindee ID: a67b70ea-4b1e-4eac-ae75-dda47a7064ae :Filename: default_sample.jpg Inference ######### -:Product: mindee/invoices v4.8 +:Product: mindee/invoices v4.9 :Rotation applied: Yes Prediction ========== -:Locale: en; en; CAD; +:Locale: en-CA; en; CA; CAD; :Invoice Number: 14 :Purchase Order Number: AD29094 :Reference Numbers: AD29094 :Purchase Date: 2018-09-25 -:Due Date: -:Payment Date: +:Due Date: 2011-12-01 +:Payment Date: 2011-12-01 :Total Net: 2145.00 :Total Amount: 2608.20 :Total Tax: 193.20 @@ -119,13 +119,13 @@ Page Predictions Page 0 ------ -:Locale: en; en; CAD; +:Locale: en-CA; en; CA; CAD; :Invoice Number: 14 :Purchase Order Number: AD29094 :Reference Numbers: AD29094 :Purchase Date: 2018-09-25 -:Due Date: -:Payment Date: +:Due Date: 2011-12-01 +:Payment Date: 2011-12-01 :Total Net: 2145.00 :Total Amount: 2608.20 :Total Tax: 193.20 diff --git a/docs/resume_v1.md b/docs/resume_v1.md index 2bafa1a5..84eddf98 100644 --- a/docs/resume_v1.md +++ b/docs/resume_v1.md @@ -38,13 +38,13 @@ puts result.document ######## Document ######## -:Mindee ID: bc80bae0-af75-4464-95a9-2419403c75bf +:Mindee ID: 9daa3085-152c-454e-9245-636f13fc9dc3 :Filename: default_sample.jpg Inference ######### -:Product: mindee/resume v1.0 -:Rotation applied: No +:Product: mindee/resume v1.1 +:Rotation applied: Yes Prediction ========== @@ -54,8 +54,8 @@ Prediction :Surnames: Morgan :Nationality: :Email Address: christoper.m@gmail.com -:Phone Number: +44 (0) 20 7666 8555 -:Address: 177 Great Portland Street, London W5W 6PQ +:Phone Number: +44 (0)20 7666 8555 +:Address: 177 Great Portland Street, London, W5W 6PQ :Social Networks: +----------------------+----------------------------------------------------+ | Name | URL | @@ -72,38 +72,37 @@ Prediction +----------+----------------------+ | ZHO | Beginner | +----------+----------------------+ - | DEU | Intermediate | + | DEU | Beginner | +----------+----------------------+ :Hard Skills: HTML5 PHP OOP JavaScript CSS MySQL + SQL :Soft Skills: Project management + Creative design Strong decision maker Innovative Complex problem solver - Creative design Service-focused :Education: +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+ | Domain | Degree | End Month | End Year | School | Start Month | Start Year | +=================+===========================+===========+==========+===========================+=============+============+ - | Computer Inf... | Bachelor | | | Columbia University, NY | | 2014 | + | Computer Inf... | Bachelor | | 2014 | Columbia University, NY | | | +-----------------+---------------------------+-----------+----------+---------------------------+-------------+------------+ :Professional Experiences: - +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+ - | Contract Type | Department | Employer | End Month | End Year | Role | Start Month | Start Year | - +=================+============+===========================+===========+==========+======================+=============+============+ - | Full-Time | | Luna Web Design, New York | 05 | 2019 | Web Developer | 09 | 2015 | - +-----------------+------------+---------------------------+-----------+----------+----------------------+-------------+------------+ + +-----------------+------------+--------------------------------------+---------------------------+-----------+----------+----------------------+-------------+------------+ + | Contract Type | Department | Description | Employer | End Month | End Year | Role | Start Month | Start Year | + +=================+============+======================================+===========================+===========+==========+======================+=============+============+ + | | | Cooperate with designers to creat... | Luna Web Design, New York | 05 | 2019 | Web Developer | 09 | 2015 | + +-----------------+------------+--------------------------------------+---------------------------+-----------+----------+----------------------+-------------+------------+ :Certificates: +------------+--------------------------------+---------------------------+------+ | Grade | Name | Provider | Year | +============+================================+===========================+======+ - | | PHP Framework (certificate)... | | 2014 | - +------------+--------------------------------+---------------------------+------+ - | | Programming Languages: Java... | | | + | | PHP Framework (certificate)... | | | +------------+--------------------------------+---------------------------+------+ ``` @@ -171,6 +170,7 @@ A `ResumeV1Language` implements the following attributes: * `level` (String): The candidate's level for the language. #### Possible values include: + - Native - Fluent - Proficient - Intermediate @@ -192,6 +192,7 @@ A `ResumeV1ProfessionalExperience` implements the following attributes: - Freelance * `department` (String): The specific department or division within the company. +* `description` (String): The description of the professional experience as written in the document. * `employer` (String): The name of the company or organization. * `end_month` (String): The month when the professional experience ended. * `end_year` (String): The year when the professional experience ended. diff --git a/lib/mindee/product.rb b/lib/mindee/product.rb index 4e564c25..fc943031 100644 --- a/lib/mindee/product.rb +++ b/lib/mindee/product.rb @@ -2,15 +2,10 @@ require_relative 'product/barcode_reader/barcode_reader_v1' require_relative 'product/bill_of_lading/bill_of_lading_v1' +require_relative 'product/business_card/business_card_v1' require_relative 'product/custom/custom_v1' -require_relative 'product/proof_of_address/proof_of_address_v1' -require_relative 'product/financial_document/financial_document_v1' -require_relative 'product/invoice/invoice_v4' require_relative 'product/cropper/cropper_v1' -require_relative 'product/multi_receipts_detector/multi_receipts_detector_v1' -require_relative 'product/passport/passport_v1' -require_relative 'product/receipt/receipt_v4' -require_relative 'product/receipt/receipt_v5' +require_relative 'product/delivery_note/delivery_note_v1' require_relative 'product/eu/license_plate/license_plate_v1' require_relative 'product/eu/driver_license/driver_license_v1' require_relative 'product/fr/bank_account_details/bank_account_details_v1' @@ -22,11 +17,19 @@ require_relative 'product/fr/id_card/id_card_v2' require_relative 'product/fr/energy_bill/energy_bill_v1' require_relative 'product/fr/payslip/payslip_v2' +require_relative 'product/financial_document/financial_document_v1' require_relative 'product/generated/generated_v1' +require_relative 'product/ind/indian_passport/indian_passport_v1' +require_relative 'product/invoice/invoice_v4' require_relative 'product/invoice_splitter/invoice_splitter_v1' require_relative 'product/international_id/international_id_v1' require_relative 'product/international_id/international_id_v2' +require_relative 'product/multi_receipts_detector/multi_receipts_detector_v1' require_relative 'product/nutrition_facts_label/nutrition_facts_label_v1' +require_relative 'product/passport/passport_v1' +require_relative 'product/proof_of_address/proof_of_address_v1' +require_relative 'product/receipt/receipt_v4' +require_relative 'product/receipt/receipt_v5' require_relative 'product/resume/resume_v1' require_relative 'product/us/bank_check/bank_check_v1' require_relative 'product/us/driver_license/driver_license_v1' diff --git a/lib/mindee/product/business_card/business_card_v1.rb b/lib/mindee/product/business_card/business_card_v1.rb new file mode 100644 index 00000000..fbd6cffc --- /dev/null +++ b/lib/mindee/product/business_card/business_card_v1.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../../parsing' +require_relative 'business_card_v1_document' +require_relative 'business_card_v1_page' + +module Mindee + module Product + # Business Card module. + module BusinessCard + # Business Card API version 1 inference prediction. + class BusinessCardV1 < Mindee::Parsing::Common::Inference + @endpoint_name = 'business_card' + @endpoint_version = '1' + + # @param prediction [Hash] + def initialize(prediction) + super + @prediction = BusinessCardV1Document.new(prediction['prediction'], nil) + @pages = [] + prediction['pages'].each do |page| + if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty? + @pages.push(BusinessCardV1Page.new(page)) + end + end + end + + class << self + # Name of the endpoint for this product. + # @return [String] + attr_reader :endpoint_name + # Version for this product. + # @return [String] + attr_reader :endpoint_version + end + end + end + end +end diff --git a/lib/mindee/product/business_card/business_card_v1_document.rb b/lib/mindee/product/business_card/business_card_v1_document.rb new file mode 100644 index 00000000..cbef93ce --- /dev/null +++ b/lib/mindee/product/business_card/business_card_v1_document.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +require_relative '../../parsing' + +module Mindee + module Product + module BusinessCard + # Business Card API version 1.0 document data. + class BusinessCardV1Document < Mindee::Parsing::Common::Prediction + include Mindee::Parsing::Standard + # The address of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :address + # The company the person works for. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :company + # The email address of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :email + # The Fax number of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :fax_number + # The given name of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :firstname + # The job title of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :job_title + # The lastname of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :lastname + # The mobile number of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :mobile_number + # The phone number of the person. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :phone_number + # The social media profiles of the person or company. + # @return [Array] + attr_reader :social_media + # The website of the person or company. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :website + + # @param prediction [Hash] + # @param page_id [Integer, nil] + def initialize(prediction, page_id) + super() + @address = StringField.new(prediction['address'], page_id) + @company = StringField.new(prediction['company'], page_id) + @email = StringField.new(prediction['email'], page_id) + @fax_number = StringField.new(prediction['fax_number'], page_id) + @firstname = StringField.new(prediction['firstname'], page_id) + @job_title = StringField.new(prediction['job_title'], page_id) + @lastname = StringField.new(prediction['lastname'], page_id) + @mobile_number = StringField.new(prediction['mobile_number'], page_id) + @phone_number = StringField.new(prediction['phone_number'], page_id) + @social_media = [] + prediction['social_media'].each do |item| + @social_media.push(StringField.new(item, page_id)) + end + @website = StringField.new(prediction['website'], page_id) + end + + # @return [String] + def to_s + social_media = @social_media.join("\n #{' ' * 14}") + out_str = String.new + out_str << "\n:Firstname: #{@firstname}".rstrip + out_str << "\n:Lastname: #{@lastname}".rstrip + out_str << "\n:Job Title: #{@job_title}".rstrip + out_str << "\n:Company: #{@company}".rstrip + out_str << "\n:Email: #{@email}".rstrip + out_str << "\n:Phone Number: #{@phone_number}".rstrip + out_str << "\n:Mobile Number: #{@mobile_number}".rstrip + out_str << "\n:Fax Number: #{@fax_number}".rstrip + out_str << "\n:Address: #{@address}".rstrip + out_str << "\n:Website: #{@website}".rstrip + out_str << "\n:Social Media: #{social_media}".rstrip + out_str[1..].to_s + end + end + end + end +end diff --git a/lib/mindee/product/business_card/business_card_v1_page.rb b/lib/mindee/product/business_card/business_card_v1_page.rb new file mode 100644 index 00000000..1e169dec --- /dev/null +++ b/lib/mindee/product/business_card/business_card_v1_page.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require_relative '../../parsing' +require_relative 'business_card_v1_document' + +module Mindee + module Product + module BusinessCard + # Business Card API version 1.0 page data. + class BusinessCardV1Page < Mindee::Parsing::Common::Page + # @param prediction [Hash] + def initialize(prediction) + super(prediction) + @prediction = BusinessCardV1PagePrediction.new( + prediction['prediction'], + prediction['id'] + ) + end + end + + # Business Card V1 page prediction. + class BusinessCardV1PagePrediction < BusinessCardV1Document + # @return [String] + def to_s + out_str = String.new + out_str << "\n#{super}" + out_str + end + end + end + end +end diff --git a/lib/mindee/product/delivery_note/delivery_note_v1.rb b/lib/mindee/product/delivery_note/delivery_note_v1.rb new file mode 100644 index 00000000..625df4da --- /dev/null +++ b/lib/mindee/product/delivery_note/delivery_note_v1.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative '../../parsing' +require_relative 'delivery_note_v1_document' +require_relative 'delivery_note_v1_page' + +module Mindee + module Product + # Delivery note module. + module DeliveryNote + # Delivery note API version 1 inference prediction. + class DeliveryNoteV1 < Mindee::Parsing::Common::Inference + @endpoint_name = 'delivery_notes' + @endpoint_version = '1' + + # @param prediction [Hash] + def initialize(prediction) + super + @prediction = DeliveryNoteV1Document.new(prediction['prediction'], nil) + @pages = [] + prediction['pages'].each do |page| + if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty? + @pages.push(DeliveryNoteV1Page.new(page)) + end + end + end + + class << self + # Name of the endpoint for this product. + # @return [String] + attr_reader :endpoint_name + # Version for this product. + # @return [String] + attr_reader :endpoint_version + end + end + end + end +end diff --git a/lib/mindee/product/delivery_note/delivery_note_v1_document.rb b/lib/mindee/product/delivery_note/delivery_note_v1_document.rb new file mode 100644 index 00000000..fa6bd474 --- /dev/null +++ b/lib/mindee/product/delivery_note/delivery_note_v1_document.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +require_relative '../../parsing' + +module Mindee + module Product + module DeliveryNote + # Delivery note API version 1.1 document data. + class DeliveryNoteV1Document < Mindee::Parsing::Common::Prediction + include Mindee::Parsing::Standard + # The address of the customer receiving the goods. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :customer_address + # The name of the customer receiving the goods. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :customer_name + # The date on which the delivery is scheduled to arrive. + # @return [Mindee::Parsing::Standard::DateField] + attr_reader :delivery_date + # A unique identifier for the delivery note. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :delivery_number + # The address of the supplier providing the goods. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :supplier_address + # The name of the supplier providing the goods. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :supplier_name + # The total monetary value of the goods being delivered. + # @return [Mindee::Parsing::Standard::AmountField] + attr_reader :total_amount + + # @param prediction [Hash] + # @param page_id [Integer, nil] + def initialize(prediction, page_id) + super() + @customer_address = StringField.new(prediction['customer_address'], page_id) + @customer_name = StringField.new(prediction['customer_name'], page_id) + @delivery_date = DateField.new(prediction['delivery_date'], page_id) + @delivery_number = StringField.new(prediction['delivery_number'], page_id) + @supplier_address = StringField.new(prediction['supplier_address'], page_id) + @supplier_name = StringField.new(prediction['supplier_name'], page_id) + @total_amount = AmountField.new(prediction['total_amount'], page_id) + end + + # @return [String] + def to_s + out_str = String.new + out_str << "\n:Delivery Date: #{@delivery_date}".rstrip + out_str << "\n:Delivery Number: #{@delivery_number}".rstrip + out_str << "\n:Supplier Name: #{@supplier_name}".rstrip + out_str << "\n:Supplier Address: #{@supplier_address}".rstrip + out_str << "\n:Customer Name: #{@customer_name}".rstrip + out_str << "\n:Customer Address: #{@customer_address}".rstrip + out_str << "\n:Total Amount: #{@total_amount}".rstrip + out_str[1..].to_s + end + end + end + end +end diff --git a/lib/mindee/product/delivery_note/delivery_note_v1_page.rb b/lib/mindee/product/delivery_note/delivery_note_v1_page.rb new file mode 100644 index 00000000..68385150 --- /dev/null +++ b/lib/mindee/product/delivery_note/delivery_note_v1_page.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require_relative '../../parsing' +require_relative 'delivery_note_v1_document' + +module Mindee + module Product + module DeliveryNote + # Delivery note API version 1.1 page data. + class DeliveryNoteV1Page < Mindee::Parsing::Common::Page + # @param prediction [Hash] + def initialize(prediction) + super(prediction) + @prediction = DeliveryNoteV1PagePrediction.new( + prediction['prediction'], + prediction['id'] + ) + end + end + + # Delivery note V1 page prediction. + class DeliveryNoteV1PagePrediction < DeliveryNoteV1Document + # @return [String] + def to_s + out_str = String.new + out_str << "\n#{super}" + out_str + end + end + end + end +end diff --git a/lib/mindee/product/financial_document/financial_document_v1_document.rb b/lib/mindee/product/financial_document/financial_document_v1_document.rb index a77a747f..be764785 100644 --- a/lib/mindee/product/financial_document/financial_document_v1_document.rb +++ b/lib/mindee/product/financial_document/financial_document_v1_document.rb @@ -6,7 +6,7 @@ module Mindee module Product module FinancialDocument - # Financial Document API version 1.10 document data. + # Financial Document API version 1.11 document data. class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The customer's address used for billing. diff --git a/lib/mindee/product/financial_document/financial_document_v1_page.rb b/lib/mindee/product/financial_document/financial_document_v1_page.rb index b64185a0..d9c2ddaf 100644 --- a/lib/mindee/product/financial_document/financial_document_v1_page.rb +++ b/lib/mindee/product/financial_document/financial_document_v1_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module FinancialDocument - # Financial Document API version 1.10 page data. + # Financial Document API version 1.11 page data. class FinancialDocumentV1Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb b/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb new file mode 100644 index 00000000..3c33bb82 --- /dev/null +++ b/lib/mindee/product/ind/indian_passport/indian_passport_v1.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require_relative '../../../parsing' +require_relative 'indian_passport_v1_document' +require_relative 'indian_passport_v1_page' + +module Mindee + module Product + module IND + # Passport - India module. + module IndianPassport + # Passport - India API version 1 inference prediction. + class IndianPassportV1 < Mindee::Parsing::Common::Inference + @endpoint_name = 'ind_passport' + @endpoint_version = '1' + + # @param prediction [Hash] + def initialize(prediction) + super + @prediction = IndianPassportV1Document.new(prediction['prediction'], nil) + @pages = [] + prediction['pages'].each do |page| + if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty? + @pages.push(IndianPassportV1Page.new(page)) + end + end + end + + class << self + # Name of the endpoint for this product. + # @return [String] + attr_reader :endpoint_name + # Version for this product. + # @return [String] + attr_reader :endpoint_version + end + end + end + end + end +end diff --git a/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb b/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb new file mode 100644 index 00000000..a946615e --- /dev/null +++ b/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +require_relative '../../../parsing' + +module Mindee + module Product + module IND + module IndianPassport + # Passport - India API version 1.0 document data. + class IndianPassportV1Document < Mindee::Parsing::Common::Prediction + include Mindee::Parsing::Standard + # The first line of the address of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :address1 + # The second line of the address of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :address2 + # The third line of the address of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :address3 + # The birth date of the passport holder, ISO format: YYYY-MM-DD. + # @return [Mindee::Parsing::Standard::DateField] + attr_reader :birth_date + # The birth place of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :birth_place + # ISO 3166-1 alpha-3 country code (3 letters format). + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :country + # The date when the passport will expire, ISO format: YYYY-MM-DD. + # @return [Mindee::Parsing::Standard::DateField] + attr_reader :expiry_date + # The file number of the passport document. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :file_number + # The gender of the passport holder. + # @return [Mindee::Parsing::Standard::ClassificationField] + attr_reader :gender + # The given names of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :given_names + # The identification number of the passport document. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :id_number + # The date when the passport was issued, ISO format: YYYY-MM-DD. + # @return [Mindee::Parsing::Standard::DateField] + attr_reader :issuance_date + # The place where the passport was issued. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :issuance_place + # The name of the legal guardian of the passport holder (if applicable). + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :legal_guardian + # The first line of the machine-readable zone (MRZ) of the passport document. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :mrz1 + # The second line of the machine-readable zone (MRZ) of the passport document. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :mrz2 + # The name of the mother of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :name_of_mother + # The name of the spouse of the passport holder (if applicable). + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :name_of_spouse + # The date of issue of the old passport (if applicable), ISO format: YYYY-MM-DD. + # @return [Mindee::Parsing::Standard::DateField] + attr_reader :old_passport_date_of_issue + # The number of the old passport (if applicable). + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :old_passport_number + # The place of issue of the old passport (if applicable). + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :old_passport_place_of_issue + # The page number of the passport document. + # @return [Mindee::Parsing::Standard::ClassificationField] + attr_reader :page_number + # The surname of the passport holder. + # @return [Mindee::Parsing::Standard::StringField] + attr_reader :surname + + # @param prediction [Hash] + # @param page_id [Integer, nil] + def initialize(prediction, page_id) + super() + @address1 = StringField.new(prediction['address1'], page_id) + @address2 = StringField.new(prediction['address2'], page_id) + @address3 = StringField.new(prediction['address3'], page_id) + @birth_date = DateField.new(prediction['birth_date'], page_id) + @birth_place = StringField.new(prediction['birth_place'], page_id) + @country = StringField.new(prediction['country'], page_id) + @expiry_date = DateField.new(prediction['expiry_date'], page_id) + @file_number = StringField.new(prediction['file_number'], page_id) + @gender = ClassificationField.new(prediction['gender'], page_id) + @given_names = StringField.new(prediction['given_names'], page_id) + @id_number = StringField.new(prediction['id_number'], page_id) + @issuance_date = DateField.new(prediction['issuance_date'], page_id) + @issuance_place = StringField.new(prediction['issuance_place'], page_id) + @legal_guardian = StringField.new(prediction['legal_guardian'], page_id) + @mrz1 = StringField.new(prediction['mrz1'], page_id) + @mrz2 = StringField.new(prediction['mrz2'], page_id) + @name_of_mother = StringField.new(prediction['name_of_mother'], page_id) + @name_of_spouse = StringField.new(prediction['name_of_spouse'], page_id) + @old_passport_date_of_issue = DateField.new(prediction['old_passport_date_of_issue'], page_id) + @old_passport_number = StringField.new(prediction['old_passport_number'], page_id) + @old_passport_place_of_issue = StringField.new(prediction['old_passport_place_of_issue'], page_id) + @page_number = ClassificationField.new(prediction['page_number'], page_id) + @surname = StringField.new(prediction['surname'], page_id) + end + + # @return [String] + def to_s + out_str = String.new + out_str << "\n:Page Number: #{@page_number}".rstrip + out_str << "\n:Country: #{@country}".rstrip + out_str << "\n:ID Number: #{@id_number}".rstrip + out_str << "\n:Given Names: #{@given_names}".rstrip + out_str << "\n:Surname: #{@surname}".rstrip + out_str << "\n:Birth Date: #{@birth_date}".rstrip + out_str << "\n:Birth Place: #{@birth_place}".rstrip + out_str << "\n:Issuance Place: #{@issuance_place}".rstrip + out_str << "\n:Gender: #{@gender}".rstrip + out_str << "\n:Issuance Date: #{@issuance_date}".rstrip + out_str << "\n:Expiry Date: #{@expiry_date}".rstrip + out_str << "\n:MRZ Line 1: #{@mrz1}".rstrip + out_str << "\n:MRZ Line 2: #{@mrz2}".rstrip + out_str << "\n:Legal Guardian: #{@legal_guardian}".rstrip + out_str << "\n:Name of Spouse: #{@name_of_spouse}".rstrip + out_str << "\n:Name of Mother: #{@name_of_mother}".rstrip + out_str << "\n:Old Passport Date of Issue: #{@old_passport_date_of_issue}".rstrip + out_str << "\n:Old Passport Number: #{@old_passport_number}".rstrip + out_str << "\n:Address Line 1: #{@address1}".rstrip + out_str << "\n:Address Line 2: #{@address2}".rstrip + out_str << "\n:Address Line 3: #{@address3}".rstrip + out_str << "\n:Old Passport Place of Issue: #{@old_passport_place_of_issue}".rstrip + out_str << "\n:File Number: #{@file_number}".rstrip + out_str[1..].to_s + end + end + end + end + end +end diff --git a/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb b/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb new file mode 100644 index 00000000..931b3376 --- /dev/null +++ b/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require_relative '../../../parsing' +require_relative 'indian_passport_v1_document' + +module Mindee + module Product + module IND + module IndianPassport + # Passport - India API version 1.0 page data. + class IndianPassportV1Page < Mindee::Parsing::Common::Page + # @param prediction [Hash] + def initialize(prediction) + super(prediction) + @prediction = IndianPassportV1PagePrediction.new( + prediction['prediction'], + prediction['id'] + ) + end + end + + # Passport - India V1 page prediction. + class IndianPassportV1PagePrediction < IndianPassportV1Document + # @return [String] + def to_s + out_str = String.new + out_str << "\n#{super}" + out_str + end + end + end + end + end +end diff --git a/lib/mindee/product/invoice/invoice_v4_document.rb b/lib/mindee/product/invoice/invoice_v4_document.rb index ae18b843..31b8e0b9 100644 --- a/lib/mindee/product/invoice/invoice_v4_document.rb +++ b/lib/mindee/product/invoice/invoice_v4_document.rb @@ -6,7 +6,7 @@ module Mindee module Product module Invoice - # Invoice API version 4.8 document data. + # Invoice API version 4.9 document data. class InvoiceV4Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The customer's address used for billing. diff --git a/lib/mindee/product/invoice/invoice_v4_page.rb b/lib/mindee/product/invoice/invoice_v4_page.rb index bb2f0fbc..438975e3 100644 --- a/lib/mindee/product/invoice/invoice_v4_page.rb +++ b/lib/mindee/product/invoice/invoice_v4_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module Invoice - # Invoice API version 4.8 page data. + # Invoice API version 4.9 page data. class InvoiceV4Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/resume/resume_v1_document.rb b/lib/mindee/product/resume/resume_v1_document.rb index 428c30e0..3765f6c4 100644 --- a/lib/mindee/product/resume/resume_v1_document.rb +++ b/lib/mindee/product/resume/resume_v1_document.rb @@ -10,7 +10,7 @@ module Mindee module Product module Resume - # Resume API version 1.0 document data. + # Resume API version 1.1 document data. class ResumeV1Document < Mindee::Parsing::Common::Prediction include Mindee::Parsing::Standard # The location information of the candidate, including city, state, and country. @@ -252,6 +252,7 @@ def professional_experiences_separator(char) out_str << ' ' out_str << "+#{char * 17}" out_str << "+#{char * 12}" + out_str << "+#{char * 38}" out_str << "+#{char * 27}" out_str << "+#{char * 11}" out_str << "+#{char * 10}" @@ -274,6 +275,7 @@ def professional_experiences_to_s out_str << "\n |" out_str << ' Contract Type |' out_str << ' Department |' + out_str << ' Description |' out_str << ' Employer |' out_str << ' End Month |' out_str << ' End Year |' diff --git a/lib/mindee/product/resume/resume_v1_page.rb b/lib/mindee/product/resume/resume_v1_page.rb index b71ceef0..138f4094 100644 --- a/lib/mindee/product/resume/resume_v1_page.rb +++ b/lib/mindee/product/resume/resume_v1_page.rb @@ -6,7 +6,7 @@ module Mindee module Product module Resume - # Resume API version 1.0 page data. + # Resume API version 1.1 page data. class ResumeV1Page < Mindee::Parsing::Common::Page # @param prediction [Hash] def initialize(prediction) diff --git a/lib/mindee/product/resume/resume_v1_professional_experience.rb b/lib/mindee/product/resume/resume_v1_professional_experience.rb index 12cf3c51..38ebfe59 100644 --- a/lib/mindee/product/resume/resume_v1_professional_experience.rb +++ b/lib/mindee/product/resume/resume_v1_professional_experience.rb @@ -14,6 +14,9 @@ class ResumeV1ProfessionalExperience < Mindee::Parsing::Standard::FeatureField # The specific department or division within the company. # @return [String] attr_reader :department + # The description of the professional experience as written in the document. + # @return [String] + attr_reader :description # The name of the company or organization. # @return [String] attr_reader :employer @@ -39,6 +42,7 @@ def initialize(prediction, page_id) super(prediction, page_id) @contract_type = prediction['contract_type'] @department = prediction['department'] + @description = prediction['description'] @employer = prediction['employer'] @end_month = prediction['end_month'] @end_year = prediction['end_year'] @@ -53,6 +57,7 @@ def printable_values printable = {} printable[:contract_type] = format_for_display(@contract_type) printable[:department] = format_for_display(@department) + printable[:description] = format_for_display(@description) printable[:employer] = format_for_display(@employer) printable[:end_month] = format_for_display(@end_month) printable[:end_year] = format_for_display(@end_year) @@ -67,6 +72,7 @@ def table_printable_values printable = {} printable[:contract_type] = format_for_display(@contract_type, 15) printable[:department] = format_for_display(@department, 10) + printable[:description] = format_for_display(@description, 36) printable[:employer] = format_for_display(@employer, 25) printable[:end_month] = format_for_display(@end_month, nil) printable[:end_year] = format_for_display(@end_year, nil) @@ -82,6 +88,7 @@ def to_table_line out_str = String.new out_str << format('| %- 16s', printable[:contract_type]) out_str << format('| %- 11s', printable[:department]) + out_str << format('| %- 37s', printable[:description]) out_str << format('| %- 26s', printable[:employer]) out_str << format('| %- 10s', printable[:end_month]) out_str << format('| %- 9s', printable[:end_year]) @@ -97,6 +104,7 @@ def to_s out_str = String.new out_str << "\n :Contract Type: #{printable[:contract_type]}" out_str << "\n :Department: #{printable[:department]}" + out_str << "\n :Description: #{printable[:description]}" out_str << "\n :Employer: #{printable[:employer]}" out_str << "\n :End Month: #{printable[:end_month]}" out_str << "\n :End Year: #{printable[:end_year]}" diff --git a/spec/data b/spec/data index e93f49c8..96f73126 160000 --- a/spec/data +++ b/spec/data @@ -1 +1 @@ -Subproject commit e93f49c8a78ba3d71c35a8fe2219d973cfcb1334 +Subproject commit 96f73126330ffffe6911d03b8c7fc13b8d301dfe diff --git a/spec/document/business_card_v1_spec.rb b/spec/document/business_card_v1_spec.rb new file mode 100644 index 00000000..b54e5bae --- /dev/null +++ b/spec/document/business_card_v1_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'json' +require 'mindee/product' +require 'mindee/parsing' + +require_relative '../data' + +DIR_BUSINESS_CARD_V1 = File.join(DATA_DIR, 'products', 'business_card', 'response_v1').freeze + +describe Mindee::Product::BusinessCard::BusinessCardV1 do + context 'A Business Card V1' do + it 'should load an empty document prediction' do + response = load_json(DIR_BUSINESS_CARD_V1, 'empty.json') + inference = Mindee::Parsing::Common::Document.new( + Mindee::Product::BusinessCard::BusinessCardV1, + response['document'] + ).inference + expect(inference.product.type).to eq('standard') + end + + it 'should load a complete document prediction' do + to_string = read_file(DIR_BUSINESS_CARD_V1, 'summary_full.rst') + response = load_json(DIR_BUSINESS_CARD_V1, 'complete.json') + document = Mindee::Parsing::Common::Document.new( + Mindee::Product::BusinessCard::BusinessCardV1, + response['document'] + ) + expect(document.to_s).to eq(to_string) + end + end +end diff --git a/spec/document/delivery_note_v1_spec.rb b/spec/document/delivery_note_v1_spec.rb new file mode 100644 index 00000000..bfcaa4b8 --- /dev/null +++ b/spec/document/delivery_note_v1_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'json' +require 'mindee/product' +require 'mindee/parsing' + +require_relative '../data' + +DIR_DELIVERY_NOTE_V1 = File.join(DATA_DIR, 'products', 'delivery_notes', 'response_v1').freeze + +describe Mindee::Product::DeliveryNote::DeliveryNoteV1 do + context 'A Delivery note V1' do + it 'should load an empty document prediction' do + response = load_json(DIR_DELIVERY_NOTE_V1, 'empty.json') + inference = Mindee::Parsing::Common::Document.new( + Mindee::Product::DeliveryNote::DeliveryNoteV1, + response['document'] + ).inference + expect(inference.product.type).to eq('standard') + end + + it 'should load a complete document prediction' do + to_string = read_file(DIR_DELIVERY_NOTE_V1, 'summary_full.rst') + response = load_json(DIR_DELIVERY_NOTE_V1, 'complete.json') + document = Mindee::Parsing::Common::Document.new( + Mindee::Product::DeliveryNote::DeliveryNoteV1, + response['document'] + ) + expect(document.to_s).to eq(to_string) + end + end +end diff --git a/spec/document/ind/indian_passport_v1_spec.rb b/spec/document/ind/indian_passport_v1_spec.rb new file mode 100644 index 00000000..6bd153a7 --- /dev/null +++ b/spec/document/ind/indian_passport_v1_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'json' +require 'mindee/product' +require 'mindee/parsing' + +require_relative '../../data' + +DIR_IND_INDIAN_PASSPORT_V1 = File.join(DATA_DIR, 'products', 'ind_passport', 'response_v1').freeze + +describe Mindee::Product::IND::IndianPassport::IndianPassportV1 do + context 'A Passport - India V1' do + it 'should load an empty document prediction' do + response = load_json(DIR_IND_INDIAN_PASSPORT_V1, 'empty.json') + inference = Mindee::Parsing::Common::Document.new( + Mindee::Product::IND::IndianPassport::IndianPassportV1, + response['document'] + ).inference + expect(inference.product.type).to eq('standard') + end + + it 'should load a complete document prediction' do + to_string = read_file(DIR_IND_INDIAN_PASSPORT_V1, 'summary_full.rst') + response = load_json(DIR_IND_INDIAN_PASSPORT_V1, 'complete.json') + document = Mindee::Parsing::Common::Document.new( + Mindee::Product::IND::IndianPassport::IndianPassportV1, + response['document'] + ) + expect(document.to_s).to eq(to_string) + end + end +end From 1279d44d6024ee150e4b12636e7fbe962591f660 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Thu, 14 Nov 2024 10:16:38 +0100 Subject: [PATCH 2/2] adjust retry delays --- lib/mindee/client.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/mindee/client.rb b/lib/mindee/client.rb index 9692b8bc..69cba257 100644 --- a/lib/mindee/client.rb +++ b/lib/mindee/client.rb @@ -149,8 +149,8 @@ def parse_queued( # * `:on_min_pages` Apply the operation only if document has at least this many pages. # @param cropper [Boolean, nil] Whether to include cropper results for each page. # This performs a cropping operation on the server and will increase response time. - # @param initial_delay_sec [Integer, Float] initial delay before polling. Defaults to 4. - # @param delay_sec [Integer, Float] delay between polling attempts. Defaults to 2. + # @param initial_delay_sec [Integer, Float] initial delay before polling. Defaults to 2. + # @param delay_sec [Integer, Float] delay between polling attempts. Defaults to 1.5. # @param max_retries [Integer] maximum amount of retries. Defaults to 60. # @return [Mindee::Parsing::Common::ApiResponse] def enqueue_and_parse( @@ -162,8 +162,8 @@ def enqueue_and_parse( close_file: true, page_options: nil, cropper: false, - initial_delay_sec: 4, - delay_sec: 2, + initial_delay_sec: 2, + delay_sec: 1.5, max_retries: 60 ) enqueue_res = enqueue( @@ -272,13 +272,13 @@ def create_endpoint(endpoint_name: '', account_name: '', version: '') # @param max_retries [Integer, nil] maximum amount of retries. def validate_async_params(initial_delay_sec, delay_sec, max_retries) min_delay_sec = 1 - min_initial_delay_sec = 2 + min_initial_delay_sec = 1 min_retries = 2 - raise "Cannot set auto-poll delay to less than #{min_delay_sec} seconds" if delay_sec < min_delay_sec + raise "Cannot set auto-poll delay to less than #{min_delay_sec} second(s)" if delay_sec < min_delay_sec if initial_delay_sec < min_initial_delay_sec - raise "Cannot set initial parsing delay to less than #{min_initial_delay_sec} seconds" + raise "Cannot set initial parsing delay to less than #{min_initial_delay_sec} second(s)" end - raise "Cannot set auto-poll delay to less than #{min_retries} seconds" if max_retries < min_retries + raise "Cannot set auto-poll retries to less than #{min_retries}" if max_retries < min_retries end # Creates an endpoint with the given values. Raises an error if the endpoint is invalid.