Bill of Lading OCR Java
The Java OCR SDK supports the Bill of Lading API.
The sample below can be used for testing purposes.
Quick-Start
import com.mindee.MindeeClient;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.common.AsyncPredictResponse;
import com.mindee.product.billoflading.BillOfLadingV1;
import java.io.File;
import java.io.IOException;
public class SimpleMindeeClient {
public static void main(String[] args) throws IOException, InterruptedException {
String apiKey = "my-api-key";
String filePath = "/path/to/the/file.ext";
// Init a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);
// Load a file from disk
LocalInputSource inputSource = new LocalInputSource(new File(filePath));
// Parse the file asynchronously
AsyncPredictResponse<BillOfLadingV1> response = mindeeClient.enqueueAndParse(
BillOfLadingV1.class,
inputSource
);
// Print a summary of the response
System.out.println(response.toString());
// Print a summary of the predictions
// System.out.println(response.getDocumentObj().toString());
// Print the document-level predictions
// System.out.println(response.getDocumentObj().getInference().getPrediction().toString());
// Print the page-level predictions
// response.getDocumentObj().getInference().getPages().forEach(
// page -> System.out.println(page.toString())
// );
}
}
Field Types
Standard Fields
These fields are generic and used in several products.
BaseField
Each prediction object contains a set of fields that inherit from the generic BaseField
class.
A typical BaseField
object will have the following attributes:
- confidence (
Double
): the confidence score of the field prediction. - boundingBox (
Polygon
): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. - polygon (
Polygon
): contains the relative vertices coordinates (polygon
extendsList<Point>
) of a polygon containing the field in the image. - pageId (
Integer
): the ID of the page, alwaysnull
when at document-level.
Note: A
Point
simply refers to a List ofDouble
.
Aside from the previous attributes, all basic fields have access to a custom toString
method that can be used to print their value as a string.
StringField
The text field StringField
extends BaseField
, but also implements:
- value (
String
): corresponds to the field value. - rawValue (
String
): corresponds to the raw value as it appears on the document.
DateField
The date field DateField
extends BaseField
, but also implements:
- value (
LocalDate
): an accessible representation of the value as a Java object. Can benull
.
Specific Fields
Fields which are specific to this product; they are not used in any other product.
Carrier Field
The shipping company responsible for transporting the goods.
A BillOfLadingV1Carrier
implements the following attributes:
- name (
String
): The name of the carrier. - professionalNumber (
String
): The professional number of the carrier. - scac (
String
): The Standard Carrier Alpha Code (SCAC) of the carrier.
Fields which are specific to this product; they are not used in any other product.
Consignee Field
The party to whom the goods are being shipped.
A BillOfLadingV1Consignee
implements the following attributes:
- address (
String
): The address of the consignee. - email (
String
): The email of the shipper. - name (
String
): The name of the consignee. - phone (
String
): The phone number of the consignee.
Fields which are specific to this product; they are not used in any other product.
Items Field
The goods being shipped.
A BillOfLadingV1CarrierItem
implements the following attributes:
- description (
String
): A description of the item. - grossWeight (
Double
): The gross weight of the item. - measurement (
Double
): The measurement of the item. - measurementUnit (
String
): The unit of measurement for the measurement. - quantity (
Double
): The quantity of the item being shipped. - weightUnit (
String
): The unit of measurement for weights.
Fields which are specific to this product; they are not used in any other product.
Notify Party Field
The party to be notified of the arrival of the goods.
A BillOfLadingV1NotifyParty
implements the following attributes:
- address (
String
): The address of the notify party. - email (
String
): The email of the shipper. - name (
String
): The name of the notify party. - phone (
String
): The phone number of the notify party.
Fields which are specific to this product; they are not used in any other product.
Shipper Field
The party responsible for shipping the goods.
A BillOfLadingV1Shipper
implements the following attributes:
- address (
String
): The address of the shipper. - email (
String
): The email of the shipper. - name (
String
): The name of the shipper. - phone (
String
): The phone number of the shipper.
Attributes
The following fields are extracted for Bill of Lading V1:
Bill of Lading Number
billOfLadingNumber: A unique identifier assigned to a Bill of Lading document.
System.out.println(result.getDocument().getInference().getPrediction().getBillOfLadingNumber().value);
Carrier
carrier(BillOfLadingV1Carrier): The shipping company responsible for transporting the goods.
System.out.println(result.getDocument().getInference().getPrediction().getCarrier().value);
Items
carrierItems(List<BillOfLadingV1CarrierItem>): The goods being shipped.
for (carrierItemsElem : result.getDocument().getInference().getPrediction().getCarrierItems())
{
System.out.println(carrierItemsElem.value);
}
Consignee
consignee(BillOfLadingV1Consignee): The party to whom the goods are being shipped.
System.out.println(result.getDocument().getInference().getPrediction().getConsignee().value);
Date of issue
dateOfIssue: The date when the bill of lading is issued.
System.out.println(result.getDocument().getInference().getPrediction().getDateOfIssue().value);
Departure Date
departureDate: The date when the vessel departs from the port of loading.
System.out.println(result.getDocument().getInference().getPrediction().getDepartureDate().value);
Notify Party
notifyParty(BillOfLadingV1NotifyParty): The party to be notified of the arrival of the goods.
System.out.println(result.getDocument().getInference().getPrediction().getNotifyParty().value);
Place of Delivery
placeOfDelivery: The place where the goods are to be delivered.
System.out.println(result.getDocument().getInference().getPrediction().getPlaceOfDelivery().value);
Port of Discharge
portOfDischarge: The port where the goods are unloaded from the vessel.
System.out.println(result.getDocument().getInference().getPrediction().getPortOfDischarge().value);
Port of Loading
portOfLoading: The port where the goods are loaded onto the vessel.
System.out.println(result.getDocument().getInference().getPrediction().getPortOfLoading().value);
Shipper
shipper(BillOfLadingV1Shipper): The party responsible for shipping the goods.
System.out.println(result.getDocument().getInference().getPrediction().getShipper().value);
Questions?
Updated 22 days ago