|
| 1 | +--- |
| 2 | +title: Bill of Lading OCR Ruby |
| 3 | +category: 622b805aaec68102ea7fcbc2 |
| 4 | +slug: ruby-bill-of-lading-ocr |
| 5 | +parentDoc: 6294d97ee723f1008d2ab28e |
| 6 | +--- |
| 7 | +The Ruby OCR SDK supports the [Bill of Lading API](https://platform.mindee.com/mindee/bill_of_lading). |
| 8 | + |
| 9 | +The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/default_sample.jpg) can be used for testing purposes. |
| 10 | + |
| 11 | + |
| 12 | +# Quick-Start |
| 13 | +```rb |
| 14 | +require 'mindee' |
| 15 | + |
| 16 | +# Init a new client |
| 17 | +mindee_client = Mindee::Client.new(api_key: 'my-api-key') |
| 18 | + |
| 19 | +# Load a file from disk |
| 20 | +input_source = mindee_client.source_from_path('/path/to/the/file.ext') |
| 21 | + |
| 22 | +# Parse the file |
| 23 | +result = mindee_client.enqueue_and_parse( |
| 24 | + input_source, |
| 25 | + Mindee::Product::BillOfLading::BillOfLadingV1 |
| 26 | +) |
| 27 | + |
| 28 | +# Print a full summary of the parsed data in RST format |
| 29 | +puts result.document |
| 30 | + |
| 31 | +# Print the document-level parsed data |
| 32 | +# puts result.document.inference.prediction |
| 33 | + |
| 34 | +``` |
| 35 | +# Field Types |
| 36 | +## Standard Fields |
| 37 | +These fields are generic and used in several products. |
| 38 | + |
| 39 | +### Basic Field |
| 40 | +Each prediction object contains a set of fields that inherit from the generic `Field` class. |
| 41 | +A typical `Field` object will have the following attributes: |
| 42 | + |
| 43 | +* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted. |
| 44 | +* **confidence** (Float, nil): the confidence score of the field prediction. |
| 45 | +* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. |
| 46 | +* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image. |
| 47 | +* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level. |
| 48 | +* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it). |
| 49 | + |
| 50 | + |
| 51 | +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. |
| 52 | + |
| 53 | +### Date Field |
| 54 | +Aside from the basic `Field` attributes, the date field `DateField` also implements the following: |
| 55 | + |
| 56 | +* **date_object** (`Date`): an accessible representation of the value as a JavaScript object. |
| 57 | + |
| 58 | +### String Field |
| 59 | +The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`). |
| 60 | + |
| 61 | +## Specific Fields |
| 62 | +Fields which are specific to this product; they are not used in any other product. |
| 63 | + |
| 64 | +### Carrier Field |
| 65 | +The shipping company responsible for transporting the goods. |
| 66 | + |
| 67 | +A `BillOfLadingV1Carrier` implements the following attributes: |
| 68 | + |
| 69 | +* `name` (String): The name of the carrier. |
| 70 | +* `professional_number` (String): The professional number of the carrier. |
| 71 | +* `scac` (String): The Standard Carrier Alpha Code (SCAC) of the carrier. |
| 72 | +Fields which are specific to this product; they are not used in any other product. |
| 73 | + |
| 74 | +### Consignee Field |
| 75 | +The party to whom the goods are being shipped. |
| 76 | + |
| 77 | +A `BillOfLadingV1Consignee` implements the following attributes: |
| 78 | + |
| 79 | +* `address` (String): The address of the consignee. |
| 80 | +* `email` (String): The email of the shipper. |
| 81 | +* `name` (String): The name of the consignee. |
| 82 | +* `phone` (String): The phone number of the consignee. |
| 83 | +Fields which are specific to this product; they are not used in any other product. |
| 84 | + |
| 85 | +### Items Field |
| 86 | +The goods being shipped. |
| 87 | + |
| 88 | +A `BillOfLadingV1CarrierItem` implements the following attributes: |
| 89 | + |
| 90 | +* `description` (String): A description of the item. |
| 91 | +* `gross_weight` (Float): The gross weight of the item. |
| 92 | +* `measurement` (Float): The measurement of the item. |
| 93 | +* `measurement_unit` (String): The unit of measurement for the measurement. |
| 94 | +* `quantity` (Float): The quantity of the item being shipped. |
| 95 | +* `weight_unit` (String): The unit of measurement for weights. |
| 96 | +Fields which are specific to this product; they are not used in any other product. |
| 97 | + |
| 98 | +### Notify Party Field |
| 99 | +The party to be notified of the arrival of the goods. |
| 100 | + |
| 101 | +A `BillOfLadingV1NotifyParty` implements the following attributes: |
| 102 | + |
| 103 | +* `address` (String): The address of the notify party. |
| 104 | +* `email` (String): The email of the shipper. |
| 105 | +* `name` (String): The name of the notify party. |
| 106 | +* `phone` (String): The phone number of the notify party. |
| 107 | +Fields which are specific to this product; they are not used in any other product. |
| 108 | + |
| 109 | +### Shipper Field |
| 110 | +The party responsible for shipping the goods. |
| 111 | + |
| 112 | +A `BillOfLadingV1Shipper` implements the following attributes: |
| 113 | + |
| 114 | +* `address` (String): The address of the shipper. |
| 115 | +* `email` (String): The email of the shipper. |
| 116 | +* `name` (String): The name of the shipper. |
| 117 | +* `phone` (String): The phone number of the shipper. |
| 118 | + |
| 119 | +# Attributes |
| 120 | +The following fields are extracted for Bill of Lading V1: |
| 121 | + |
| 122 | +## Bill of Lading Number |
| 123 | +**bill_of_lading_number** ([StringField](#string-field)): A unique identifier assigned to a Bill of Lading document. |
| 124 | + |
| 125 | +```rb |
| 126 | +puts result.document.inference.prediction.bill_of_lading_number.value |
| 127 | +``` |
| 128 | + |
| 129 | +## Carrier |
| 130 | +**carrier** ([BillOfLadingV1Carrier](#carrier-field)): The shipping company responsible for transporting the goods. |
| 131 | + |
| 132 | +```rb |
| 133 | +puts result.document.inference.prediction.carrier.value |
| 134 | +``` |
| 135 | + |
| 136 | +## Items |
| 137 | +**carrier_items** (Array<[BillOfLadingV1CarrierItem](#items-field)>): The goods being shipped. |
| 138 | + |
| 139 | +```rb |
| 140 | +for carrier_items_elem in result.document.inference.prediction.carrier_items do |
| 141 | + puts carrier_items_elem.value |
| 142 | +end |
| 143 | +``` |
| 144 | + |
| 145 | +## Consignee |
| 146 | +**consignee** ([BillOfLadingV1Consignee](#consignee-field)): The party to whom the goods are being shipped. |
| 147 | + |
| 148 | +```rb |
| 149 | +puts result.document.inference.prediction.consignee.value |
| 150 | +``` |
| 151 | + |
| 152 | +## Date of issue |
| 153 | +**date_of_issue** ([DateField](#date-field)): The date when the bill of lading is issued. |
| 154 | + |
| 155 | +```rb |
| 156 | +puts result.document.inference.prediction.date_of_issue.value |
| 157 | +``` |
| 158 | + |
| 159 | +## Departure Date |
| 160 | +**departure_date** ([DateField](#date-field)): The date when the vessel departs from the port of loading. |
| 161 | + |
| 162 | +```rb |
| 163 | +puts result.document.inference.prediction.departure_date.value |
| 164 | +``` |
| 165 | + |
| 166 | +## Notify Party |
| 167 | +**notify_party** ([BillOfLadingV1NotifyParty](#notify-party-field)): The party to be notified of the arrival of the goods. |
| 168 | + |
| 169 | +```rb |
| 170 | +puts result.document.inference.prediction.notify_party.value |
| 171 | +``` |
| 172 | + |
| 173 | +## Place of Delivery |
| 174 | +**place_of_delivery** ([StringField](#string-field)): The place where the goods are to be delivered. |
| 175 | + |
| 176 | +```rb |
| 177 | +puts result.document.inference.prediction.place_of_delivery.value |
| 178 | +``` |
| 179 | + |
| 180 | +## Port of Discharge |
| 181 | +**port_of_discharge** ([StringField](#string-field)): The port where the goods are unloaded from the vessel. |
| 182 | + |
| 183 | +```rb |
| 184 | +puts result.document.inference.prediction.port_of_discharge.value |
| 185 | +``` |
| 186 | + |
| 187 | +## Port of Loading |
| 188 | +**port_of_loading** ([StringField](#string-field)): The port where the goods are loaded onto the vessel. |
| 189 | + |
| 190 | +```rb |
| 191 | +puts result.document.inference.prediction.port_of_loading.value |
| 192 | +``` |
| 193 | + |
| 194 | +## Shipper |
| 195 | +**shipper** ([BillOfLadingV1Shipper](#shipper-field)): The party responsible for shipping the goods. |
| 196 | + |
| 197 | +```rb |
| 198 | +puts result.document.inference.prediction.shipper.value |
| 199 | +``` |
| 200 | + |
| 201 | +# Questions? |
| 202 | +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) |
0 commit comments