diff --git a/README.md b/README.md index e4892efcc..c6ba7ef61 100644 --- a/README.md +++ b/README.md @@ -215,17 +215,12 @@ Complete details on the working of the library are available in the following gu * [Java Financial Document OCR](https://developers.mindee.com/docs/java-financial-document-ocr) * [Java Passport OCR](https://developers.mindee.com/docs/java-passport-ocr) * [Java Resume OCR](https://developers.mindee.com/docs/java-resume-ocr) -* [Java Proof of Address OCR](https://developers.mindee.com/docs/java-proof-of-address-ocr) * [Java International Id OCR](https://developers.mindee.com/docs/java-international-id-ocr) -* [Java EU License Plate OCR](https://developers.mindee.com/docs/java-eu-license-plate-ocr) -* [Java EU Driver License OCR](https://developers.mindee.com/docs/java-eu-driver-license-ocr) * [Java FR Bank Account Detail OCR](https://developers.mindee.com/docs/java-fr-bank-account-details-ocr) * [Java FR Carte Grise OCR](https://developers.mindee.com/docs/java-fr-carte-grise-ocr) * [Java FR Health Card OCR](https://developers.mindee.com/docs/java-fr-health-card-ocr) * [Java FR ID Card OCR](https://developers.mindee.com/docs/java-fr-carte-nationale-didentite-ocr) * [Java US Bank Check OCR](https://developers.mindee.com/docs/java-us-bank-check-ocr) -* [Java US W9 OCR](https://developers.mindee.com/docs/java-us-w9-ocr) -* [Java US Driver License OCR](https://developers.mindee.com/docs/java-us-driver-license-ocr) * [Java Barcode Reader API](https://developers.mindee.com/docs/java-barcode-reader-ocr) * [Java Cropper API](https://developers.mindee.com/docs/java-cropper-ocr) * [Java Invoice Splitter API](https://developers.mindee.com/docs/java-invoice-splitter-ocr) diff --git a/docs/code_samples/eu_driver_license_v1.txt b/docs/code_samples/eu_driver_license_v1.txt deleted file mode 100644 index 584336388..000000000 --- a/docs/code_samples/eu_driver_license_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.eu.driverlicense.DriverLicenseV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - DriverLicenseV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/expense_receipts_v4.txt b/docs/code_samples/expense_receipts_v4.txt deleted file mode 100644 index 74c82816e..000000000 --- a/docs/code_samples/expense_receipts_v4.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.receipt.ReceiptV4; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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 - PredictResponse response = mindeeClient.parse( - ReceiptV4.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/license_plates_v1.txt b/docs/code_samples/license_plates_v1.txt deleted file mode 100644 index d4cb057a7..000000000 --- a/docs/code_samples/license_plates_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.eu.licenseplate.LicensePlateV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - LicensePlateV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/proof_of_address_v1.txt b/docs/code_samples/proof_of_address_v1.txt deleted file mode 100644 index ad0b2c140..000000000 --- a/docs/code_samples/proof_of_address_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.proofofaddress.ProofOfAddressV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - ProofOfAddressV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/us_driver_license_v1.txt b/docs/code_samples/us_driver_license_v1.txt deleted file mode 100644 index f1c76f731..000000000 --- a/docs/code_samples/us_driver_license_v1.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.us.driverlicense.DriverLicenseV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - DriverLicenseV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/code_samples/us_w9_v1.txt b/docs/code_samples/us_w9_v1.txt deleted file mode 100644 index daa1720be..000000000 --- a/docs/code_samples/us_w9_v1.txt +++ /dev/null @@ -1,38 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.us.w9.W9V1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - W9V1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} diff --git a/docs/license_plates_v1.md b/docs/license_plates_v1.md deleted file mode 100644 index 1b8c54c13..000000000 --- a/docs/license_plates_v1.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: EU License Plate OCR Java -category: 622b805aaec68102ea7fcbc2 -slug: java-eu-license-plate-ocr -parentDoc: 631a062c3718850f3519b793 ---- -The Java OCR SDK supports the [License Plate API](https://platform.mindee.com/mindee/license_plates). - -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/license_plates/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. -![License Plate sample](https://github.com/mindee/client-lib-test-data/blob/main/products/license_plates/default_sample.jpg?raw=true) - -# Quick-Start -```java -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.eu.licenseplate.LicensePlateV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - LicensePlateV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} - -``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: f0f48232-2c80-4473-9c6f-88a09111b84d -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/license_plates v1.0 -:Rotation applied: No - -Prediction -========== -:License Plates: BY-323-YB - -Page Predictions -================ - -Page 0 ------- -:License Plates: BY-323-YB -``` - -# 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` extends `List`) of a polygon containing the field in the image. -* **pageId** (`Integer`): the ID of the page, always `null` when at document-level. - -> **Note:** A `Point` simply refers to a List of `Double`. - - -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. - -# Attributes -The following fields are extracted for License Plate V1: - -## License Plates -**licensePlates**: List of all license plates found in the image. - -```java -for (licensePlatesElem : result.getDocument().getInference().getPrediction().getLicensePlates()) -{ - System.out.println(licensePlatesElem.value); -} -``` - -# Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/proof_of_address_v1.md b/docs/proof_of_address_v1.md deleted file mode 100644 index a0053b58b..000000000 --- a/docs/proof_of_address_v1.md +++ /dev/null @@ -1,241 +0,0 @@ ---- -title: Proof of Address OCR Java -category: 622b805aaec68102ea7fcbc2 -slug: java-proof-of-address-ocr -parentDoc: 631a062c3718850f3519b793 ---- -The Java OCR SDK supports the [Proof of Address API](https://platform.mindee.com/mindee/proof_of_address). - -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. -![Proof of Address sample](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg?raw=true) - -# Quick-Start -```java -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.proofofaddress.ProofOfAddressV1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - ProofOfAddressV1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the document-level predictions -// System.out.println(response.getDocument().getInference().getPrediction().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} - -``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: 5d2361e9-405e-4fc1-8531-f92a3aef0c38 -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/proof_of_address v1.1 -:Rotation applied: Yes - -Prediction -========== -:Locale: en; en; USD; -:Issuer Name: PPL ELECTRIC UTILITIES -:Issuer Company Registrations: -:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175 -:Recipient Name: -:Recipient Company Registrations: -:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062 -:Dates: 2011-07-27 - 2011-07-06 - 2011-08-03 - 2011-07-27 - 2011-06-01 - 2011-07-01 - 2010-07-01 - 2010-08-01 - 2011-07-01 - 2009-08-01 - 2010-07-01 - 2011-07-27 -:Date of Issue: 2011-07-27 - -Page Predictions -================ - -Page 0 ------- -:Locale: en; en; USD; -:Issuer Name: PPL ELECTRIC UTILITIES -:Issuer Company Registrations: -:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175 -:Recipient Name: -:Recipient Company Registrations: -:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062 -:Dates: 2011-07-27 - 2011-07-06 - 2011-08-03 - 2011-07-27 - 2011-06-01 - 2011-07-01 - 2010-07-01 - 2010-08-01 - 2011-07-01 - 2009-08-01 - 2010-07-01 - 2011-07-27 -:Date of Issue: 2011-07-27 -``` - -# 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` extends `List`) of a polygon containing the field in the image. -* **pageId** (`Integer`): the ID of the page, always `null` when at document-level. - -> **Note:** A `Point` simply refers to a List of `Double`. - - -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. - - -### CompanyRegistrationField -Aside from the basic `BaseField` attributes, the company registration field `CompanyRegistrationField` also implements the following: - -* **type** (`String`): the type of company. -* **value** (`String`): corresponds to the field value. -* **toTableLine()**: a method that formats the data to fit in a .rst display. - -### 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 be `null`. - -### LocaleField -The locale field `LocaleField` extends `BaseField`, but also implements: - -* **value** (`LocalDate`): an accessible representation of the value as a Java object. Can be `null`. -* **language** (`String`): ISO 639-1 language code (e.g.: `en` for English). Can be `null`. -* **country** (`String`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great Britain"). Can be `null`. -* **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `null`. - -# Attributes -The following fields are extracted for Proof of Address V1: - -## Date of Issue -**date**: The date the document was issued. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getDate().value); -``` - -## Dates -**dates**: List of dates found on the document. - -```java -for (datesElem : result.getDocument().getInference().getPrediction().getDates()) -{ - System.out.println(datesElem.value); -} -``` - -## Issuer Address -**issuerAddress**: The address of the document's issuer. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getIssuerAddress().value); -``` - -## Issuer Company Registrations -**issuerCompanyRegistration**: List of company registrations found for the issuer. - -```java -for (issuerCompanyRegistrationElem : result.getDocument().getInference().getPrediction().getIssuerCompanyRegistration()) -{ - System.out.println(issuerCompanyRegistrationElem.value); -} -``` - -## Issuer Name -**issuerName**: The name of the person or company issuing the document. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getIssuerName().value); -``` - -## Locale -**locale**: The locale detected on the document. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getLocale().value); -``` - -## Recipient Address -**recipientAddress**: The address of the recipient. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getRecipientAddress().value); -``` - -## Recipient Company Registrations -**recipientCompanyRegistration**: List of company registrations found for the recipient. - -```java -for (recipientCompanyRegistrationElem : result.getDocument().getInference().getPrediction().getRecipientCompanyRegistration()) -{ - System.out.println(recipientCompanyRegistrationElem.value); -} -``` - -## Recipient Name -**recipientName**: The name of the person or company receiving the document. - -```java -System.out.println(result.getDocument().getInference().getPrediction().getRecipientName().value); -``` - -# Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/us_w9_v1.md b/docs/us_w9_v1.md deleted file mode 100644 index 4d50d08c2..000000000 --- a/docs/us_w9_v1.md +++ /dev/null @@ -1,259 +0,0 @@ ---- -title: US W9 OCR Java -category: 622b805aaec68102ea7fcbc2 -slug: java-us-w9-ocr -parentDoc: 631a062c3718850f3519b793 ---- -The Java OCR SDK supports the [W9 API](https://platform.mindee.com/mindee/us_w9). - -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. -![W9 sample](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg?raw=true) - -# Quick-Start -```java -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.product.us.w9.W9V1; -import java.io.File; -import java.io.IOException; - -public class SimpleMindeeClient { - - public static void main(String[] args) throws IOException { - 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(filePath); - - // Parse the file - PredictResponse response = mindeeClient.parse( - W9V1.class, - inputSource - ); - - // Print a summary of the response - System.out.println(response.toString()); - - // Print a summary of the predictions -// System.out.println(response.getDocument().toString()); - - // Print the page-level predictions -// response.getDocument().getInference().getPages().forEach( -// page -> System.out.println(page.toString()) -// ); - } - -} - -``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: d7c5b25f-e0d3-4491-af54-6183afa1aaab -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/us_w9 v1.0 -:Rotation applied: Yes - -Prediction -========== - -Page Predictions -================ - -Page 0 ------- -:Name: Stephen W Hawking -:SSN: 560758145 -:Address: Somewhere In Milky Way -:City State Zip: Probably Still At Cambridge P O Box CB1 -:Business Name: -:EIN: 942203664 -:Tax Classification: individual -:Tax Classification Other Details: -:W9 Revision Date: august 2013 -:Signature Position: Polygon with 4 points. -:Signature Date Position: -:Tax Classification LLC: -``` - -# 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` extends `List`) of a polygon containing the field in the image. -* **pageId** (`Integer`): the ID of the page, always `null` when at document-level. - -> **Note:** A `Point` simply refers to a List of `Double`. - - -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. - - -### PositionField -The position field `PositionField` implements: - -* **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` extends `List`) of a polygon containing the field in the image. -* **rectangle** (`Polygon`): a polygon with four points that may be oriented (even beyond canvas). -* **quadrangle** (`Polygon`): a free polygon made up of four points. - -## Page-Level Fields -Some fields are constrained to the page level, and so will not be retrievable at document level. - -# Attributes -The following fields are extracted for W9 V1: - -## Address -[📄](#page-level-fields "This field is only present on individual pages.")**address**: The street address (number, street, and apt. or suite no.) of the applicant. - -```java -for (StringField addressElem : result.getDocument().getInference().getPrediction().getAddress()) -{ - System.out.println(addressElem) - .value; -} -``` - -## Business Name -[📄](#page-level-fields "This field is only present on individual pages.")**businessName**: The business name or disregarded entity name, if different from Name. - -```java -for (StringField businessNameElem : result.getDocument().getInference().getPrediction().getBusinessName()) -{ - System.out.println(businessNameElem) - .value; -} -``` - -## City State Zip -[📄](#page-level-fields "This field is only present on individual pages.")**cityStateZip**: The city, state, and ZIP code of the applicant. - -```java -for (StringField cityStateZipElem : result.getDocument().getInference().getPrediction().getCityStateZip()) -{ - System.out.println(cityStateZipElem) - .value; -} -``` - -## EIN -[📄](#page-level-fields "This field is only present on individual pages.")**ein**: The employer identification number. - -```java -for (StringField einElem : result.getDocument().getInference().getPrediction().getEin()) -{ - System.out.println(einElem) - .value; -} -``` - -## Name -[📄](#page-level-fields "This field is only present on individual pages.")**name**: Name as shown on the applicant's income tax return. - -```java -for (StringField nameElem : result.getDocument().getInference().getPrediction().getName()) -{ - System.out.println(nameElem) - .value; -} -``` - -## Signature Date Position -[📄](#page-level-fields "This field is only present on individual pages.")**signatureDatePosition**: Position of the signature date on the document. - -```java -for (PositionField signatureDatePositionElem : result.getDocument().getInference().getPrediction().getSignatureDatePosition()) -{ - System.out.println(signatureDatePositionElem).polygon; -} -``` - -## Signature Position -[📄](#page-level-fields "This field is only present on individual pages.")**signaturePosition**: Position of the signature on the document. - -```java -for (PositionField signaturePositionElem : result.getDocument().getInference().getPrediction().getSignaturePosition()) -{ - System.out.println(signaturePositionElem).polygon; -} -``` - -## SSN -[📄](#page-level-fields "This field is only present on individual pages.")**ssn**: The applicant's social security number. - -```java -for (StringField ssnElem : result.getDocument().getInference().getPrediction().getSsn()) -{ - System.out.println(ssnElem) - .value; -} -``` - -## Tax Classification -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassification**: The federal tax classification, which can vary depending on the revision date. - -```java -for (StringField taxClassificationElem : result.getDocument().getInference().getPrediction().getTaxClassification()) -{ - System.out.println(taxClassificationElem) - .value; -} -``` - -## Tax Classification LLC -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassificationLlc**: Depending on revision year, among S, C, P or D for Limited Liability Company Classification. - -```java -for (StringField taxClassificationLlcElem : result.getDocument().getInference().getPrediction().getTaxClassificationLlc()) -{ - System.out.println(taxClassificationLlcElem) - .value; -} -``` - -## Tax Classification Other Details -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassificationOtherDetails**: Tax Classification Other Details. - -```java -for (StringField taxClassificationOtherDetailsElem : result.getDocument().getInference().getPrediction().getTaxClassificationOtherDetails()) -{ - System.out.println(taxClassificationOtherDetailsElem) - .value; -} -``` - -## W9 Revision Date -[📄](#page-level-fields "This field is only present on individual pages.")**w9RevisionDate**: The Revision month and year of the W9 form. - -```java -for (StringField w9RevisionDateElem : result.getDocument().getInference().getPrediction().getW9RevisionDate()) -{ - System.out.println(w9RevisionDateElem) - .value; -} -``` - -# Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java index 3a436608a..1e5908286 100644 --- a/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java +++ b/src/main/java/com/mindee/cli/CommandLineInterfaceProducts.java @@ -25,7 +25,6 @@ import com.mindee.product.us.bankcheck.BankCheckV1; import com.mindee.product.us.healthcarecard.HealthcareCardV1; import com.mindee.product.us.usmail.UsMailV3; -import com.mindee.product.us.w9.W9V1; import java.io.File; import java.io.IOException; import picocli.CommandLine; @@ -242,12 +241,4 @@ void usMailV3Method( ) throws IOException, InterruptedException { System.out.println(processor.standardProductAsyncOutput(UsMailV3.class, file)); } - - @CommandLine.Command(name = "us-w9", description = "Parse using US W9") - void w9V1Method( - @CommandLine.Parameters(index = "0", paramLabel = "", scope = CommandLine.ScopeType.LOCAL) - File file - ) throws IOException, InterruptedException { - System.out.println(processor.standardProductOutput(W9V1.class, file)); - } } diff --git a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java deleted file mode 100644 index 65ca81575..000000000 --- a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.eu.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Driver License API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "eu_driver_license", version = "1") -public class DriverLicenseV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Document.java b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Document.java deleted file mode 100644 index ca16e8cdf..000000000 --- a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Document.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.mindee.product.eu.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Driver License API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class DriverLicenseV1Document extends Prediction { - - /** - * EU driver license holders address - */ - @JsonProperty("address") - protected StringField address; - /** - * EU driver license holders categories - */ - @JsonProperty("category") - protected StringField category; - /** - * Country code extracted as a string. - */ - @JsonProperty("country_code") - protected StringField countryCode; - /** - * The date of birth of the document holder - */ - @JsonProperty("date_of_birth") - protected DateField dateOfBirth; - /** - * ID number of the Document. - */ - @JsonProperty("document_id") - protected StringField documentId; - /** - * Date the document expires - */ - @JsonProperty("expiry_date") - protected DateField expiryDate; - /** - * First name(s) of the driver license holder - */ - @JsonProperty("first_name") - protected StringField firstName; - /** - * Authority that issued the document - */ - @JsonProperty("issue_authority") - protected StringField issueAuthority; - /** - * Date the document was issued - */ - @JsonProperty("issue_date") - protected DateField issueDate; - /** - * Last name of the driver license holder. - */ - @JsonProperty("last_name") - protected StringField lastName; - /** - * Machine-readable license number - */ - @JsonProperty("mrz") - protected StringField mrz; - /** - * Place where the driver license holder was born - */ - @JsonProperty("place_of_birth") - protected StringField placeOfBirth; - - @Override - public boolean isEmpty() { - return ( - this.countryCode == null - && this.documentId == null - && this.category == null - && this.lastName == null - && this.firstName == null - && this.dateOfBirth == null - && this.placeOfBirth == null - && this.expiryDate == null - && this.issueDate == null - && this.issueAuthority == null - && this.mrz == null - && this.address == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Country Code: %s%n", this.getCountryCode()) - ); - outStr.append( - String.format(":Document ID: %s%n", this.getDocumentId()) - ); - outStr.append( - String.format(":Driver License Category: %s%n", this.getCategory()) - ); - outStr.append( - String.format(":Last Name: %s%n", this.getLastName()) - ); - outStr.append( - String.format(":First Name: %s%n", this.getFirstName()) - ); - outStr.append( - String.format(":Date Of Birth: %s%n", this.getDateOfBirth()) - ); - outStr.append( - String.format(":Place Of Birth: %s%n", this.getPlaceOfBirth()) - ); - outStr.append( - String.format(":Expiry Date: %s%n", this.getExpiryDate()) - ); - outStr.append( - String.format(":Issue Date: %s%n", this.getIssueDate()) - ); - outStr.append( - String.format(":Issue Authority: %s%n", this.getIssueAuthority()) - ); - outStr.append( - String.format(":MRZ: %s%n", this.getMrz()) - ); - outStr.append( - String.format(":Address: %s%n", this.getAddress()) - ); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Page.java b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Page.java deleted file mode 100644 index 54d6b8f3c..000000000 --- a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Page.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.mindee.product.eu.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.PositionField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Driver License API version 1.0 page data. - */ -@Getter -@EqualsAndHashCode(callSuper = true) -@JsonIgnoreProperties(ignoreUnknown = true) -public class DriverLicenseV1Page extends DriverLicenseV1Document { - - /** - * Has a photo of the EU driver license holder - */ - @JsonProperty("photo") - protected PositionField photo; - /** - * Has a signature of the EU driver license holder - */ - @JsonProperty("signature") - protected PositionField signature; - - @Override - public boolean isEmpty() { - return ( - this.photo == null - && this.signature == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Photo: %s%n", this.getPhoto()) - ); - outStr.append( - String.format(":Signature: %s%n", this.getSignature()) - ); - outStr.append(super.toString()); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1.java b/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1.java deleted file mode 100644 index 381957895..000000000 --- a/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.eu.licenseplate; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * License Plate API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "license_plates", version = "1") -public class LicensePlateV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1Document.java b/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1Document.java deleted file mode 100644 index f8827c9d1..000000000 --- a/src/main/java/com/mindee/product/eu/licenseplate/LicensePlateV1Document.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.mindee.product.eu.licenseplate; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * License Plate API version 1.1 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class LicensePlateV1Document extends Prediction { - - /** - * List of all license plates found in the image. - */ - @JsonProperty("license_plates") - protected List licensePlates = new ArrayList<>(); - - @Override - public boolean isEmpty() { - return ( - (this.licensePlates == null || this.licensePlates.isEmpty()) - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - String licensePlates = SummaryHelper.arrayToString( - this.getLicensePlates(), - "%n " - ); - outStr.append( - String.format(":License Plates: %s%n", licensePlates) - ); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1.java b/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1.java deleted file mode 100644 index d569f8943..000000000 --- a/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.proofofaddress; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Proof of Address API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "proof_of_address", version = "1") -public class ProofOfAddressV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1Document.java b/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1Document.java deleted file mode 100644 index b29ad3bce..000000000 --- a/src/main/java/com/mindee/product/proofofaddress/ProofOfAddressV1Document.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.mindee.product.proofofaddress; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.CompanyRegistrationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.LocaleField; -import com.mindee.parsing.standard.StringField; -import java.util.ArrayList; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Proof of Address API version 1.1 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class ProofOfAddressV1Document extends Prediction { - - /** - * The date the document was issued. - */ - @JsonProperty("date") - protected DateField date; - /** - * List of dates found on the document. - */ - @JsonProperty("dates") - protected List dates = new ArrayList<>(); - /** - * The address of the document's issuer. - */ - @JsonProperty("issuer_address") - protected StringField issuerAddress; - /** - * List of company registrations found for the issuer. - */ - @JsonProperty("issuer_company_registration") - protected List issuerCompanyRegistration = new ArrayList<>(); - /** - * The name of the person or company issuing the document. - */ - @JsonProperty("issuer_name") - protected StringField issuerName; - /** - * The locale detected on the document. - */ - @JsonProperty("locale") - protected LocaleField locale; - /** - * The address of the recipient. - */ - @JsonProperty("recipient_address") - protected StringField recipientAddress; - /** - * List of company registrations found for the recipient. - */ - @JsonProperty("recipient_company_registration") - protected List recipientCompanyRegistration = new ArrayList<>(); - /** - * The name of the person or company receiving the document. - */ - @JsonProperty("recipient_name") - protected StringField recipientName; - - @Override - public boolean isEmpty() { - return ( - this.locale == null - && this.issuerName == null - && (this.issuerCompanyRegistration == null || this.issuerCompanyRegistration.isEmpty()) - && this.issuerAddress == null - && this.recipientName == null - && (this.recipientCompanyRegistration == null || this.recipientCompanyRegistration.isEmpty()) - && this.recipientAddress == null - && (this.dates == null || this.dates.isEmpty()) - && this.date == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Locale: %s%n", this.getLocale()) - ); - outStr.append( - String.format(":Issuer Name: %s%n", this.getIssuerName()) - ); - String issuerCompanyRegistration = SummaryHelper.arrayToString( - this.getIssuerCompanyRegistration(), - "%n " - ); - outStr.append( - String.format(":Issuer Company Registrations: %s%n", issuerCompanyRegistration) - ); - outStr.append( - String.format(":Issuer Address: %s%n", this.getIssuerAddress()) - ); - outStr.append( - String.format(":Recipient Name: %s%n", this.getRecipientName()) - ); - String recipientCompanyRegistration = SummaryHelper.arrayToString( - this.getRecipientCompanyRegistration(), - "%n " - ); - outStr.append( - String.format(":Recipient Company Registrations: %s%n", recipientCompanyRegistration) - ); - outStr.append( - String.format(":Recipient Address: %s%n", this.getRecipientAddress()) - ); - String dates = SummaryHelper.arrayToString( - this.getDates(), - "%n " - ); - outStr.append( - String.format(":Dates: %s%n", dates) - ); - outStr.append( - String.format(":Date of Issue: %s%n", this.getDate()) - ); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV4.java b/src/main/java/com/mindee/product/receipt/ReceiptV4.java deleted file mode 100644 index 59665c3b8..000000000 --- a/src/main/java/com/mindee/product/receipt/ReceiptV4.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.receipt; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * The receipt V4 inference. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "expense_receipts", version = "4") -public class ReceiptV4 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/receipt/ReceiptV4Document.java b/src/main/java/com/mindee/product/receipt/ReceiptV4Document.java deleted file mode 100644 index 669e23543..000000000 --- a/src/main/java/com/mindee/product/receipt/ReceiptV4Document.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.mindee.product.receipt; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.AmountField; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.LocaleField; -import com.mindee.parsing.standard.StringField; -import com.mindee.parsing.standard.TaxField; -import com.mindee.parsing.standard.TaxesDeserializer; -import java.util.List; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Document data for Receipt, API version 4. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class ReceiptV4Document extends Prediction { - - /** - * Where the purchase was made, the language, and the currency. - */ - @JsonProperty("locale") - private LocaleField localeField; - /** - * The purchase date. - */ - @JsonProperty("date") - private DateField date; - /** - * The time of the purchase. - */ - @JsonProperty("time") - private StringField time; - /** - * The type of purchase among a certain list of it (see official documentation for the list). - */ - @JsonProperty("category") - private ClassificationField category; - /** - * The subcategory of purchase among a certain list of it (see official documentation for the list). - */ - @JsonProperty("subcategory") - private ClassificationField subCategory; - /** - * The type of the parsed document (see official documentation for the list). - */ - @JsonProperty("document_type") - private ClassificationField documentType; - /** - * Merchant's name as seen on the receipt. - */ - @JsonProperty("supplier") - private StringField supplierName; - /** - * List of taxes detected on the receipt. - */ - @JsonProperty("taxes") - @JsonDeserialize(using = TaxesDeserializer.class) - private List taxes; - /** - * total spent including taxes, discounts, fees, tips, and gratuity. - */ - @JsonProperty("total_amount") - private AmountField totalAmount; - /** - * Total amount of the purchase excluding taxes. - */ - @JsonProperty("total_net") - private AmountField totalNet; - /** - * Total tax amount of the purchase. - */ - @JsonProperty("total_tax") - private AmountField totalTax; - /** - * Total amount of tip and gratuity. - */ - @JsonProperty("tip") - private AmountField tip; - - @Override - public String toString() { - - String summary = - String.format(":Locale: %s%n", this.getLocaleField()) - + String.format(":Date: %s%n", this.getDate()) - + String.format(":Category: %s%n", this.getCategory()) - + String.format(":Subcategory: %s%n", this.getSubCategory()) - + String.format(":Document type: %s%n", this.getDocumentType()) - + String.format(":Time: %s%n", this.getTime()) - + String.format(":Supplier name: %s%n", this.getSupplierName()) - + String.format(":Taxes: %s%n", this.taxes.toString()) - + String.format(":Total net: %s%n", this.getTotalNet()) - + String.format(":Total tax: %s%n", this.getTotalTax()) - + String.format(":Tip: %s%n", this.getTip()) - + String.format(":Total amount: %s%n", this.getTotalAmount()); - - return SummaryHelper.cleanSummary(summary); - } - - @Override - public boolean isEmpty() { - return ( - this.localeField == null - && this.category == null - && this.subCategory == null - && this.documentType == null - && this.date == null - && this.time == null - && this.totalAmount == null - && this.totalNet == null - && this.totalTax == null - && this.tip == null - && (this.taxes == null || this.taxes.isEmpty()) - && this.supplierName == null - ); - } -} diff --git a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1.java b/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1.java deleted file mode 100644 index b9fd1ffd2..000000000 --- a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.us.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * Driver License API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "us_driver_license", version = "1") -public class DriverLicenseV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Document.java b/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Document.java deleted file mode 100644 index e8335eac1..000000000 --- a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Document.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.mindee.product.us.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.common.Prediction; -import com.mindee.parsing.standard.DateField; -import com.mindee.parsing.standard.StringField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Driver License API version 1.1 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class DriverLicenseV1Document extends Prediction { - - /** - * US driver license holders address - */ - @JsonProperty("address") - protected StringField address; - /** - * US driver license holders date of birth - */ - @JsonProperty("date_of_birth") - protected DateField dateOfBirth; - /** - * Document Discriminator Number of the US Driver License - */ - @JsonProperty("dd_number") - protected StringField ddNumber; - /** - * US driver license holders class - */ - @JsonProperty("dl_class") - protected StringField dlClass; - /** - * ID number of the US Driver License. - */ - @JsonProperty("driver_license_id") - protected StringField driverLicenseId; - /** - * US driver license holders endorsements - */ - @JsonProperty("endorsements") - protected StringField endorsements; - /** - * Date on which the documents expires. - */ - @JsonProperty("expiry_date") - protected DateField expiryDate; - /** - * US driver license holders eye colour - */ - @JsonProperty("eye_color") - protected StringField eyeColor; - /** - * US driver license holders first name(s) - */ - @JsonProperty("first_name") - protected StringField firstName; - /** - * US driver license holders hair colour - */ - @JsonProperty("hair_color") - protected StringField hairColor; - /** - * US driver license holders hight - */ - @JsonProperty("height") - protected StringField height; - /** - * Date on which the documents was issued. - */ - @JsonProperty("issued_date") - protected DateField issuedDate; - /** - * US driver license holders last name - */ - @JsonProperty("last_name") - protected StringField lastName; - /** - * US driver license holders restrictions - */ - @JsonProperty("restrictions") - protected StringField restrictions; - /** - * US driver license holders gender - */ - @JsonProperty("sex") - protected StringField sex; - /** - * US State - */ - @JsonProperty("state") - protected StringField state; - /** - * US driver license holders weight - */ - @JsonProperty("weight") - protected StringField weight; - - @Override - public boolean isEmpty() { - return ( - this.state == null - && this.driverLicenseId == null - && this.expiryDate == null - && this.issuedDate == null - && this.lastName == null - && this.firstName == null - && this.address == null - && this.dateOfBirth == null - && this.restrictions == null - && this.endorsements == null - && this.dlClass == null - && this.sex == null - && this.height == null - && this.weight == null - && this.hairColor == null - && this.eyeColor == null - && this.ddNumber == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":State: %s%n", this.getState()) - ); - outStr.append( - String.format(":Driver License ID: %s%n", this.getDriverLicenseId()) - ); - outStr.append( - String.format(":Expiry Date: %s%n", this.getExpiryDate()) - ); - outStr.append( - String.format(":Date Of Issue: %s%n", this.getIssuedDate()) - ); - outStr.append( - String.format(":Last Name: %s%n", this.getLastName()) - ); - outStr.append( - String.format(":First Name: %s%n", this.getFirstName()) - ); - outStr.append( - String.format(":Address: %s%n", this.getAddress()) - ); - outStr.append( - String.format(":Date Of Birth: %s%n", this.getDateOfBirth()) - ); - outStr.append( - String.format(":Restrictions: %s%n", this.getRestrictions()) - ); - outStr.append( - String.format(":Endorsements: %s%n", this.getEndorsements()) - ); - outStr.append( - String.format(":Driver License Class: %s%n", this.getDlClass()) - ); - outStr.append( - String.format(":Sex: %s%n", this.getSex()) - ); - outStr.append( - String.format(":Height: %s%n", this.getHeight()) - ); - outStr.append( - String.format(":Weight: %s%n", this.getWeight()) - ); - outStr.append( - String.format(":Hair Color: %s%n", this.getHairColor()) - ); - outStr.append( - String.format(":Eye Color: %s%n", this.getEyeColor()) - ); - outStr.append( - String.format(":Document Discriminator: %s%n", this.getDdNumber()) - ); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Page.java b/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Page.java deleted file mode 100644 index 8e97c59b2..000000000 --- a/src/main/java/com/mindee/product/us/driverlicense/DriverLicenseV1Page.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.mindee.product.us.driverlicense; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.PositionField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * Driver License API version 1.1 page data. - */ -@Getter -@EqualsAndHashCode(callSuper = true) -@JsonIgnoreProperties(ignoreUnknown = true) -public class DriverLicenseV1Page extends DriverLicenseV1Document { - - /** - * Has a photo of the US driver license holder - */ - @JsonProperty("photo") - protected PositionField photo; - /** - * Has a signature of the US driver license holder - */ - @JsonProperty("signature") - protected PositionField signature; - - @Override - public boolean isEmpty() { - return ( - this.photo == null - && this.signature == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Photo: %s%n", this.getPhoto()) - ); - outStr.append( - String.format(":Signature: %s%n", this.getSignature()) - ); - outStr.append(super.toString()); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/us/w9/W9V1.java b/src/main/java/com/mindee/product/us/w9/W9V1.java deleted file mode 100644 index c7d19e3a9..000000000 --- a/src/main/java/com/mindee/product/us/w9/W9V1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.us.w9; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * W9 API version 1 inference prediction. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "us_w9", version = "1") -public class W9V1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/us/w9/W9V1Document.java b/src/main/java/com/mindee/product/us/w9/W9V1Document.java deleted file mode 100644 index 3cfc6b833..000000000 --- a/src/main/java/com/mindee/product/us/w9/W9V1Document.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mindee.product.us.w9; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.parsing.common.Prediction; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * W9 API version 1.0 document data. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class W9V1Document extends Prediction { - - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public String toString() { - return ""; - } -} diff --git a/src/main/java/com/mindee/product/us/w9/W9V1Page.java b/src/main/java/com/mindee/product/us/w9/W9V1Page.java deleted file mode 100644 index cb6111595..000000000 --- a/src/main/java/com/mindee/product/us/w9/W9V1Page.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.mindee.product.us.w9; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; -import com.mindee.parsing.standard.PositionField; -import com.mindee.parsing.standard.StringField; -import lombok.EqualsAndHashCode; -import lombok.Getter; - -/** - * W9 API version 1.0 page data. - */ -@Getter -@EqualsAndHashCode(callSuper = true) -@JsonIgnoreProperties(ignoreUnknown = true) -public class W9V1Page extends W9V1Document { - - /** - * The street address (number, street, and apt. or suite no.) of the applicant. - */ - @JsonProperty("address") - protected StringField address; - /** - * The business name or disregarded entity name, if different from Name. - */ - @JsonProperty("business_name") - protected StringField businessName; - /** - * The city, state, and ZIP code of the applicant. - */ - @JsonProperty("city_state_zip") - protected StringField cityStateZip; - /** - * The employer identification number. - */ - @JsonProperty("ein") - protected StringField ein; - /** - * Name as shown on the applicant's income tax return. - */ - @JsonProperty("name") - protected StringField name; - /** - * Position of the signature date on the document. - */ - @JsonProperty("signature_date_position") - protected PositionField signatureDatePosition; - /** - * Position of the signature on the document. - */ - @JsonProperty("signature_position") - protected PositionField signaturePosition; - /** - * The applicant's social security number. - */ - @JsonProperty("ssn") - protected StringField ssn; - /** - * The federal tax classification, which can vary depending on the revision date. - */ - @JsonProperty("tax_classification") - protected StringField taxClassification; - /** - * Depending on revision year, among S, C, P or D for Limited Liability Company Classification. - */ - @JsonProperty("tax_classification_llc") - protected StringField taxClassificationLlc; - /** - * Tax Classification Other Details. - */ - @JsonProperty("tax_classification_other_details") - protected StringField taxClassificationOtherDetails; - /** - * The Revision month and year of the W9 form. - */ - @JsonProperty("w9_revision_date") - protected StringField w9RevisionDate; - - @Override - public boolean isEmpty() { - return ( - this.name == null - && this.ssn == null - && this.address == null - && this.cityStateZip == null - && this.businessName == null - && this.ein == null - && this.taxClassification == null - && this.taxClassificationOtherDetails == null - && this.w9RevisionDate == null - && this.signaturePosition == null - && this.signatureDatePosition == null - && this.taxClassificationLlc == null - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Name: %s%n", this.getName()) - ); - outStr.append( - String.format(":SSN: %s%n", this.getSsn()) - ); - outStr.append( - String.format(":Address: %s%n", this.getAddress()) - ); - outStr.append( - String.format(":City State Zip: %s%n", this.getCityStateZip()) - ); - outStr.append( - String.format(":Business Name: %s%n", this.getBusinessName()) - ); - outStr.append( - String.format(":EIN: %s%n", this.getEin()) - ); - outStr.append( - String.format(":Tax Classification: %s%n", this.getTaxClassification()) - ); - outStr.append( - String.format(":Tax Classification Other Details: %s%n", this.getTaxClassificationOtherDetails()) - ); - outStr.append( - String.format(":W9 Revision Date: %s%n", this.getW9RevisionDate()) - ); - outStr.append( - String.format(":Signature Position: %s%n", this.getSignaturePosition()) - ); - outStr.append( - String.format(":Signature Date Position: %s%n", this.getSignatureDatePosition()) - ); - outStr.append( - String.format(":Tax Classification LLC: %s%n", this.getTaxClassificationLlc()) - ); - outStr.append(super.toString()); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/test/java/com/mindee/parsing/common/CropperTest.java b/src/test/java/com/mindee/parsing/common/CropperTest.java index 2fc48f5e3..48b00434a 100644 --- a/src/test/java/com/mindee/parsing/common/CropperTest.java +++ b/src/test/java/com/mindee/parsing/common/CropperTest.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.mindee.parsing.standard.PositionField; -import com.mindee.product.receipt.ReceiptV4; -import com.mindee.product.receipt.ReceiptV4Document; +import com.mindee.product.receipt.ReceiptV5; +import com.mindee.product.receipt.ReceiptV5Document; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.File; @@ -13,14 +13,14 @@ public class CropperTest { - private List> loadResult() throws IOException { + private List> loadResult() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.findAndRegisterModules(); JavaType type = objectMapper.getTypeFactory().constructParametricType( PredictResponse.class, - ReceiptV4.class); - PredictResponse prediction = objectMapper.readValue( + ReceiptV5.class); + PredictResponse prediction = objectMapper.readValue( new File("src/test/resources/extras/cropper/complete.json"), type); @@ -29,7 +29,7 @@ private List> loadResult() throws IOException { @Test void should_GetCropperResult() throws IOException { - List> pages = loadResult(); + List> pages = loadResult(); List cropping = pages.get(0).getExtras().getCropper().getCropping(); Assertions.assertEquals("Polygon with 24 points.", cropping.get(0).toString()); } diff --git a/src/test/java/com/mindee/parsing/common/OcrTest.java b/src/test/java/com/mindee/parsing/common/OcrTest.java index a57a48180..3a9cd261a 100644 --- a/src/test/java/com/mindee/parsing/common/OcrTest.java +++ b/src/test/java/com/mindee/parsing/common/OcrTest.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.product.receipt.ReceiptV4; import com.mindee.parsing.common.ocr.Word; import com.mindee.parsing.common.ocr.Ocr; +import com.mindee.product.receipt.ReceiptV5; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.File; @@ -21,8 +21,8 @@ private Ocr loadResult() throws IOException { JavaType type = objectMapper.getTypeFactory().constructParametricType( PredictResponse.class, - ReceiptV4.class); - PredictResponse prediction = objectMapper.readValue( + ReceiptV5.class); + PredictResponse prediction = objectMapper.readValue( new File("src/test/resources/extras/ocr/complete.json"), type); diff --git a/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java b/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java deleted file mode 100644 index 71983ec8b..000000000 --- a/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.mindee.product.eu.driverlicense; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.product.ProductTestHelper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -/** - * Unit tests for DriverLicenseV1. - */ -public class DriverLicenseV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - DriverLicenseV1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/eu_driver_license/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - DriverLicenseV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getCountryCode().getValue()); - Assertions.assertNull(docPrediction.getDocumentId().getValue()); - Assertions.assertNull(docPrediction.getCategory().getValue()); - Assertions.assertNull(docPrediction.getLastName().getValue()); - Assertions.assertNull(docPrediction.getFirstName().getValue()); - Assertions.assertNull(docPrediction.getDateOfBirth().getValue()); - Assertions.assertNull(docPrediction.getPlaceOfBirth().getValue()); - Assertions.assertNull(docPrediction.getExpiryDate().getValue()); - Assertions.assertNull(docPrediction.getIssueDate().getValue()); - Assertions.assertNull(docPrediction.getIssueAuthority().getValue()); - Assertions.assertNull(docPrediction.getMrz().getValue()); - Assertions.assertNull(docPrediction.getAddress().getValue()); - DriverLicenseV1Page pagePrediction = response.getDocument().getInference().getPages().get(0).getPrediction(); - Assertions.assertEquals(pagePrediction.getPhoto().toString(), ""); - Assertions.assertEquals(pagePrediction.getSignature().toString(), ""); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/eu_driver_license/response_v1/summary_full.rst" - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse response = getPrediction("complete"); - Page page = response.getDocument().getInference().getPages().get(0); - ProductTestHelper.assertStringEqualsFile( - page.toString(), - "src/test/resources/products/eu_driver_license/response_v1/summary_page0.rst" - ); - } -} diff --git a/src/test/java/com/mindee/product/eu/licenseplate/LicensePlateV1Test.java b/src/test/java/com/mindee/product/eu/licenseplate/LicensePlateV1Test.java deleted file mode 100644 index c18ab3c46..000000000 --- a/src/test/java/com/mindee/product/eu/licenseplate/LicensePlateV1Test.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.mindee.product.eu.licenseplate; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.product.ProductTestHelper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -/** - * Unit tests for LicensePlateV1. - */ -public class LicensePlateV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - LicensePlateV1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/license_plates/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - LicensePlateV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertTrue(docPrediction.getLicensePlates().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/license_plates/response_v1/summary_full.rst" - ); - } - -} diff --git a/src/test/java/com/mindee/product/proofofaddress/ProofOfAddressV1Test.java b/src/test/java/com/mindee/product/proofofaddress/ProofOfAddressV1Test.java deleted file mode 100644 index 0d4635116..000000000 --- a/src/test/java/com/mindee/product/proofofaddress/ProofOfAddressV1Test.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.mindee.product.proofofaddress; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.product.ProductTestHelper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -/** - * Unit tests for ProofOfAddressV1. - */ -public class ProofOfAddressV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - ProofOfAddressV1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/proof_of_address/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - ProofOfAddressV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getLocale().getValue()); - Assertions.assertNull(docPrediction.getIssuerName().getValue()); - Assertions.assertTrue(docPrediction.getIssuerCompanyRegistration().isEmpty()); - Assertions.assertNull(docPrediction.getIssuerAddress().getValue()); - Assertions.assertNull(docPrediction.getRecipientName().getValue()); - Assertions.assertTrue(docPrediction.getRecipientCompanyRegistration().isEmpty()); - Assertions.assertNull(docPrediction.getRecipientAddress().getValue()); - Assertions.assertTrue(docPrediction.getDates().isEmpty()); - Assertions.assertNull(docPrediction.getDate().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/proof_of_address/response_v1/summary_full.rst" - ); - } - -} diff --git a/src/test/java/com/mindee/product/receipt/ReceiptV4Test.java b/src/test/java/com/mindee/product/receipt/ReceiptV4Test.java deleted file mode 100644 index fc707a42d..000000000 --- a/src/test/java/com/mindee/product/receipt/ReceiptV4Test.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mindee.product.receipt; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; - -/** - * Unit tests for ReceiptV4. - */ -public class ReceiptV4Test { - - protected PredictResponse getPrediction() throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - ReceiptV4.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/expense_receipts/response_v4/complete.json"), - type - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse prediction = getPrediction(); - Document doc = prediction.getDocument(); - String[] actualLines = doc.toString().split(System.lineSeparator()); - List expectedLines = Files.readAllLines( - Paths.get("src/test/resources/products/expense_receipts/response_v4/summary_full.rst") - ); - String expectedSummary = String.join(String.format("%n"), expectedLines); - String actualSummary = String.join(String.format("%n"), actualLines); - - Assertions.assertEquals(expectedSummary, actualSummary); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse prediction = getPrediction(); - Page page = prediction.getDocument().getInference().getPages().get(0); - String[] actualLines = page.toString().split(System.lineSeparator()); - List expectedLines = Files.readAllLines( - Paths.get("src/test/resources/products/expense_receipts/response_v4/summary_page0.rst") - ); - String expectedSummary = String.join(String.format("%n"), expectedLines); - String actualSummary = String.join(String.format("%n"), actualLines); - - Assertions.assertEquals(expectedSummary, actualSummary); - } -} diff --git a/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java b/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java deleted file mode 100644 index a23bb4b27..000000000 --- a/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.mindee.product.us.driverlicense; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.product.ProductTestHelper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -/** - * Unit tests for DriverLicenseV1. - */ -public class DriverLicenseV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - DriverLicenseV1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/us_driver_license/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - DriverLicenseV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getState().getValue()); - Assertions.assertNull(docPrediction.getDriverLicenseId().getValue()); - Assertions.assertNull(docPrediction.getExpiryDate().getValue()); - Assertions.assertNull(docPrediction.getIssuedDate().getValue()); - Assertions.assertNull(docPrediction.getLastName().getValue()); - Assertions.assertNull(docPrediction.getFirstName().getValue()); - Assertions.assertNull(docPrediction.getAddress().getValue()); - Assertions.assertNull(docPrediction.getDateOfBirth().getValue()); - Assertions.assertNull(docPrediction.getRestrictions().getValue()); - Assertions.assertNull(docPrediction.getEndorsements().getValue()); - Assertions.assertNull(docPrediction.getDlClass().getValue()); - Assertions.assertNull(docPrediction.getSex().getValue()); - Assertions.assertNull(docPrediction.getHeight().getValue()); - Assertions.assertNull(docPrediction.getWeight().getValue()); - Assertions.assertNull(docPrediction.getHairColor().getValue()); - Assertions.assertNull(docPrediction.getEyeColor().getValue()); - Assertions.assertNull(docPrediction.getDdNumber().getValue()); - DriverLicenseV1Page pagePrediction = response.getDocument().getInference().getPages().get(0).getPrediction(); - Assertions.assertEquals(pagePrediction.getPhoto().toString(), ""); - Assertions.assertEquals(pagePrediction.getSignature().toString(), ""); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/us_driver_license/response_v1/summary_full.rst" - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse response = getPrediction("complete"); - Page page = response.getDocument().getInference().getPages().get(0); - ProductTestHelper.assertStringEqualsFile( - page.toString(), - "src/test/resources/products/us_driver_license/response_v1/summary_page0.rst" - ); - } -} diff --git a/src/test/java/com/mindee/product/us/w9/W9V1Test.java b/src/test/java/com/mindee/product/us/w9/W9V1Test.java deleted file mode 100644 index 0648d355c..000000000 --- a/src/test/java/com/mindee/product/us/w9/W9V1Test.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.mindee.product.us.w9; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.parsing.common.Document; -import com.mindee.parsing.common.Page; -import com.mindee.parsing.common.PredictResponse; -import com.mindee.parsing.standard.ClassificationField; -import com.mindee.product.ProductTestHelper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; - -/** - * Unit tests for W9V1. - */ -public class W9V1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - W9V1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/us_w9/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - W9V1Page pagePrediction = response.getDocument().getInference().getPages().get(0).getPrediction(); - Assertions.assertNull(pagePrediction.getName().getValue()); - Assertions.assertNull(pagePrediction.getSsn().getValue()); - Assertions.assertNull(pagePrediction.getAddress().getValue()); - Assertions.assertNull(pagePrediction.getCityStateZip().getValue()); - Assertions.assertNull(pagePrediction.getBusinessName().getValue()); - Assertions.assertNull(pagePrediction.getEin().getValue()); - Assertions.assertNull(pagePrediction.getTaxClassification().getValue()); - Assertions.assertNull(pagePrediction.getTaxClassificationOtherDetails().getValue()); - Assertions.assertNull(pagePrediction.getW9RevisionDate().getValue()); - Assertions.assertEquals(pagePrediction.getSignaturePosition().toString(), ""); - Assertions.assertEquals(pagePrediction.getSignatureDatePosition().toString(), ""); - Assertions.assertNull(pagePrediction.getTaxClassificationLlc().getValue()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/us_w9/response_v1/summary_full.rst" - ); - } - - @Test - void whenCompleteDeserialized_mustHaveValidPage0Summary() throws IOException { - PredictResponse response = getPrediction("complete"); - Page page = response.getDocument().getInference().getPages().get(0); - ProductTestHelper.assertStringEqualsFile( - page.toString(), - "src/test/resources/products/us_w9/response_v1/summary_page0.rst" - ); - } -}