From ff955982f3a4ab1cfbdf5458ca166fb3876f7a2d Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 20 Feb 2024 15:21:30 +0100 Subject: [PATCH 1/3] add new products --- docs/code_samples/eu_driver_license_v1.txt | 41 +++ .../international_id_v2_async.txt | 41 +++ .../receipts_items_classifier_v1_async.txt | 41 +++ docs/code_samples/resume_v1_async.txt | 41 +++ .../com/mindee/parsing/SummaryHelper.java | 17 ++ .../product/cropper/CropperV1Document.java | 2 - .../eu/driverlicense/DriverLicenseV1.java | 16 ++ .../DriverLicenseV1Document.java | 140 +++++++++ .../eu/driverlicense/DriverLicenseV1Page.java | 49 ++++ .../FinancialDocumentV1LineItem.java | 2 +- .../BankAccountDetailsV2Bban.java | 8 +- .../InternationalIdV1Document.java | 7 +- .../internationalid/InternationalIdV2.java | 16 ++ .../InternationalIdV2Document.java | 196 +++++++++++++ .../ReceiptsItemsClassifierV1.java | 16 ++ .../ReceiptsItemsClassifierV1Document.java | 138 +++++++++ .../ReceiptsItemsClassifierV1LineItem.java | 75 +++++ .../com/mindee/product/resume/ResumeV1.java | 16 ++ .../product/resume/ResumeV1Certificate.java | 69 +++++ .../product/resume/ResumeV1Document.java | 270 ++++++++++++++++++ .../product/resume/ResumeV1Education.java | 93 ++++++ .../product/resume/ResumeV1Language.java | 53 ++++ .../ResumeV1ProfessionalExperience.java | 101 +++++++ .../resume/ResumeV1SocialNetworksUrl.java | 53 ++++ .../mindee/product/us/w9/W9V1Document.java | 2 - .../eu/driverlicense/DriverLicenseV1Test.java | 74 +++++ .../InternationalIdV2Test.java | 66 +++++ .../ReceiptsItemsClassifierV1Test.java | 59 ++++ .../mindee/product/resume/ResumeV1Test.java | 66 +++++ .../product/us/bankcheck/BankCheckV1Test.java | 2 +- .../us/driverlicense/DriverLicenseV1Test.java | 4 +- .../com/mindee/product/us/w9/W9V1Test.java | 29 +- src/test/resources | 2 +- 33 files changed, 1770 insertions(+), 35 deletions(-) create mode 100644 docs/code_samples/eu_driver_license_v1.txt create mode 100644 docs/code_samples/international_id_v2_async.txt create mode 100644 docs/code_samples/receipts_items_classifier_v1_async.txt create mode 100644 docs/code_samples/resume_v1_async.txt create mode 100644 src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1.java create mode 100644 src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Document.java create mode 100644 src/main/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Page.java create mode 100644 src/main/java/com/mindee/product/internationalid/InternationalIdV2.java create mode 100644 src/main/java/com/mindee/product/internationalid/InternationalIdV2Document.java create mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java create mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java create mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Certificate.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Document.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Education.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1Language.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java create mode 100644 src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java create mode 100644 src/test/java/com/mindee/product/eu/driverlicense/DriverLicenseV1Test.java create mode 100644 src/test/java/com/mindee/product/internationalid/InternationalIdV2Test.java create mode 100644 src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java create mode 100644 src/test/java/com/mindee/product/resume/ResumeV1Test.java 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/receipts_items_classifier_v1_async.txt b/docs/code_samples/receipts_items_classifier_v1_async.txt new file mode 100644 index 000000000..f8896aec4 --- /dev/null +++ b/docs/code_samples/receipts_items_classifier_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.receiptsitemsclassifier.ReceiptsItemsClassifierV1; +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( + ReceiptsItemsClassifierV1.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/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/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java new file mode 100644 index 000000000..539e6a388 --- /dev/null +++ b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java @@ -0,0 +1,16 @@ +package com.mindee.product.receiptsitemsclassifier; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.mindee.http.EndpointInfo; +import com.mindee.parsing.common.Inference; +import lombok.Getter; + +/** + * The definition for Receipts Items Classifier, API version 1. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +@EndpointInfo(endpointName = "receipts_items_classifier", version = "1") +public class ReceiptsItemsClassifierV1 + extends Inference { +} diff --git a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java new file mode 100644 index 000000000..f88dcaabc --- /dev/null +++ b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java @@ -0,0 +1,138 @@ +package com.mindee.product.receiptsitemsclassifier; + +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.AmountField; +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 Receipts Items Classifier, API version 1. + */ +@Getter +@EqualsAndHashCode(callSuper = false) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ReceiptsItemsClassifierV1Document extends Prediction { + + /** + * The currency of the receipt in ISO 4217 three-letter code. + */ + @JsonProperty("currency_code") + private StringField currencyCode; + /** + * The category or type of the expense. + */ + @JsonProperty("expense_category") + private ClassificationField expenseCategory; + /** + * The ISO formatted date on which the receipt was issued. + */ + @JsonProperty("issue_date") + private StringField issueDate; + /** + * A list of fields about individual items or services being billed. + */ + @JsonProperty("line_items") + private List lineItems = new ArrayList<>(); + /** + * The address of the merchant. + */ + @JsonProperty("merchant_address") + private StringField merchantAddress; + /** + * The name of the merchant. + */ + @JsonProperty("merchant_name") + private StringField merchantName; + /** + * Whether there are several receipts on the document. + */ + @JsonProperty("multiple_receipts") + private StringField multipleReceipts; + /** + * The tip added on the receipt. + */ + @JsonProperty("tip") + private AmountField tip; + /** + * The sum of all the individual line item amounts, including taxes and discounts. + */ + @JsonProperty("total_amount") + private AmountField totalAmount; + /** + * The total tax of the bought items. + */ + @JsonProperty("total_tax") + private AmountField totalTax; + + @Override + public boolean isEmpty() { + return ( + this.multipleReceipts == null + && this.issueDate == null + && this.expenseCategory == null + && this.merchantName == null + && this.merchantAddress == null + && this.totalAmount == null + && this.tip == null + && this.totalTax == null + && this.currencyCode == null + && (this.lineItems == null || this.lineItems.isEmpty()) + ); + } + + @Override + public String toString() { + StringBuilder outStr = new StringBuilder(); + outStr.append( + String.format(":Multiple Receipts: %s%n", this.getMultipleReceipts()) + ); + outStr.append( + String.format(":Date of Issue: %s%n", this.getIssueDate()) + ); + outStr.append( + String.format(":Expense Type: %s%n", this.getExpenseCategory()) + ); + outStr.append( + String.format(":Merchant: %s%n", this.getMerchantName()) + ); + outStr.append( + String.format(":Merchant address: %s%n", this.getMerchantAddress()) + ); + outStr.append( + String.format(":Total Amount: %s%n", this.getTotalAmount()) + ); + outStr.append( + String.format(":Tip: %s%n", this.getTip()) + ); + outStr.append( + String.format(":Total tax: %s%n", this.getTotalTax()) + ); + outStr.append( + String.format(":Currency: %s%n", this.getCurrencyCode()) + ); + String lineItemsSummary = ""; + if (!this.getLineItems().isEmpty()) { + int[] lineItemsColSizes = new int[]{21, 11, 10, 7}; + lineItemsSummary = + String.format("%n%s%n ", SummaryHelper.lineSeparator(lineItemsColSizes, "-")) + + "| Item Classification " + + "| Item Name " + + "| Quantity " + + "| Price " + + String.format("|%n%s%n ", SummaryHelper.lineSeparator(lineItemsColSizes, "=")); + lineItemsSummary += SummaryHelper.arrayToString(this.getLineItems(), lineItemsColSizes); + lineItemsSummary += String.format("%n%s", SummaryHelper.lineSeparator(lineItemsColSizes, "-")); + } + outStr.append( + String.format(":Line Items: %s%n", lineItemsSummary) + ); + return SummaryHelper.cleanSummary(outStr.toString()); + } +} diff --git a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java new file mode 100644 index 000000000..6f869ede5 --- /dev/null +++ b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java @@ -0,0 +1,75 @@ +package com.mindee.product.receiptsitemsclassifier; + +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; + +/** + * A list of fields about individual items or services being billed. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ReceiptsItemsClassifierV1LineItem extends BaseField implements LineItemField { + + /** + * The class or type of item. + */ + @JsonProperty("item_classification") + String itemClassification; + /** + * The name or description of a specific item or product being invoiced. + */ + @JsonProperty("item_name") + String itemName; + /** + * The number of units of a specific item that were purchased or sold. + */ + @JsonProperty("quantity") + Double quantity; + /** + * The total cost of a specific item or service, including any applicable taxes or discounts. + */ + @JsonProperty("total_price") + Double totalPrice; + + /** + * Output the line in a format suitable for inclusion in an rST table. + */ + public String toTableLine() { + Map printable = this.printableValues(); + return String.format("| %-19s ", printable.get("itemClassification")) + + String.format("| %-9s ", printable.get("itemName")) + + String.format("| %-8s ", printable.get("quantity")) + + String.format("| %-5s |", printable.get("totalPrice")); + } + + @Override + public String toString() { + Map printable = this.printableValues(); + return String.format("Item Classification: %s", printable.get("itemClassification")) + + String.format(", Item Name: %s", printable.get("itemName")) + + String.format(", Quantity: %s", printable.get("quantity")) + + String.format(", Price: %s", printable.get("totalPrice")); + } + + private Map printableValues() { + Map printable = new HashMap<>(); + + printable.put("itemClassification", SummaryHelper.formatForDisplay(this.itemClassification, null)); + printable.put("itemName", SummaryHelper.formatForDisplay(this.itemName, null)); + printable.put( + "quantity", + SummaryHelper.formatAmount(this.quantity) + ); + printable.put( + "totalPrice", + SummaryHelper.formatAmount(this.totalPrice) + ); + return printable; + } +} 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..9a25aedc0 --- /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 certifications obtained by the individual. + */ + @JsonProperty("name") + String name; + /** + * The organization or institution that issued the certificates listed in the document. + */ + @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..5e97ffaee --- /dev/null +++ b/src/main/java/com/mindee/product/resume/ResumeV1Document.java @@ -0,0 +1,270 @@ +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.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 person, 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, possible values being RESUME, MOTIVATION_LETTER and RECOMMENDATION_LETTER. + */ + @JsonProperty("document_type") + private StringField documentType; + /** + * The list of values that represent the educational background of an individual. + */ + @JsonProperty("education") + private List education = new ArrayList<>(); + /** + * The email address of the candidate. + */ + @JsonProperty("email_address") + private StringField emailAddress; + /** + * The list of names that represent a person's first or given names. + */ + @JsonProperty("given_names") + private List givenNames = new ArrayList<>(); + /** + * The list of specific technical abilities and knowledge mentioned in a resume. + */ + @JsonProperty("hard_skills") + private List hardSkills = new ArrayList<>(); + /** + * The specific industry or job role that the applicant is applying for. + */ + @JsonProperty("job_applied") + private StringField jobApplied; + /** + * The list of languages that a person is proficient in, as stated in their resume. + */ + @JsonProperty("languages") + private List languages = new ArrayList<>(); + /** + * The ISO 3166 code for the country of citizenship or origin of the person. + */ + @JsonProperty("nationality") + private StringField nationality; + /** + * The phone number of the candidate. + */ + @JsonProperty("phone_number") + private StringField phoneNumber; + /** + * The area of expertise or specialization in which the individual has professional experience and qualifications. + */ + @JsonProperty("profession") + private StringField profession; + /** + * The list of values that represent the professional experiences of an individual in their global resume. + */ + @JsonProperty("professional_experiences") + private List professionalExperiences = new ArrayList<>(); + /** + * The list of URLs for social network profiles of the person. + */ + @JsonProperty("social_networks_urls") + private List socialNetworksUrls = new ArrayList<>(); + /** + * The list of values that represent a person's interpersonal and communication abilities in a global resume. + */ + @JsonProperty("soft_skills") + private List softSkills = new ArrayList<>(); + /** + * The list of last names provided in a resume document. + */ + @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..c218e03c4 --- /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 values that represent the educational background of an individual. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Education extends BaseField implements LineItemField { + + /** + * The area of study or specialization pursued by an individual in their educational background. + */ + @JsonProperty("degree_domain") + String degreeDomain; + /** + * The type of degree obtained by the individual, such as Bachelor's, Master's, or Doctorate. + */ + @JsonProperty("degree_type") + String degreeType; + /** + * The month when the education program or course was completed or is expected to be completed. + */ + @JsonProperty("end_month") + String endMonth; + /** + * The year when the education program or course was completed or is expected to be completed. + */ + @JsonProperty("end_year") + String endYear; + /** + * The name of the school the individual went to. + */ + @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..af7fbcecc --- /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 a person is proficient in, as stated in their resume. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1Language extends BaseField implements LineItemField { + + /** + * The language ISO 639 code. + */ + @JsonProperty("language") + String language; + /** + * The level for the language. Possible values: 'Fluent', 'Proficient', 'Intermediate' and 'Beginner'. + */ + @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..a777da4f9 --- /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 values that represent the professional experiences of an individual in their global resume. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1ProfessionalExperience extends BaseField implements LineItemField { + + /** + * The type of contract for a professional experience. Possible values: 'Full-Time', 'Part-Time', 'Internship' and 'Freelance'. + */ + @JsonProperty("contract_type") + String contractType; + /** + * The specific department or division within a company where the professional experience was gained. + */ + @JsonProperty("department") + String department; + /** + * The name of the company or organization where the candidate has worked. + */ + @JsonProperty("employer") + String employer; + /** + * The month when a professional experience ended. + */ + @JsonProperty("end_month") + String endMonth; + /** + * The year when a professional experience ended. + */ + @JsonProperty("end_year") + String endYear; + /** + * The position or job title held by the individual in their previous work experience. + */ + @JsonProperty("role") + String role; + /** + * The month when a professional experience began. + */ + @JsonProperty("start_month") + String startMonth; + /** + * The year when a 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..4d3e793a2 --- /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 URLs for social network profiles of the person. + */ +@Getter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ResumeV1SocialNetworksUrl extends BaseField implements LineItemField { + + /** + * The name of of the social media concerned. + */ + @JsonProperty("name") + String name; + /** + * The URL of the profile for this particular 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/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java b/src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java new file mode 100644 index 000000000..ca396c716 --- /dev/null +++ b/src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java @@ -0,0 +1,59 @@ +package com.mindee.product.receiptsitemsclassifier; + +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 ReceiptsItemsClassifierV1. + */ +public class ReceiptsItemsClassifierV1Test { + + protected PredictResponse getPrediction(String name) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.findAndRegisterModules(); + + JavaType type = objectMapper.getTypeFactory().constructParametricType( + PredictResponse.class, + ReceiptsItemsClassifierV1.class + ); + return objectMapper.readValue( + new File("src/test/resources/products/receipts_items_classifier/response_v1/" + name + ".json"), + type + ); + } + + @Test + void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { + PredictResponse response = getPrediction("empty"); + ReceiptsItemsClassifierV1Document docPrediction = response.getDocument().getInference().getPrediction(); + Assertions.assertNull(docPrediction.getMultipleReceipts().getValue()); + Assertions.assertNull(docPrediction.getIssueDate().getValue()); + Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getExpenseCategory()); + Assertions.assertNull(docPrediction.getMerchantName().getValue()); + Assertions.assertNull(docPrediction.getMerchantAddress().getValue()); + Assertions.assertNull(docPrediction.getTotalAmount().getValue()); + Assertions.assertNull(docPrediction.getTip().getValue()); + Assertions.assertNull(docPrediction.getTotalTax().getValue()); + Assertions.assertNull(docPrediction.getCurrencyCode().getValue()); + Assertions.assertTrue(docPrediction.getLineItems().isEmpty()); + } + + @Test + void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { + PredictResponse response = getPrediction("complete"); + Document doc = response.getDocument(); + ProductTestHelper.assertStringEqualsFile( + doc.toString(), + "src/test/resources/products/receipts_items_classifier/response_v1/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..82ffb924e --- /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.assertNull(docPrediction.getDocumentType().getValue()); + 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 From d43ad4e70ccb0f0dc872577cf257915ffe562d6b Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Wed, 21 Feb 2024 10:07:37 +0100 Subject: [PATCH 2/3] remove classifier --- .../receipts_items_classifier_v1_async.txt | 41 ------ .../ReceiptsItemsClassifierV1.java | 16 -- .../ReceiptsItemsClassifierV1Document.java | 138 ------------------ .../ReceiptsItemsClassifierV1LineItem.java | 75 ---------- .../ReceiptsItemsClassifierV1Test.java | 59 -------- 5 files changed, 329 deletions(-) delete mode 100644 docs/code_samples/receipts_items_classifier_v1_async.txt delete mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java delete mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java delete mode 100644 src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java delete mode 100644 src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java diff --git a/docs/code_samples/receipts_items_classifier_v1_async.txt b/docs/code_samples/receipts_items_classifier_v1_async.txt deleted file mode 100644 index f8896aec4..000000000 --- a/docs/code_samples/receipts_items_classifier_v1_async.txt +++ /dev/null @@ -1,41 +0,0 @@ -import com.mindee.MindeeClient; -import com.mindee.input.LocalInputSource; -import com.mindee.parsing.common.AsyncPredictResponse; -import com.mindee.product.receiptsitemsclassifier.ReceiptsItemsClassifierV1; -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( - ReceiptsItemsClassifierV1.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/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java deleted file mode 100644 index 539e6a388..000000000 --- a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mindee.product.receiptsitemsclassifier; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.mindee.http.EndpointInfo; -import com.mindee.parsing.common.Inference; -import lombok.Getter; - -/** - * The definition for Receipts Items Classifier, API version 1. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -@EndpointInfo(endpointName = "receipts_items_classifier", version = "1") -public class ReceiptsItemsClassifierV1 - extends Inference { -} diff --git a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java deleted file mode 100644 index f88dcaabc..000000000 --- a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Document.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.mindee.product.receiptsitemsclassifier; - -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.AmountField; -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 Receipts Items Classifier, API version 1. - */ -@Getter -@EqualsAndHashCode(callSuper = false) -@JsonIgnoreProperties(ignoreUnknown = true) -public class ReceiptsItemsClassifierV1Document extends Prediction { - - /** - * The currency of the receipt in ISO 4217 three-letter code. - */ - @JsonProperty("currency_code") - private StringField currencyCode; - /** - * The category or type of the expense. - */ - @JsonProperty("expense_category") - private ClassificationField expenseCategory; - /** - * The ISO formatted date on which the receipt was issued. - */ - @JsonProperty("issue_date") - private StringField issueDate; - /** - * A list of fields about individual items or services being billed. - */ - @JsonProperty("line_items") - private List lineItems = new ArrayList<>(); - /** - * The address of the merchant. - */ - @JsonProperty("merchant_address") - private StringField merchantAddress; - /** - * The name of the merchant. - */ - @JsonProperty("merchant_name") - private StringField merchantName; - /** - * Whether there are several receipts on the document. - */ - @JsonProperty("multiple_receipts") - private StringField multipleReceipts; - /** - * The tip added on the receipt. - */ - @JsonProperty("tip") - private AmountField tip; - /** - * The sum of all the individual line item amounts, including taxes and discounts. - */ - @JsonProperty("total_amount") - private AmountField totalAmount; - /** - * The total tax of the bought items. - */ - @JsonProperty("total_tax") - private AmountField totalTax; - - @Override - public boolean isEmpty() { - return ( - this.multipleReceipts == null - && this.issueDate == null - && this.expenseCategory == null - && this.merchantName == null - && this.merchantAddress == null - && this.totalAmount == null - && this.tip == null - && this.totalTax == null - && this.currencyCode == null - && (this.lineItems == null || this.lineItems.isEmpty()) - ); - } - - @Override - public String toString() { - StringBuilder outStr = new StringBuilder(); - outStr.append( - String.format(":Multiple Receipts: %s%n", this.getMultipleReceipts()) - ); - outStr.append( - String.format(":Date of Issue: %s%n", this.getIssueDate()) - ); - outStr.append( - String.format(":Expense Type: %s%n", this.getExpenseCategory()) - ); - outStr.append( - String.format(":Merchant: %s%n", this.getMerchantName()) - ); - outStr.append( - String.format(":Merchant address: %s%n", this.getMerchantAddress()) - ); - outStr.append( - String.format(":Total Amount: %s%n", this.getTotalAmount()) - ); - outStr.append( - String.format(":Tip: %s%n", this.getTip()) - ); - outStr.append( - String.format(":Total tax: %s%n", this.getTotalTax()) - ); - outStr.append( - String.format(":Currency: %s%n", this.getCurrencyCode()) - ); - String lineItemsSummary = ""; - if (!this.getLineItems().isEmpty()) { - int[] lineItemsColSizes = new int[]{21, 11, 10, 7}; - lineItemsSummary = - String.format("%n%s%n ", SummaryHelper.lineSeparator(lineItemsColSizes, "-")) - + "| Item Classification " - + "| Item Name " - + "| Quantity " - + "| Price " - + String.format("|%n%s%n ", SummaryHelper.lineSeparator(lineItemsColSizes, "=")); - lineItemsSummary += SummaryHelper.arrayToString(this.getLineItems(), lineItemsColSizes); - lineItemsSummary += String.format("%n%s", SummaryHelper.lineSeparator(lineItemsColSizes, "-")); - } - outStr.append( - String.format(":Line Items: %s%n", lineItemsSummary) - ); - return SummaryHelper.cleanSummary(outStr.toString()); - } -} diff --git a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java b/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java deleted file mode 100644 index 6f869ede5..000000000 --- a/src/main/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1LineItem.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mindee.product.receiptsitemsclassifier; - -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; - -/** - * A list of fields about individual items or services being billed. - */ -@Getter -@JsonIgnoreProperties(ignoreUnknown = true) -public class ReceiptsItemsClassifierV1LineItem extends BaseField implements LineItemField { - - /** - * The class or type of item. - */ - @JsonProperty("item_classification") - String itemClassification; - /** - * The name or description of a specific item or product being invoiced. - */ - @JsonProperty("item_name") - String itemName; - /** - * The number of units of a specific item that were purchased or sold. - */ - @JsonProperty("quantity") - Double quantity; - /** - * The total cost of a specific item or service, including any applicable taxes or discounts. - */ - @JsonProperty("total_price") - Double totalPrice; - - /** - * Output the line in a format suitable for inclusion in an rST table. - */ - public String toTableLine() { - Map printable = this.printableValues(); - return String.format("| %-19s ", printable.get("itemClassification")) - + String.format("| %-9s ", printable.get("itemName")) - + String.format("| %-8s ", printable.get("quantity")) - + String.format("| %-5s |", printable.get("totalPrice")); - } - - @Override - public String toString() { - Map printable = this.printableValues(); - return String.format("Item Classification: %s", printable.get("itemClassification")) - + String.format(", Item Name: %s", printable.get("itemName")) - + String.format(", Quantity: %s", printable.get("quantity")) - + String.format(", Price: %s", printable.get("totalPrice")); - } - - private Map printableValues() { - Map printable = new HashMap<>(); - - printable.put("itemClassification", SummaryHelper.formatForDisplay(this.itemClassification, null)); - printable.put("itemName", SummaryHelper.formatForDisplay(this.itemName, null)); - printable.put( - "quantity", - SummaryHelper.formatAmount(this.quantity) - ); - printable.put( - "totalPrice", - SummaryHelper.formatAmount(this.totalPrice) - ); - return printable; - } -} diff --git a/src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java b/src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java deleted file mode 100644 index ca396c716..000000000 --- a/src/test/java/com/mindee/product/receiptsitemsclassifier/ReceiptsItemsClassifierV1Test.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mindee.product.receiptsitemsclassifier; - -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 ReceiptsItemsClassifierV1. - */ -public class ReceiptsItemsClassifierV1Test { - - protected PredictResponse getPrediction(String name) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.findAndRegisterModules(); - - JavaType type = objectMapper.getTypeFactory().constructParametricType( - PredictResponse.class, - ReceiptsItemsClassifierV1.class - ); - return objectMapper.readValue( - new File("src/test/resources/products/receipts_items_classifier/response_v1/" + name + ".json"), - type - ); - } - - @Test - void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { - PredictResponse response = getPrediction("empty"); - ReceiptsItemsClassifierV1Document docPrediction = response.getDocument().getInference().getPrediction(); - Assertions.assertNull(docPrediction.getMultipleReceipts().getValue()); - Assertions.assertNull(docPrediction.getIssueDate().getValue()); - Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getExpenseCategory()); - Assertions.assertNull(docPrediction.getMerchantName().getValue()); - Assertions.assertNull(docPrediction.getMerchantAddress().getValue()); - Assertions.assertNull(docPrediction.getTotalAmount().getValue()); - Assertions.assertNull(docPrediction.getTip().getValue()); - Assertions.assertNull(docPrediction.getTotalTax().getValue()); - Assertions.assertNull(docPrediction.getCurrencyCode().getValue()); - Assertions.assertTrue(docPrediction.getLineItems().isEmpty()); - } - - @Test - void whenCompleteDeserialized_mustHaveValidDocumentSummary() throws IOException { - PredictResponse response = getPrediction("complete"); - Document doc = response.getDocument(); - ProductTestHelper.assertStringEqualsFile( - doc.toString(), - "src/test/resources/products/receipts_items_classifier/response_v1/summary_full.rst" - ); - } - -} From db1c49eaea6b228fa49807975dfbf6fe6c7e1261 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Wed, 21 Feb 2024 14:41:47 +0100 Subject: [PATCH 3/3] update resule + fix slack links --- README.md | 2 +- docs/java-api-builder.md | 2 +- docs/java-field.md | 2 +- docs/java-financial-document-ocr.md | 2 +- docs/java-getting-started.md | 2 +- docs/java-invoice-ocr.md | 2 +- docs/java-license-plates-ocr.md | 2 +- docs/java-passport-ocr.md | 2 +- docs/java-proof-of-address-ocr.md | 2 +- docs/java-receipt-ocr.md | 2 +- docs/java-us-bank-check-ocr.md | 2 +- .../product/resume/ResumeV1Certificate.java | 4 +-- .../product/resume/ResumeV1Document.java | 29 ++++++++++--------- .../product/resume/ResumeV1Education.java | 12 ++++---- .../product/resume/ResumeV1Language.java | 6 ++-- .../ResumeV1ProfessionalExperience.java | 18 ++++++------ .../resume/ResumeV1SocialNetworksUrl.java | 6 ++-- .../mindee/product/resume/ResumeV1Test.java | 2 +- 18 files changed, 50 insertions(+), 49 deletions(-) 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/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/product/resume/ResumeV1Certificate.java b/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java index 9a25aedc0..30c27d137 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1Certificate.java @@ -22,12 +22,12 @@ public class ResumeV1Certificate extends BaseField implements LineItemField { @JsonProperty("grade") String grade; /** - * The name of certifications obtained by the individual. + * The name of certification. */ @JsonProperty("name") String name; /** - * The organization or institution that issued the certificates listed in the document. + * The organization or institution that issued the certificate. */ @JsonProperty("provider") String provider; diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Document.java b/src/main/java/com/mindee/product/resume/ResumeV1Document.java index 5e97ffaee..7d3184b66 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1Document.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1Document.java @@ -4,6 +4,7 @@ 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; @@ -19,7 +20,7 @@ public class ResumeV1Document extends Prediction { /** - * The location information of the person, including city, state, and country. + * The location information of the candidate, including city, state, and country. */ @JsonProperty("address") private StringField address; @@ -34,12 +35,12 @@ public class ResumeV1Document extends Prediction { @JsonProperty("document_language") private StringField documentLanguage; /** - * The type of the document sent, possible values being RESUME, MOTIVATION_LETTER and RECOMMENDATION_LETTER. + * The type of the document sent. */ @JsonProperty("document_type") - private StringField documentType; + private ClassificationField documentType; /** - * The list of values that represent the educational background of an individual. + * The list of the candidate's educational background. */ @JsonProperty("education") private List education = new ArrayList<>(); @@ -49,27 +50,27 @@ public class ResumeV1Document extends Prediction { @JsonProperty("email_address") private StringField emailAddress; /** - * The list of names that represent a person's first or given names. + * The candidate's first or given names. */ @JsonProperty("given_names") private List givenNames = new ArrayList<>(); /** - * The list of specific technical abilities and knowledge mentioned in a resume. + * The list of the candidate's technical abilities and knowledge. */ @JsonProperty("hard_skills") private List hardSkills = new ArrayList<>(); /** - * The specific industry or job role that the applicant is applying for. + * The position that the candidate is applying for. */ @JsonProperty("job_applied") private StringField jobApplied; /** - * The list of languages that a person is proficient in, as stated in their resume. + * 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 or origin of the person. + * The ISO 3166 code for the country of citizenship of the candidate. */ @JsonProperty("nationality") private StringField nationality; @@ -79,27 +80,27 @@ public class ResumeV1Document extends Prediction { @JsonProperty("phone_number") private StringField phoneNumber; /** - * The area of expertise or specialization in which the individual has professional experience and qualifications. + * The candidate's current profession. */ @JsonProperty("profession") private StringField profession; /** - * The list of values that represent the professional experiences of an individual in their global resume. + * The list of the candidate's professional experiences. */ @JsonProperty("professional_experiences") private List professionalExperiences = new ArrayList<>(); /** - * The list of URLs for social network profiles of the person. + * The list of social network profiles of the candidate. */ @JsonProperty("social_networks_urls") private List socialNetworksUrls = new ArrayList<>(); /** - * The list of values that represent a person's interpersonal and communication abilities in a global resume. + * The list of the candidate's interpersonal and communication abilities. */ @JsonProperty("soft_skills") private List softSkills = new ArrayList<>(); /** - * The list of last names provided in a resume document. + * The candidate's last names. */ @JsonProperty("surnames") private List surnames = new ArrayList<>(); diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Education.java b/src/main/java/com/mindee/product/resume/ResumeV1Education.java index c218e03c4..1a26428f1 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1Education.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1Education.java @@ -10,34 +10,34 @@ import lombok.Getter; /** - * The list of values that represent the educational background of an individual. + * 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 pursued by an individual in their educational background. + * The area of study or specialization. */ @JsonProperty("degree_domain") String degreeDomain; /** - * The type of degree obtained by the individual, such as Bachelor's, Master's, or Doctorate. + * 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 or is expected to be completed. + * 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 or is expected to be completed. + * The year when the education program or course was completed. */ @JsonProperty("end_year") String endYear; /** - * The name of the school the individual went to. + * The name of the school. */ @JsonProperty("school") String school; diff --git a/src/main/java/com/mindee/product/resume/ResumeV1Language.java b/src/main/java/com/mindee/product/resume/ResumeV1Language.java index af7fbcecc..3e5907f60 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1Language.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1Language.java @@ -10,19 +10,19 @@ import lombok.Getter; /** - * The list of languages that a person is proficient in, as stated in their resume. + * The list of languages that the candidate is proficient in. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) public class ResumeV1Language extends BaseField implements LineItemField { /** - * The language ISO 639 code. + * The language's ISO 639 code. */ @JsonProperty("language") String language; /** - * The level for the language. Possible values: 'Fluent', 'Proficient', 'Intermediate' and 'Beginner'. + * The candidate's level for the language. */ @JsonProperty("level") String level; diff --git a/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java b/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java index a777da4f9..f3afe85be 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1ProfessionalExperience.java @@ -10,49 +10,49 @@ import lombok.Getter; /** - * The list of values that represent the professional experiences of an individual in their global resume. + * The list of the candidate's professional experiences. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) public class ResumeV1ProfessionalExperience extends BaseField implements LineItemField { /** - * The type of contract for a professional experience. Possible values: 'Full-Time', 'Part-Time', 'Internship' and 'Freelance'. + * The type of contract for the professional experience. */ @JsonProperty("contract_type") String contractType; /** - * The specific department or division within a company where the professional experience was gained. + * The specific department or division within the company. */ @JsonProperty("department") String department; /** - * The name of the company or organization where the candidate has worked. + * The name of the company or organization. */ @JsonProperty("employer") String employer; /** - * The month when a professional experience ended. + * The month when the professional experience ended. */ @JsonProperty("end_month") String endMonth; /** - * The year when a professional experience ended. + * The year when the professional experience ended. */ @JsonProperty("end_year") String endYear; /** - * The position or job title held by the individual in their previous work experience. + * The position or job title held by the candidate. */ @JsonProperty("role") String role; /** - * The month when a professional experience began. + * The month when the professional experience began. */ @JsonProperty("start_month") String startMonth; /** - * The year when a professional experience began. + * The year when the professional experience began. */ @JsonProperty("start_year") String startYear; diff --git a/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java b/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java index 4d3e793a2..e02fbe0db 100644 --- a/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java +++ b/src/main/java/com/mindee/product/resume/ResumeV1SocialNetworksUrl.java @@ -10,19 +10,19 @@ import lombok.Getter; /** - * The list of URLs for social network profiles of the person. + * The list of social network profiles of the candidate. */ @Getter @JsonIgnoreProperties(ignoreUnknown = true) public class ResumeV1SocialNetworksUrl extends BaseField implements LineItemField { /** - * The name of of the social media concerned. + * The name of the social network. */ @JsonProperty("name") String name; /** - * The URL of the profile for this particular social network. + * The URL of the social network. */ @JsonProperty("url") String url; diff --git a/src/test/java/com/mindee/product/resume/ResumeV1Test.java b/src/test/java/com/mindee/product/resume/ResumeV1Test.java index 82ffb924e..9be4ac18a 100644 --- a/src/test/java/com/mindee/product/resume/ResumeV1Test.java +++ b/src/test/java/com/mindee/product/resume/ResumeV1Test.java @@ -35,7 +35,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { PredictResponse response = getPrediction("empty"); ResumeV1Document docPrediction = response.getDocument().getInference().getPrediction(); Assertions.assertNull(docPrediction.getDocumentLanguage().getValue()); - Assertions.assertNull(docPrediction.getDocumentType().getValue()); + Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType()); Assertions.assertTrue(docPrediction.getGivenNames().isEmpty()); Assertions.assertTrue(docPrediction.getSurnames().isEmpty()); Assertions.assertNull(docPrediction.getNationality().getValue());