Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add support for business cards, delivery notes, indian passport & update resume, invoice & findoc #124

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions docs/business_card_v1.md
Original file line number Diff line number Diff line change
@@ -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: [email protected]
: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)
19 changes: 19 additions & 0 deletions docs/code_samples/business_card_v1_async.txt
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions docs/code_samples/delivery_notes_v1_async.txt
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions docs/code_samples/ind_passport_v1_async.txt
Original file line number Diff line number Diff line change
@@ -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
143 changes: 143 additions & 0 deletions docs/delivery_notes_v1.md
Original file line number Diff line number Diff line change
@@ -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)
Loading