diff --git a/README.md b/README.md index 81c65a675..a811d7627 100644 --- a/README.md +++ b/README.md @@ -149,4 +149,4 @@ Available as open source under the terms of the [MIT License](https://opensource ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/code_samples/eu_driver_license_v1.txt b/docs/code_samples/eu_driver_license_v1.txt new file mode 100644 index 000000000..584336388 --- /dev/null +++ b/docs/code_samples/eu_driver_license_v1.txt @@ -0,0 +1,41 @@ +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/international_id_v2_async.txt b/docs/code_samples/international_id_v2_async.txt new file mode 100644 index 000000000..bab7bb49f --- /dev/null +++ b/docs/code_samples/international_id_v2_async.txt @@ -0,0 +1,41 @@ +import com.mindee.MindeeClient; +import com.mindee.input.LocalInputSource; +import com.mindee.parsing.common.AsyncPredictResponse; +import com.mindee.product.internationalid.InternationalIdV2; +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 response = mindeeClient.enqueueAndParse( + InternationalIdV2.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()) +// ); + } + +} diff --git a/docs/code_samples/resume_v1_async.txt b/docs/code_samples/resume_v1_async.txt new file mode 100644 index 000000000..dff6f5263 --- /dev/null +++ b/docs/code_samples/resume_v1_async.txt @@ -0,0 +1,41 @@ +import com.mindee.MindeeClient; +import com.mindee.input.LocalInputSource; +import com.mindee.parsing.common.AsyncPredictResponse; +import com.mindee.product.resume.ResumeV1; +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 response = mindeeClient.enqueueAndParse( + ResumeV1.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()) +// ); + } + +} diff --git a/docs/java-api-builder.md b/docs/java-api-builder.md index be0a5b2a1..0fa7369e9 100644 --- a/docs/java-api-builder.md +++ b/docs/java-api-builder.md @@ -130,4 +130,4 @@ for (Page page : inference.getPages()) { ``` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-field.md b/docs/java-field.md index 4d7078c3a..50bdca853 100644 --- a/docs/java-field.md +++ b/docs/java-field.md @@ -77,4 +77,4 @@ This field type captures tax information The `value` attribute is of type `java.time.LocalTime` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-financial-document-ocr.md b/docs/java-financial-document-ocr.md index 0dfa1a533..a29c8e9a0 100644 --- a/docs/java-financial-document-ocr.md +++ b/docs/java-financial-document-ocr.md @@ -61,4 +61,4 @@ Code QTY Price Amount Tax (Rate) Descript ``` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-getting-started.md b/docs/java-getting-started.md index e3e3255a0..3a7c82b1b 100644 --- a/docs/java-getting-started.md +++ b/docs/java-getting-started.md @@ -293,4 +293,4 @@ Each page element contains the data extracted for a particular page of the docum ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-invoice-ocr.md b/docs/java-invoice-ocr.md index 7b2717193..cf5f238b9 100644 --- a/docs/java-invoice-ocr.md +++ b/docs/java-invoice-ocr.md @@ -291,4 +291,4 @@ logger.info(invoiceDocument.getInference().getDocumentPrediction().getTotalNet() ```` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-license-plates-ocr.md b/docs/java-license-plates-ocr.md index 566a5a57f..bd825e50a 100644 --- a/docs/java-license-plates-ocr.md +++ b/docs/java-license-plates-ocr.md @@ -51,4 +51,4 @@ Page 0 ``` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-passport-ocr.md b/docs/java-passport-ocr.md index 527635a26..7ba13902b 100644 --- a/docs/java-passport-ocr.md +++ b/docs/java-passport-ocr.md @@ -134,4 +134,4 @@ The following date fields are available: * **`surname`** (StringField): Passport's owner surname. ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-proof-of-address-ocr.md b/docs/java-proof-of-address-ocr.md index 8bccf1bd0..312fb981c 100644 --- a/docs/java-proof-of-address-ocr.md +++ b/docs/java-proof-of-address-ocr.md @@ -50,4 +50,4 @@ Output: ``` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-receipt-ocr.md b/docs/java-receipt-ocr.md index bb6757f91..148e88bca 100644 --- a/docs/java-receipt-ocr.md +++ b/docs/java-receipt-ocr.md @@ -148,4 +148,4 @@ The following date fields are available: ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/java-us-bank-check-ocr.md b/docs/java-us-bank-check-ocr.md index 80c8b7e1f..97c7b7934 100644 --- a/docs/java-us-bank-check-ocr.md +++ b/docs/java-us-bank-check-ocr.md @@ -57,4 +57,4 @@ Page 0 ``` ## Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw) +[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/src/main/java/com/mindee/parsing/SummaryHelper.java b/src/main/java/com/mindee/parsing/SummaryHelper.java index 32cbbc544..ae6d156c6 100644 --- a/src/main/java/com/mindee/parsing/SummaryHelper.java +++ b/src/main/java/com/mindee/parsing/SummaryHelper.java @@ -43,6 +43,23 @@ public static String arrayToString(List lineItems, ); } + /** + * Truncates a string if it's too long for the requested width. + */ + public static String formatForDisplay(String inputString, Integer maxColSize) { + if (inputString == null || inputString.isEmpty()) { + return ""; + } + if (maxColSize == null) { + return inputString; + } + if (inputString.length() <= maxColSize) { + return inputString; + } else { + return inputString.substring(0, maxColSize - 3) + "..."; + } + } + /** * Format an rST table line separator. */ diff --git a/src/main/java/com/mindee/product/cropper/CropperV1Document.java b/src/main/java/com/mindee/product/cropper/CropperV1Document.java index 57c028f47..65584e249 100644 --- a/src/main/java/com/mindee/product/cropper/CropperV1Document.java +++ b/src/main/java/com/mindee/product/cropper/CropperV1Document.java @@ -1,8 +1,6 @@ package com.mindee.product.cropper; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.mindee.parsing.SummaryHelper; import com.mindee.parsing.common.Prediction; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java new file mode 100644 index 000000000..d728898cf --- /dev/null +++ b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java @@ -0,0 +1,16 @@ +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; + +/** + * The definition for Driver License, API version 1. + */ +@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 new file mode 100644 index 000000000..d817fc621 --- /dev/null +++ b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Document.java @@ -0,0 +1,140 @@ +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; + +/** + * Document data for Driver License, API version 1. + */ +@Getter +@EqualsAndHashCode(callSuper = false) +@JsonIgnoreProperties(ignoreUnknown = true) +public class DriverLicenseV1Document extends Prediction { + + /** + * EU driver license holders address + */ + @JsonProperty("address") + private StringField address; + /** + * EU driver license holders categories + */ + @JsonProperty("category") + private StringField category; + /** + * Country code extracted as a string. + */ + @JsonProperty("country_code") + private StringField countryCode; + /** + * The date of birth of the document holder + */ + @JsonProperty("date_of_birth") + private DateField dateOfBirth; + /** + * ID number of the Document. + */ + @JsonProperty("document_id") + private StringField documentId; + /** + * Date the document expires + */ + @JsonProperty("expiry_date") + private DateField expiryDate; + /** + * First name(s) of the driver license holder + */ + @JsonProperty("first_name") + private StringField firstName; + /** + * Authority that issued the document + */ + @JsonProperty("issue_authority") + private StringField issueAuthority; + /** + * Date the document was issued + */ + @JsonProperty("issue_date") + private DateField issueDate; + /** + * Last name of the driver license holder. + */ + @JsonProperty("last_name") + private StringField lastName; + /** + * Machine-readable license number + */ + @JsonProperty("mrz") + private StringField mrz; + /** + * Place where the driver license holder was born + */ + @JsonProperty("place_of_birth") + private 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 new file mode 100644 index 000000000..646862432 --- /dev/null +++ b/src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Page.java @@ -0,0 +1,49 @@ +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; + +/** + * Page data for Driver License, API version 1. + */ +@Getter +@EqualsAndHashCode(callSuper = true) +@JsonIgnoreProperties(ignoreUnknown = true) +public class DriverLicenseV1Page extends DriverLicenseV1Document { + + /** + * Has a photo of the EU driver license holder + */ + @JsonProperty("photo") + private PositionField photo; + /** + * Has a signature of the EU driver license holder + */ + @JsonProperty("signature") + private 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/financialdocument/FinancialDocumentV1LineItem.java b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java index 2b67aae45..6def13959 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java +++ b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1LineItem.java @@ -86,7 +86,7 @@ private Map printableValues() { descriptionSummary = descriptionSummary.substring(0, 33) + "..."; } printable.put("description", descriptionSummary); - printable.put("productCode", SummaryHelper.formatString(this.productCode)); + printable.put("productCode", SummaryHelper.formatForDisplay(this.productCode, null)); printable.put( "quantity", SummaryHelper.formatAmount(this.quantity) diff --git a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java b/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java index ece9aae58..9315c4646 100644 --- a/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java +++ b/src/main/java/com/mindee/product/fr/bankaccountdetails/BankAccountDetailsV2Bban.java @@ -59,10 +59,10 @@ public String toString() { private Map printableValues() { Map printable = new HashMap<>(); - printable.put("bbanBankCode", SummaryHelper.formatString(this.bbanBankCode)); - printable.put("bbanBranchCode", SummaryHelper.formatString(this.bbanBranchCode)); - printable.put("bbanKey", SummaryHelper.formatString(this.bbanKey)); - printable.put("bbanNumber", SummaryHelper.formatString(this.bbanNumber)); + printable.put("bbanBankCode", SummaryHelper.formatForDisplay(this.bbanBankCode, null)); + printable.put("bbanBranchCode", SummaryHelper.formatForDisplay(this.bbanBranchCode, null)); + printable.put("bbanKey", SummaryHelper.formatForDisplay(this.bbanKey, null)); + printable.put("bbanNumber", SummaryHelper.formatForDisplay(this.bbanNumber, null)); return printable; } } diff --git a/src/main/java/com/mindee/product/internationalid/InternationalIdV1Document.java b/src/main/java/com/mindee/product/internationalid/InternationalIdV1Document.java index 596bd2d55..d99308b05 100644 --- a/src/main/java/com/mindee/product/internationalid/InternationalIdV1Document.java +++ b/src/main/java/com/mindee/product/internationalid/InternationalIdV1Document.java @@ -5,6 +5,7 @@ import com.mindee.parsing.SummaryHelper; import com.mindee.parsing.common.Prediction; import com.mindee.parsing.standard.ClassificationField; +import com.mindee.parsing.standard.DateField; import com.mindee.parsing.standard.StringField; import java.util.ArrayList; import java.util.List; @@ -28,7 +29,7 @@ public class InternationalIdV1Document extends Prediction { * The date of birth of the document holder. */ @JsonProperty("birth_date") - private StringField birthDate; + private DateField birthDate; /** * The location where the document holder was born. */ @@ -53,7 +54,7 @@ public class InternationalIdV1Document extends Prediction { * The date when the document will no longer be valid for use. */ @JsonProperty("expiry_date") - private StringField expiryDate; + private DateField expiryDate; /** * The first names or given names of the document holder. */ @@ -63,7 +64,7 @@ public class InternationalIdV1Document extends Prediction { * The date when the document was issued. */ @JsonProperty("issue_date") - private StringField issueDate; + private DateField issueDate; /** * First line of information in a standardized format for easy machine reading and processing. */ diff --git a/src/main/java/com/mindee/product/internationalid/InternationalIdV2.java b/src/main/java/com/mindee/product/internationalid/InternationalIdV2.java new file mode 100644 index 000000000..ba539aded --- /dev/null +++ b/src/main/java/com/mindee/product/internationalid/InternationalIdV2.java @@ -0,0 +1,16 @@ +package com.mindee.product.internationalid; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.mindee.http.EndpointInfo; +import com.mindee.parsing.common.Inference; +import lombok.Getter; + +/** + * The definition for International ID, API version 2. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +@EndpointInfo(endpointName = "international_id", version = "2") +public class InternationalIdV2 + extends Inference { +} diff --git a/src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java b/src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java new file mode 100644 index 000000000..baa627fd9 --- /dev/null +++ b/src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java @@ -0,0 +1,196 @@ +package com.mindee.product.internationalid; + +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.ClassificationField; +import com.mindee.parsing.standard.DateField; +import com.mindee.parsing.standard.StringField; +import java.util.ArrayList; +import java.util.List; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +/** + * Document data for International ID, API version 2. + */ +@Getter +@EqualsAndHashCode(callSuper = false) +@JsonIgnoreProperties(ignoreUnknown = true) +public class InternationalIdV2Document extends Prediction { + + /** + * The physical address of the document holder. + */ + @JsonProperty("address") + private StringField address; + /** + * The date of birth of the document holder. + */ + @JsonProperty("birth_date") + private DateField birthDate; + /** + * The place of birth of the document holder. + */ + @JsonProperty("birth_place") + private StringField birthPlace; + /** + * The country where the document was issued. + */ + @JsonProperty("country_of_issue") + private StringField countryOfIssue; + /** + * The unique identifier assigned to the document. + */ + @JsonProperty("document_number") + private StringField documentNumber; + /** + * The type of personal identification document. + */ + @JsonProperty("document_type") + private ClassificationField documentType; + /** + * The date when the document becomes invalid. + */ + @JsonProperty("expiry_date") + private DateField expiryDate; + /** + * The list of the document holder's given names. + */ + @JsonProperty("given_names") + private List givenNames = new ArrayList<>(); + /** + * The date when the document was issued. + */ + @JsonProperty("issue_date") + private DateField issueDate; + /** + * The Machine Readable Zone, first line. + */ + @JsonProperty("mrz_line1") + private StringField mrzLine1; + /** + * The Machine Readable Zone, second line. + */ + @JsonProperty("mrz_line2") + private StringField mrzLine2; + /** + * The Machine Readable Zone, third line. + */ + @JsonProperty("mrz_line3") + private StringField mrzLine3; + /** + * The country of citizenship of the document holder. + */ + @JsonProperty("nationality") + private StringField nationality; + /** + * The unique identifier assigned to the document holder. + */ + @JsonProperty("personal_number") + private StringField personalNumber; + /** + * The biological sex of the document holder. + */ + @JsonProperty("sex") + private StringField sex; + /** + * The state or territory where the document was issued. + */ + @JsonProperty("state_of_issue") + private StringField stateOfIssue; + /** + * The list of the document holder's family names. + */ + @JsonProperty("surnames") + private List surnames = new ArrayList<>(); + + @Override + public boolean isEmpty() { + return ( + this.documentType == null + && this.documentNumber == null + && (this.surnames == null || this.surnames.isEmpty()) + && (this.givenNames == null || this.givenNames.isEmpty()) + && this.sex == null + && this.birthDate == null + && this.birthPlace == null + && this.nationality == null + && this.personalNumber == null + && this.countryOfIssue == null + && this.stateOfIssue == null + && this.issueDate == null + && this.expiryDate == null + && this.address == null + && this.mrzLine1 == null + && this.mrzLine2 == null + && this.mrzLine3 == null + ); + } + + @Override + public String toString() { + StringBuilder outStr = new StringBuilder(); + outStr.append( + String.format(":Document Type: %s%n", this.getDocumentType()) + ); + outStr.append( + String.format(":Document Number: %s%n", this.getDocumentNumber()) + ); + String surnames = SummaryHelper.arrayToString( + this.getSurnames(), + "%n " + ); + outStr.append( + String.format(":Surnames: %s%n", surnames) + ); + String givenNames = SummaryHelper.arrayToString( + this.getGivenNames(), + "%n " + ); + outStr.append( + String.format(":Given Names: %s%n", givenNames) + ); + outStr.append( + String.format(":Sex: %s%n", this.getSex()) + ); + outStr.append( + String.format(":Birth Date: %s%n", this.getBirthDate()) + ); + outStr.append( + String.format(":Birth Place: %s%n", this.getBirthPlace()) + ); + outStr.append( + String.format(":Nationality: %s%n", this.getNationality()) + ); + outStr.append( + String.format(":Personal Number: %s%n", this.getPersonalNumber()) + ); + outStr.append( + String.format(":Country of Issue: %s%n", this.getCountryOfIssue()) + ); + outStr.append( + String.format(":State of Issue: %s%n", this.getStateOfIssue()) + ); + outStr.append( + String.format(":Issue Date: %s%n", this.getIssueDate()) + ); + outStr.append( + String.format(":Expiration Date: %s%n", this.getExpiryDate()) + ); + outStr.append( + String.format(":Address: %s%n", this.getAddress()) + ); + outStr.append( + String.format(":MRZ Line 1: %s%n", this.getMrzLine1()) + ); + outStr.append( + String.format(":MRZ Line 2: %s%n", this.getMrzLine2()) + ); + outStr.append( + String.format(":MRZ Line 3: %s%n", this.getMrzLine3()) + ); + return SummaryHelper.cleanSummary(outStr.toString()); + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1.java b/src/main/java/com/mindee/product/resume/ResumeV1.java new file mode 100644 index 000000000..e39a7034e --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1.java @@ -0,0 +1,16 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.mindee.http.EndpointInfo; +import com.mindee.parsing.common.Inference; +import lombok.Getter; + +/** + * The definition for Resume, API version 1. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +@EndpointInfo(endpointName = "resume", version = "1") +public class ResumeV1 + extends Inference { +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java b/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java new file mode 100644 index 000000000..30c27d137 --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java @@ -0,0 +1,69 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.SummaryHelper; +import com.mindee.parsing.standard.BaseField; +import com.mindee.parsing.standard.LineItemField; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +/** + * The list of certificates obtained by the candidate. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Certificate extends BaseField implements LineItemField { + + /** + * The grade obtained for the certificate. + */ + @JsonProperty("grade") + String grade; + /** + * The name of certification. + */ + @JsonProperty("name") + String name; + /** + * The organization or institution that issued the certificate. + */ + @JsonProperty("provider") + String provider; + /** + * The year when a certificate was issued or received. + */ + @JsonProperty("year") + String year; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-10s ", printable.get("grade")) + + String.format("| %-30s ", printable.get("name")) + + String.format("| %-25s ", printable.get("provider")) + + String.format("| %-4s |", printable.get("year")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Grade: %s", printable.get("grade")) + + String.format(", Name: %s", printable.get("name")) + + String.format(", Provider: %s", printable.get("provider")) + + String.format(", Year: %s", printable.get("year")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("grade", SummaryHelper.formatForDisplay(this.grade, 10)); + printable.put("name", SummaryHelper.formatForDisplay(this.name, 30)); + printable.put("provider", SummaryHelper.formatForDisplay(this.provider, 25)); + printable.put("year", SummaryHelper.formatForDisplay(this.year, null)); + return printable; + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Document.java b/src/main/java/com/mindee/product/resume/ResumeV1Document.java new file mode 100644 index 000000000..7d3184b66 --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1Document.java @@ -0,0 +1,271 @@ +package com.mindee.product.resume; + +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.ClassificationField; +import com.mindee.parsing.standard.StringField; +import java.util.ArrayList; +import java.util.List; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +/** + * Document data for Resume, API version 1. + */ +@Getter +@EqualsAndHashCode(callSuper = false) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Document extends Prediction { + + /** + * The location information of the candidate, including city, state, and country. + */ + @JsonProperty("address") + private StringField address; + /** + * The list of certificates obtained by the candidate. + */ + @JsonProperty("certificates") + private List certificates = new ArrayList<>(); + /** + * The ISO 639 code of the language in which the document is written. + */ + @JsonProperty("document_language") + private StringField documentLanguage; + /** + * The type of the document sent. + */ + @JsonProperty("document_type") + private ClassificationField documentType; + /** + * The list of the candidate's educational background. + */ + @JsonProperty("education") + private List education = new ArrayList<>(); + /** + * The email address of the candidate. + */ + @JsonProperty("email_address") + private StringField emailAddress; + /** + * The candidate's first or given names. + */ + @JsonProperty("given_names") + private List givenNames = new ArrayList<>(); + /** + * The list of the candidate's technical abilities and knowledge. + */ + @JsonProperty("hard_skills") + private List hardSkills = new ArrayList<>(); + /** + * The position that the candidate is applying for. + */ + @JsonProperty("job_applied") + private StringField jobApplied; + /** + * The list of languages that the candidate is proficient in. + */ + @JsonProperty("languages") + private List languages = new ArrayList<>(); + /** + * The ISO 3166 code for the country of citizenship of the candidate. + */ + @JsonProperty("nationality") + private StringField nationality; + /** + * The phone number of the candidate. + */ + @JsonProperty("phone_number") + private StringField phoneNumber; + /** + * The candidate's current profession. + */ + @JsonProperty("profession") + private StringField profession; + /** + * The list of the candidate's professional experiences. + */ + @JsonProperty("professional_experiences") + private List professionalExperiences = new ArrayList<>(); + /** + * The list of social network profiles of the candidate. + */ + @JsonProperty("social_networks_urls") + private List socialNetworksUrls = new ArrayList<>(); + /** + * The list of the candidate's interpersonal and communication abilities. + */ + @JsonProperty("soft_skills") + private List softSkills = new ArrayList<>(); + /** + * The candidate's last names. + */ + @JsonProperty("surnames") + private List surnames = new ArrayList<>(); + + @Override + public boolean isEmpty() { + return ( + this.documentLanguage == null + && this.documentType == null + && (this.givenNames == null || this.givenNames.isEmpty()) + && (this.surnames == null || this.surnames.isEmpty()) + && this.nationality == null + && this.emailAddress == null + && this.phoneNumber == null + && this.address == null + && (this.socialNetworksUrls == null || this.socialNetworksUrls.isEmpty()) + && this.profession == null + && this.jobApplied == null + && (this.languages == null || this.languages.isEmpty()) + && (this.hardSkills == null || this.hardSkills.isEmpty()) + && (this.softSkills == null || this.softSkills.isEmpty()) + && (this.education == null || this.education.isEmpty()) + && (this.professionalExperiences == null || this.professionalExperiences.isEmpty()) + && (this.certificates == null || this.certificates.isEmpty()) + ); + } + + @Override + public String toString() { + StringBuilder outStr = new StringBuilder(); + outStr.append( + String.format(":Document Language: %s%n", this.getDocumentLanguage()) + ); + outStr.append( + String.format(":Document Type: %s%n", this.getDocumentType()) + ); + String givenNames = SummaryHelper.arrayToString( + this.getGivenNames(), + "%n " + ); + outStr.append( + String.format(":Given Names: %s%n", givenNames) + ); + String surnames = SummaryHelper.arrayToString( + this.getSurnames(), + "%n " + ); + outStr.append( + String.format(":Surnames: %s%n", surnames) + ); + outStr.append( + String.format(":Nationality: %s%n", this.getNationality()) + ); + outStr.append( + String.format(":Email Address: %s%n", this.getEmailAddress()) + ); + outStr.append( + String.format(":Phone Number: %s%n", this.getPhoneNumber()) + ); + outStr.append( + String.format(":Address: %s%n", this.getAddress()) + ); + String socialNetworksUrlsSummary = ""; + if (!this.getSocialNetworksUrls().isEmpty()) { + int[] socialNetworksUrlsColSizes = new int[]{22, 52}; + socialNetworksUrlsSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "-")) + + "| Name " + + "| URL " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "=")); + socialNetworksUrlsSummary += SummaryHelper.arrayToString(this.getSocialNetworksUrls(), socialNetworksUrlsColSizes); + socialNetworksUrlsSummary += String.format("%n%s", SummaryHelper.lineSeparator(socialNetworksUrlsColSizes, "-")); + } + outStr.append( + String.format(":Social Networks: %s%n", socialNetworksUrlsSummary) + ); + outStr.append( + String.format(":Profession: %s%n", this.getProfession()) + ); + outStr.append( + String.format(":Job Applied: %s%n", this.getJobApplied()) + ); + String languagesSummary = ""; + if (!this.getLanguages().isEmpty()) { + int[] languagesColSizes = new int[]{10, 22}; + languagesSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(languagesColSizes, "-")) + + "| Language " + + "| Level " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(languagesColSizes, "=")); + languagesSummary += SummaryHelper.arrayToString(this.getLanguages(), languagesColSizes); + languagesSummary += String.format("%n%s", SummaryHelper.lineSeparator(languagesColSizes, "-")); + } + outStr.append( + String.format(":Languages: %s%n", languagesSummary) + ); + String hardSkills = SummaryHelper.arrayToString( + this.getHardSkills(), + "%n " + ); + outStr.append( + String.format(":Hard Skills: %s%n", hardSkills) + ); + String softSkills = SummaryHelper.arrayToString( + this.getSoftSkills(), + "%n " + ); + outStr.append( + String.format(":Soft Skills: %s%n", softSkills) + ); + String educationSummary = ""; + if (!this.getEducation().isEmpty()) { + int[] educationColSizes = new int[]{17, 27, 11, 10, 27, 13, 12}; + educationSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(educationColSizes, "-")) + + "| Domain " + + "| Degree " + + "| End Month " + + "| End Year " + + "| School " + + "| Start Month " + + "| Start Year " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(educationColSizes, "=")); + educationSummary += SummaryHelper.arrayToString(this.getEducation(), educationColSizes); + educationSummary += String.format("%n%s", SummaryHelper.lineSeparator(educationColSizes, "-")); + } + outStr.append( + String.format(":Education: %s%n", educationSummary) + ); + String professionalExperiencesSummary = ""; + if (!this.getProfessionalExperiences().isEmpty()) { + int[] professionalExperiencesColSizes = new int[]{17, 12, 27, 11, 10, 22, 13, 12}; + professionalExperiencesSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "-")) + + "| Contract Type " + + "| Department " + + "| Employer " + + "| End Month " + + "| End Year " + + "| Role " + + "| Start Month " + + "| Start Year " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "=")); + professionalExperiencesSummary += SummaryHelper.arrayToString(this.getProfessionalExperiences(), professionalExperiencesColSizes); + professionalExperiencesSummary += String.format("%n%s", SummaryHelper.lineSeparator(professionalExperiencesColSizes, "-")); + } + outStr.append( + String.format(":Professional Experiences: %s%n", professionalExperiencesSummary) + ); + String certificatesSummary = ""; + if (!this.getCertificates().isEmpty()) { + int[] certificatesColSizes = new int[]{12, 32, 27, 6}; + certificatesSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(certificatesColSizes, "-")) + + "| Grade " + + "| Name " + + "| Provider " + + "| Year " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(certificatesColSizes, "=")); + certificatesSummary += SummaryHelper.arrayToString(this.getCertificates(), certificatesColSizes); + certificatesSummary += String.format("%n%s", SummaryHelper.lineSeparator(certificatesColSizes, "-")); + } + outStr.append( + String.format(":Certificates: %s%n", certificatesSummary) + ); + return SummaryHelper.cleanSummary(outStr.toString()); + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Education.java b/src/main/java/com/mindee/product/resume/ResumeV1Education.java new file mode 100644 index 000000000..1a26428f1 --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1Education.java @@ -0,0 +1,93 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.SummaryHelper; +import com.mindee.parsing.standard.BaseField; +import com.mindee.parsing.standard.LineItemField; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +/** + * The list of the candidate's educational background. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Education extends BaseField implements LineItemField { + + /** + * The area of study or specialization. + */ + @JsonProperty("degree_domain") + String degreeDomain; + /** + * The type of degree obtained, such as Bachelor's, Master's, or Doctorate. + */ + @JsonProperty("degree_type") + String degreeType; + /** + * The month when the education program or course was completed. + */ + @JsonProperty("end_month") + String endMonth; + /** + * The year when the education program or course was completed. + */ + @JsonProperty("end_year") + String endYear; + /** + * The name of the school. + */ + @JsonProperty("school") + String school; + /** + * The month when the education program or course began. + */ + @JsonProperty("start_month") + String startMonth; + /** + * The year when the education program or course began. + */ + @JsonProperty("start_year") + String startYear; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-15s ", printable.get("degreeDomain")) + + String.format("| %-25s ", printable.get("degreeType")) + + String.format("| %-9s ", printable.get("endMonth")) + + String.format("| %-8s ", printable.get("endYear")) + + String.format("| %-25s ", printable.get("school")) + + String.format("| %-11s ", printable.get("startMonth")) + + String.format("| %-10s |", printable.get("startYear")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Domain: %s", printable.get("degreeDomain")) + + String.format(", Degree: %s", printable.get("degreeType")) + + String.format(", End Month: %s", printable.get("endMonth")) + + String.format(", End Year: %s", printable.get("endYear")) + + String.format(", School: %s", printable.get("school")) + + String.format(", Start Month: %s", printable.get("startMonth")) + + String.format(", Start Year: %s", printable.get("startYear")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("degreeDomain", SummaryHelper.formatForDisplay(this.degreeDomain, 15)); + printable.put("degreeType", SummaryHelper.formatForDisplay(this.degreeType, 25)); + printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); + printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); + printable.put("school", SummaryHelper.formatForDisplay(this.school, 25)); + printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); + printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); + return printable; + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Language.java b/src/main/java/com/mindee/product/resume/ResumeV1Language.java new file mode 100644 index 000000000..3e5907f60 --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1Language.java @@ -0,0 +1,53 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.SummaryHelper; +import com.mindee.parsing.standard.BaseField; +import com.mindee.parsing.standard.LineItemField; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +/** + * The list of languages that the candidate is proficient in. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Language extends BaseField implements LineItemField { + + /** + * The language's ISO 639 code. + */ + @JsonProperty("language") + String language; + /** + * The candidate's level for the language. + */ + @JsonProperty("level") + String level; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-8s ", printable.get("language")) + + String.format("| %-20s |", printable.get("level")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Language: %s", printable.get("language")) + + String.format(", Level: %s", printable.get("level")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("language", SummaryHelper.formatForDisplay(this.language, null)); + printable.put("level", SummaryHelper.formatForDisplay(this.level, 20)); + return printable; + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java b/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java new file mode 100644 index 000000000..f3afe85be --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java @@ -0,0 +1,101 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.SummaryHelper; +import com.mindee.parsing.standard.BaseField; +import com.mindee.parsing.standard.LineItemField; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +/** + * The list of the candidate's professional experiences. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1ProfessionalExperience extends BaseField implements LineItemField { + + /** + * The type of contract for the professional experience. + */ + @JsonProperty("contract_type") + String contractType; + /** + * The specific department or division within the company. + */ + @JsonProperty("department") + String department; + /** + * The name of the company or organization. + */ + @JsonProperty("employer") + String employer; + /** + * The month when the professional experience ended. + */ + @JsonProperty("end_month") + String endMonth; + /** + * The year when the professional experience ended. + */ + @JsonProperty("end_year") + String endYear; + /** + * The position or job title held by the candidate. + */ + @JsonProperty("role") + String role; + /** + * The month when the professional experience began. + */ + @JsonProperty("start_month") + String startMonth; + /** + * The year when the professional experience began. + */ + @JsonProperty("start_year") + String startYear; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-15s ", printable.get("contractType")) + + String.format("| %-10s ", printable.get("department")) + + String.format("| %-25s ", printable.get("employer")) + + String.format("| %-9s ", printable.get("endMonth")) + + String.format("| %-8s ", printable.get("endYear")) + + String.format("| %-20s ", printable.get("role")) + + String.format("| %-11s ", printable.get("startMonth")) + + String.format("| %-10s |", printable.get("startYear")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Contract Type: %s", printable.get("contractType")) + + String.format(", Department: %s", printable.get("department")) + + String.format(", Employer: %s", printable.get("employer")) + + String.format(", End Month: %s", printable.get("endMonth")) + + String.format(", End Year: %s", printable.get("endYear")) + + String.format(", Role: %s", printable.get("role")) + + String.format(", Start Month: %s", printable.get("startMonth")) + + String.format(", Start Year: %s", printable.get("startYear")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("contractType", SummaryHelper.formatForDisplay(this.contractType, 15)); + printable.put("department", SummaryHelper.formatForDisplay(this.department, 10)); + printable.put("employer", SummaryHelper.formatForDisplay(this.employer, 25)); + printable.put("endMonth", SummaryHelper.formatForDisplay(this.endMonth, null)); + printable.put("endYear", SummaryHelper.formatForDisplay(this.endYear, null)); + printable.put("role", SummaryHelper.formatForDisplay(this.role, 20)); + printable.put("startMonth", SummaryHelper.formatForDisplay(this.startMonth, null)); + printable.put("startYear", SummaryHelper.formatForDisplay(this.startYear, null)); + return printable; + } +} diff --git a/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java b/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java new file mode 100644 index 000000000..e02fbe0db --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java @@ -0,0 +1,53 @@ +package com.mindee.product.resume; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.SummaryHelper; +import com.mindee.parsing.standard.BaseField; +import com.mindee.parsing.standard.LineItemField; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +/** + * The list of social network profiles of the candidate. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1SocialNetworksUrl extends BaseField implements LineItemField { + + /** + * The name of the social network. + */ + @JsonProperty("name") + String name; + /** + * The URL of the social network. + */ + @JsonProperty("url") + String url; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-20s ", printable.get("name")) + + String.format("| %-50s |", printable.get("url")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Name: %s", printable.get("name")) + + String.format(", URL: %s", printable.get("url")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("name", SummaryHelper.formatForDisplay(this.name, 20)); + printable.put("url", SummaryHelper.formatForDisplay(this.url, 50)); + return printable; + } +} diff --git a/src/main/java/com/mindee/product/us/w9/W9V1Document.java b/src/main/java/com/mindee/product/us/w9/W9V1Document.java index c80fe8267..4c65a07af 100644 --- a/src/main/java/com/mindee/product/us/w9/W9V1Document.java +++ b/src/main/java/com/mindee/product/us/w9/W9V1Document.java @@ -1,8 +1,6 @@ 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.common.Prediction; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java b/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java new file mode 100644 index 000000000..71983ec8b --- /dev/null +++ b/src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java @@ -0,0 +1,74 @@ +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/internationalid/InternationalIdV2Test.java b/src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java new file mode 100644 index 000000000..faedd2527 --- /dev/null +++ b/src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java @@ -0,0 +1,66 @@ +package com.mindee.product.internationalid; + +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 InternationalIdV2. + */ +public class InternationalIdV2Test { + + protected PredictResponse getPrediction(String name) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.findAndRegisterModules(); + + JavaType type = objectMapper.getTypeFactory().constructParametricType( + PredictResponse.class, + InternationalIdV2.class + ); + return objectMapper.readValue( + new File("src/test/resources/products/international_id/response_v2/" + name + ".json"), + type + ); + } + + @Test + void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { + PredictResponse response = getPrediction("empty"); + InternationalIdV2Document docPrediction = response.getDocument().getInference().getPrediction(); + Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType()); + Assertions.assertNull(docPrediction.getDocumentNumber().getValue()); + Assertions.assertTrue(docPrediction.getSurnames().isEmpty()); + Assertions.assertTrue(docPrediction.getGivenNames().isEmpty()); + Assertions.assertNull(docPrediction.getSex().getValue()); + Assertions.assertNull(docPrediction.getBirthDate().getValue()); + Assertions.assertNull(docPrediction.getBirthPlace().getValue()); + Assertions.assertNull(docPrediction.getNationality().getValue()); + Assertions.assertNull(docPrediction.getPersonalNumber().getValue()); + Assertions.assertNull(docPrediction.getCountryOfIssue().getValue()); + Assertions.assertNull(docPrediction.getStateOfIssue().getValue()); + Assertions.assertNull(docPrediction.getIssueDate().getValue()); + Assertions.assertNull(docPrediction.getExpiryDate().getValue()); + Assertions.assertNull(docPrediction.getAddress().getValue()); + Assertions.assertNull(docPrediction.getMrzLine1().getValue()); + Assertions.assertNull(docPrediction.getMrzLine2().getValue()); + Assertions.assertNull(docPrediction.getMrzLine3().getValue()); + } + + @Test + void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { + PredictResponse response = getPrediction("complete"); + Document doc = response.getDocument(); + ProductTestHelper.assertStringEqualsFile( + doc.toString(), + "src/test/resources/products/international_id/response_v2/summary_full.rst" + ); + } + +} diff --git a/src/test/java/com/mindee/product/resume/ResumeV1Test.java b/src/test/java/com/mindee/product/resume/ResumeV1Test.java new file mode 100644 index 000000000..9be4ac18a --- /dev/null +++ b/src/test/java/com/mindee/product/resume/ResumeV1Test.java @@ -0,0 +1,66 @@ +package com.mindee.product.resume; + +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 ResumeV1. + */ +public class ResumeV1Test { + + protected PredictResponse getPrediction(String name) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.findAndRegisterModules(); + + JavaType type = objectMapper.getTypeFactory().constructParametricType( + PredictResponse.class, + ResumeV1.class + ); + return objectMapper.readValue( + new File("src/test/resources/products/resume/response_v1/" + name + ".json"), + type + ); + } + + @Test + void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { + PredictResponse response = getPrediction("empty"); + ResumeV1Document docPrediction = response.getDocument().getInference().getPrediction(); + Assertions.assertNull(docPrediction.getDocumentLanguage().getValue()); + Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType()); + Assertions.assertTrue(docPrediction.getGivenNames().isEmpty()); + Assertions.assertTrue(docPrediction.getSurnames().isEmpty()); + Assertions.assertNull(docPrediction.getNationality().getValue()); + Assertions.assertNull(docPrediction.getEmailAddress().getValue()); + Assertions.assertNull(docPrediction.getPhoneNumber().getValue()); + Assertions.assertNull(docPrediction.getAddress().getValue()); + Assertions.assertTrue(docPrediction.getSocialNetworksUrls().isEmpty()); + Assertions.assertNull(docPrediction.getProfession().getValue()); + Assertions.assertNull(docPrediction.getJobApplied().getValue()); + Assertions.assertTrue(docPrediction.getLanguages().isEmpty()); + Assertions.assertTrue(docPrediction.getHardSkills().isEmpty()); + Assertions.assertTrue(docPrediction.getSoftSkills().isEmpty()); + Assertions.assertTrue(docPrediction.getEducation().isEmpty()); + Assertions.assertTrue(docPrediction.getProfessionalExperiences().isEmpty()); + Assertions.assertTrue(docPrediction.getCertificates().isEmpty()); + } + + @Test + void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { + PredictResponse response = getPrediction("complete"); + Document doc = response.getDocument(); + ProductTestHelper.assertStringEqualsFile( + doc.toString(), + "src/test/resources/products/resume/response_v1/summary_full.rst" + ); + } + +} diff --git a/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java b/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java index 2f8742cd6..6a9556a78 100644 --- a/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java +++ b/src/test/java/com/mindee/product/us/bankcheck/BankCheckV1Test.java @@ -42,7 +42,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { Assertions.assertNull(docPrediction.getAccountNumber().getValue()); Assertions.assertNull(docPrediction.getCheckNumber().getValue()); BankCheckV1Page pagePrediction = response.getDocument().getInference().getPages().get(0).getPrediction(); - Assertions.assertTrue(pagePrediction.getCheckPosition().getPolygon().isEmpty()); + Assertions.assertEquals(pagePrediction.getCheckPosition().toString(), ""); Assertions.assertTrue(pagePrediction.getSignaturesPositions().isEmpty()); } diff --git a/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java b/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java index 4ebc852b9..a23bb4b27 100644 --- a/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java +++ b/src/test/java/com/mindee/product/us/driverlicense/DriverLicenseV1Test.java @@ -53,8 +53,8 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { Assertions.assertNull(docPrediction.getEyeColor().getValue()); Assertions.assertNull(docPrediction.getDdNumber().getValue()); DriverLicenseV1Page pagePrediction = response.getDocument().getInference().getPages().get(0).getPrediction(); - Assertions.assertTrue(pagePrediction.getPhoto().getPolygon().isEmpty()); - Assertions.assertTrue(pagePrediction.getSignature().getPolygon().isEmpty()); + Assertions.assertEquals(pagePrediction.getPhoto().toString(), ""); + Assertions.assertEquals(pagePrediction.getSignature().toString(), ""); } @Test diff --git a/src/test/java/com/mindee/product/us/w9/W9V1Test.java b/src/test/java/com/mindee/product/us/w9/W9V1Test.java index 3ad9d2de5..0648d355c 100644 --- a/src/test/java/com/mindee/product/us/w9/W9V1Test.java +++ b/src/test/java/com/mindee/product/us/w9/W9V1Test.java @@ -5,13 +5,12 @@ 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; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; /** * Unit tests for W9V1. @@ -45,8 +44,8 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { Assertions.assertNull(pagePrediction.getTaxClassification().getValue()); Assertions.assertNull(pagePrediction.getTaxClassificationOtherDetails().getValue()); Assertions.assertNull(pagePrediction.getW9RevisionDate().getValue()); - Assertions.assertNull(pagePrediction.getSignaturePosition().getPolygon()); - Assertions.assertNull(pagePrediction.getSignatureDatePosition().getPolygon()); + Assertions.assertEquals(pagePrediction.getSignaturePosition().toString(), ""); + Assertions.assertEquals(pagePrediction.getSignatureDatePosition().toString(), ""); Assertions.assertNull(pagePrediction.getTaxClassificationLlc().getValue()); } @@ -54,27 +53,19 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { PredictResponse response = getPrediction("complete"); Document doc = response.getDocument(); - String[] actualLines = doc.toString().split(System.lineSeparator()); - List expectedLines = Files.readAllLines( - Paths.get("src/test/resources/products/us_w9/response_v1/summary_full.rst") + ProductTestHelper.assertStringEqualsFile( + doc.toString(), + "src/test/resources/products/us_w9/response_v1/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 response = getPrediction("complete"); Page page = response.getDocument().getInference().getPages().get(0); - String[] actualLines = page.toString().split(System.lineSeparator()); - List expectedLines = Files.readAllLines( - Paths.get("src/test/resources/products/us_w9/response_v1/summary_page0.rst") + ProductTestHelper.assertStringEqualsFile( + page.toString(), + "src/test/resources/products/us_w9/response_v1/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/resources b/src/test/resources index d083eb21f..eed30b2bd 160000 --- a/src/test/resources +++ b/src/test/resources @@ -1 +1 @@ -Subproject commit d083eb21ffbba7dd9fe83cc3d07ffedbf2ba6517 +Subproject commit eed30b2bd69dd7ec726df27ac3fffbae3cb69a00