mindee 3.3.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +6 -1
- package/package.json +19 -19
- package/src/api/index.d.ts +1 -1
- package/src/api/response.d.ts +3 -0
- package/src/client.d.ts +4 -4
- package/src/client.js +1 -1
- package/src/documents/{custom.d.ts → custom/customV1.d.ts} +4 -4
- package/src/documents/{custom.js → custom/customV1.js} +2 -2
- package/src/{fields/apiBuilder.d.ts → documents/custom/fields.d.ts} +8 -6
- package/src/{fields/apiBuilder.js → documents/custom/fields.js} +1 -1
- package/src/documents/document.d.ts +5 -5
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +2 -2
- package/src/documents/eu/licensePlate/licensePlateV1.js +3 -2
- package/src/documents/financialDocument/financialDocumentV1.d.ts +9 -9
- package/src/documents/financialDocument/financialDocumentV1.js +5 -5
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +4 -4
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +3 -3
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +4 -4
- package/src/documents/fr/carteVitale/carteVitaleV1.js +4 -3
- package/src/documents/fr/idCard/idCardV1.d.ts +9 -9
- package/src/documents/fr/idCard/idCardV1.js +8 -8
- package/src/documents/index.d.ts +1 -1
- package/src/documents/index.js +2 -2
- package/src/documents/invoice/invoiceLineItem.d.ts +2 -2
- package/src/documents/invoice/invoiceLineItem.js +2 -2
- package/src/documents/invoice/invoiceV3.d.ts +7 -7
- package/src/documents/invoice/invoiceV3.js +21 -21
- package/src/documents/invoice/invoiceV4.d.ts +8 -8
- package/src/documents/invoice/invoiceV4.js +18 -6
- package/src/documents/invoice/reconstruction.js +5 -4
- package/src/documents/passport/passportV1.d.ts +11 -11
- package/src/documents/passport/passportV1.js +16 -14
- package/src/documents/receipt/receiptV3.d.ts +4 -4
- package/src/documents/receipt/receiptV3.js +6 -7
- package/src/documents/receipt/receiptV4.d.ts +8 -4
- package/src/documents/receipt/receiptV4.js +14 -5
- package/src/documents/receipt/tax.d.ts +3 -3
- package/src/documents/receipt/tax.js +7 -7
- package/src/documents/shipping_container/shippingContainerV1.d.ts +4 -4
- package/src/documents/shipping_container/shippingContainerV1.js +4 -3
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +5 -5
- package/src/documents/us/bankCheck/bankCheckV1.js +4 -4
- package/src/fields/amount.d.ts +1 -1
- package/src/fields/amount.js +7 -4
- package/src/fields/base.d.ts +27 -0
- package/src/fields/base.js +53 -0
- package/src/fields/companyRegistration.d.ts +3 -1
- package/src/fields/date.d.ts +4 -1
- package/src/fields/date.js +16 -8
- package/src/fields/field.d.ts +8 -38
- package/src/fields/field.js +6 -53
- package/src/fields/fullText.d.ts +3 -3
- package/src/fields/fullText.js +4 -4
- package/src/fields/index.d.ts +3 -3
- package/src/fields/index.js +5 -8
- package/src/fields/locale.d.ts +13 -9
- package/src/fields/locale.js +4 -3
- package/src/fields/orientation.d.ts +3 -1
- package/src/fields/orientation.js +2 -2
- package/src/fields/paymentDetails.d.ts +4 -1
- package/src/fields/paymentDetails.js +26 -23
- package/src/fields/position.d.ts +2 -2
- package/src/fields/tax.d.ts +4 -3
- package/src/fields/tax.js +2 -2
- package/src/fields/text.d.ts +13 -0
- package/src/fields/text.js +10 -0
- package/src/geometry.d.ts +4 -5
- package/src/index.d.ts +4 -3
- package/src/index.js +5 -1
- package/src/inputs/sources.d.ts +4 -4
- package/src/inputs/sources.js +9 -9
|
@@ -13,11 +13,11 @@ class BankCheckV1 extends document_1.Document {
|
|
|
13
13
|
});
|
|
14
14
|
/** List of payees (full name or company name). */
|
|
15
15
|
this.payees = [];
|
|
16
|
-
this.accountNumber = new fields_1.
|
|
16
|
+
this.accountNumber = new fields_1.TextField({
|
|
17
17
|
prediction: prediction.account_number,
|
|
18
18
|
pageId: pageId,
|
|
19
19
|
});
|
|
20
|
-
this.checkNumber = new fields_1.
|
|
20
|
+
this.checkNumber = new fields_1.TextField({
|
|
21
21
|
prediction: prediction.check_number,
|
|
22
22
|
pageId: pageId,
|
|
23
23
|
});
|
|
@@ -34,11 +34,11 @@ class BankCheckV1 extends document_1.Document {
|
|
|
34
34
|
prediction: prediction.date,
|
|
35
35
|
pageId: pageId,
|
|
36
36
|
});
|
|
37
|
-
prediction.payees.map((prediction) => this.payees.push(new fields_1.
|
|
37
|
+
prediction.payees.map((prediction) => this.payees.push(new fields_1.TextField({
|
|
38
38
|
prediction: prediction,
|
|
39
39
|
pageId: pageId,
|
|
40
40
|
})));
|
|
41
|
-
this.routingNumber = new fields_1.
|
|
41
|
+
this.routingNumber = new fields_1.TextField({
|
|
42
42
|
prediction: prediction.routing_number,
|
|
43
43
|
pageId: pageId,
|
|
44
44
|
});
|
package/src/fields/amount.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Field, FieldConstructor } from "./field";
|
|
|
2
2
|
export declare function floatToString(value: number): string;
|
|
3
3
|
export declare class Amount extends Field {
|
|
4
4
|
/** The value. */
|
|
5
|
-
value
|
|
5
|
+
value?: number;
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
package/src/fields/amount.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Amount = exports.floatToString = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
5
|
function floatToString(value) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
return value.toLocaleString(undefined, {
|
|
7
|
+
minimumFractionDigits: 2,
|
|
8
|
+
maximumFractionDigits: 3,
|
|
9
|
+
useGrouping: false,
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
12
|
exports.floatToString = floatToString;
|
|
12
13
|
class Amount extends field_1.Field {
|
|
@@ -18,6 +19,8 @@ class Amount extends field_1.Field {
|
|
|
18
19
|
*/
|
|
19
20
|
constructor({ prediction, valueKey = "amount", reconstructed = false, pageId = undefined, }) {
|
|
20
21
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
22
|
+
/** The value. */
|
|
23
|
+
this.value = undefined;
|
|
21
24
|
this.value = +parseFloat(prediction[valueKey]).toFixed(3);
|
|
22
25
|
if (isNaN(this.value)) {
|
|
23
26
|
this.value = undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type StringDict = {
|
|
2
|
+
[index: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export interface BaseFieldConstructor {
|
|
5
|
+
prediction: StringDict;
|
|
6
|
+
valueKey?: string;
|
|
7
|
+
reconstructed?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class BaseField {
|
|
10
|
+
/** The value. */
|
|
11
|
+
value?: string | number;
|
|
12
|
+
/** `true` when the field was reconstructed or computed using other fields. */
|
|
13
|
+
reconstructed: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
16
|
+
* @param {String} valueKey - Key to use in the prediction dict
|
|
17
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
18
|
+
*/
|
|
19
|
+
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
20
|
+
compare(other: BaseField): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @param {BaseField[]} array - Array of Fields
|
|
23
|
+
* @returns {Number} Sum of all the Fields values in the array
|
|
24
|
+
*/
|
|
25
|
+
static arraySum(array: BaseField[]): number;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseField = void 0;
|
|
4
|
+
class BaseField {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
7
|
+
* @param {String} valueKey - Key to use in the prediction dict
|
|
8
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
9
|
+
*/
|
|
10
|
+
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
11
|
+
/** The value. */
|
|
12
|
+
this.value = undefined;
|
|
13
|
+
this.reconstructed = reconstructed;
|
|
14
|
+
if (prediction !== undefined &&
|
|
15
|
+
prediction !== null &&
|
|
16
|
+
valueKey in prediction &&
|
|
17
|
+
prediction[valueKey] !== null) {
|
|
18
|
+
this.value = prediction[valueKey];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
compare(other) {
|
|
22
|
+
if (this.value === null && other.value === null)
|
|
23
|
+
return true;
|
|
24
|
+
if (this.value === null || other.value === null)
|
|
25
|
+
return false;
|
|
26
|
+
if (typeof this.value === "string" && typeof other.value === "string") {
|
|
27
|
+
return this.value.toLowerCase() === other.value.toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
return this.value === other.value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {BaseField[]} array - Array of Fields
|
|
33
|
+
* @returns {Number} Sum of all the Fields values in the array
|
|
34
|
+
*/
|
|
35
|
+
static arraySum(array) {
|
|
36
|
+
let total = 0.0;
|
|
37
|
+
for (const field of array) {
|
|
38
|
+
if (typeof field.value !== "number")
|
|
39
|
+
return 0.0;
|
|
40
|
+
total += field.value;
|
|
41
|
+
if (isNaN(total))
|
|
42
|
+
return 0.0;
|
|
43
|
+
}
|
|
44
|
+
return total;
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
if (this.value !== undefined) {
|
|
48
|
+
return `${this.value}`;
|
|
49
|
+
}
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.BaseField = BaseField;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare class CompanyRegistration extends Field {
|
|
3
|
-
/**
|
|
3
|
+
/** Registration identifier. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Type of company registration. */
|
|
4
6
|
type: string;
|
|
5
7
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
6
8
|
}
|
package/src/fields/date.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare class DateField extends Field {
|
|
3
|
+
/** Date string in ISO format. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Date as a standard JavaScript `Date` object. */
|
|
6
|
+
dateObject?: Date;
|
|
3
7
|
/**
|
|
4
8
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
5
9
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
6
10
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
7
11
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
8
12
|
*/
|
|
9
|
-
dateObject: Date | undefined;
|
|
10
13
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
11
14
|
static compareDates(date1: Date, date2: Date): boolean;
|
|
12
15
|
}
|
package/src/fields/date.js
CHANGED
|
@@ -3,16 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DateField = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
5
|
class DateField extends field_1.Field {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
|
+
* @param {String} valueKey - Key to use in the prediction dict
|
|
9
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
10
|
+
* @param {Integer} pageId - Page ID for multi-page document
|
|
11
|
+
*/
|
|
6
12
|
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
7
13
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.dateObject
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (typeof this.value === "string") {
|
|
15
|
+
this.dateObject = new Date(this.value);
|
|
16
|
+
if (isNaN(this.dateObject.valueOf())) {
|
|
17
|
+
this.dateObject = undefined;
|
|
18
|
+
this.confidence = 0.0;
|
|
19
|
+
this.value = undefined;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.dateObject.setUTCHours(0, 0, 0, 0);
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
static compareDates(date1, date2) {
|
package/src/fields/field.d.ts
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
+
import { StringDict, BaseField } from "./base";
|
|
1
2
|
import { Polygon } from "../geometry";
|
|
2
|
-
export declare type stringDict = {
|
|
3
|
-
[index: string]: any;
|
|
4
|
-
};
|
|
5
3
|
export interface FieldConstructor {
|
|
6
|
-
prediction:
|
|
4
|
+
prediction: StringDict;
|
|
7
5
|
valueKey?: string;
|
|
8
6
|
reconstructed?: boolean;
|
|
9
7
|
pageId?: number | undefined;
|
|
10
8
|
}
|
|
11
|
-
export interface BaseFieldConstructor {
|
|
12
|
-
prediction: stringDict;
|
|
13
|
-
valueKey?: string;
|
|
14
|
-
reconstructed?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare class BaseField {
|
|
17
|
-
/** The value. */
|
|
18
|
-
value?: any;
|
|
19
|
-
/**
|
|
20
|
-
* True if the field was reconstructed or computed using other fields.
|
|
21
|
-
*/
|
|
22
|
-
reconstructed: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* @param {Object} prediction - Prediction object from HTTP response
|
|
25
|
-
* @param {String} valueKey - Key to use in the prediction dict
|
|
26
|
-
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
27
|
-
*/
|
|
28
|
-
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
29
|
-
toString(): string;
|
|
30
|
-
}
|
|
31
9
|
export declare class Field extends BaseField {
|
|
32
10
|
/**
|
|
33
11
|
* Contains exactly 4 relative vertices coordinates (points) of a right
|
|
@@ -40,10 +18,8 @@ export declare class Field extends BaseField {
|
|
|
40
18
|
*/
|
|
41
19
|
polygon: Polygon;
|
|
42
20
|
/** The document page on which the information was found. */
|
|
43
|
-
pageId: number
|
|
44
|
-
/**
|
|
45
|
-
* The confidence score of the prediction.
|
|
46
|
-
*/
|
|
21
|
+
pageId: number;
|
|
22
|
+
/** The confidence score of the prediction. */
|
|
47
23
|
confidence: number;
|
|
48
24
|
/**
|
|
49
25
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
@@ -53,22 +29,16 @@ export declare class Field extends BaseField {
|
|
|
53
29
|
* @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
|
|
54
30
|
*/
|
|
55
31
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
56
|
-
compare(other: Field): boolean;
|
|
57
32
|
/**
|
|
58
|
-
@param {
|
|
59
|
-
@param {
|
|
33
|
+
@param {Field[]} array1 - first Array of Fields
|
|
34
|
+
@param {Field[]} array2 - second Array of Fields
|
|
60
35
|
@param {String} attr - Attribute to compare
|
|
61
36
|
@returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
|
|
62
37
|
*/
|
|
63
38
|
static compareArrays(array1: Field[], array2: Field[], attr?: string): boolean;
|
|
64
39
|
/**
|
|
65
|
-
* @param {
|
|
40
|
+
* @param {Field[]} array - Array of Fields
|
|
66
41
|
* @returns {Number} product of all the fields probaility
|
|
67
42
|
*/
|
|
68
|
-
static arrayConfidence(array:
|
|
69
|
-
/**
|
|
70
|
-
* @param {Array<Field>} array - Array of Fields
|
|
71
|
-
* @returns {Number} Sum of all the Fields values in the array
|
|
72
|
-
*/
|
|
73
|
-
static arraySum(array: any): number;
|
|
43
|
+
static arrayConfidence(array: Field[]): number;
|
|
74
44
|
}
|
package/src/fields/field.js
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Field =
|
|
3
|
+
exports.Field = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
4
5
|
const geometry_1 = require("../geometry");
|
|
5
|
-
class BaseField {
|
|
6
|
-
/**
|
|
7
|
-
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
|
-
* @param {String} valueKey - Key to use in the prediction dict
|
|
9
|
-
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
10
|
-
*/
|
|
11
|
-
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
12
|
-
/** The value. */
|
|
13
|
-
this.value = undefined;
|
|
14
|
-
this.reconstructed = reconstructed;
|
|
15
|
-
if (prediction !== undefined &&
|
|
16
|
-
prediction !== null &&
|
|
17
|
-
valueKey in prediction &&
|
|
18
|
-
prediction[valueKey] !== null) {
|
|
19
|
-
this.value = prediction[valueKey];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
toString() {
|
|
23
|
-
if (this.value !== undefined) {
|
|
24
|
-
return `${this.value}`;
|
|
25
|
-
}
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.BaseField = BaseField;
|
|
30
|
-
class Field extends BaseField {
|
|
6
|
+
class Field extends base_1.BaseField {
|
|
31
7
|
/**
|
|
32
8
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
33
9
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
@@ -54,19 +30,9 @@ class Field extends BaseField {
|
|
|
54
30
|
this.bbox = (0, geometry_1.getBboxAsPolygon)(prediction.polygon);
|
|
55
31
|
}
|
|
56
32
|
}
|
|
57
|
-
compare(other) {
|
|
58
|
-
if (this.value === null && other.value === null)
|
|
59
|
-
return true;
|
|
60
|
-
if (this.value === null || other.value === null)
|
|
61
|
-
return false;
|
|
62
|
-
if (typeof this.value === "string") {
|
|
63
|
-
return this.value.toLowerCase() === other.value.toLowerCase();
|
|
64
|
-
}
|
|
65
|
-
return this.value === other.value;
|
|
66
|
-
}
|
|
67
33
|
/**
|
|
68
|
-
@param {
|
|
69
|
-
@param {
|
|
34
|
+
@param {Field[]} array1 - first Array of Fields
|
|
35
|
+
@param {Field[]} array2 - second Array of Fields
|
|
70
36
|
@param {String} attr - Attribute to compare
|
|
71
37
|
@returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
|
|
72
38
|
*/
|
|
@@ -82,7 +48,7 @@ class Field extends BaseField {
|
|
|
82
48
|
return true;
|
|
83
49
|
}
|
|
84
50
|
/**
|
|
85
|
-
* @param {
|
|
51
|
+
* @param {Field[]} array - Array of Fields
|
|
86
52
|
* @returns {Number} product of all the fields probaility
|
|
87
53
|
*/
|
|
88
54
|
static arrayConfidence(array) {
|
|
@@ -94,18 +60,5 @@ class Field extends BaseField {
|
|
|
94
60
|
}
|
|
95
61
|
return total;
|
|
96
62
|
}
|
|
97
|
-
/**
|
|
98
|
-
* @param {Array<Field>} array - Array of Fields
|
|
99
|
-
* @returns {Number} Sum of all the Fields values in the array
|
|
100
|
-
*/
|
|
101
|
-
static arraySum(array) {
|
|
102
|
-
let total = 0.0;
|
|
103
|
-
for (const field of array) {
|
|
104
|
-
total += field.value;
|
|
105
|
-
if (isNaN(total))
|
|
106
|
-
return 0.0;
|
|
107
|
-
}
|
|
108
|
-
return total;
|
|
109
|
-
}
|
|
110
63
|
}
|
|
111
64
|
exports.Field = Field;
|
package/src/fields/fullText.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as geometry from "../geometry";
|
|
2
|
-
export
|
|
2
|
+
export type Word = {
|
|
3
3
|
/**
|
|
4
4
|
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
5
5
|
* the field in the document.
|
|
@@ -8,14 +8,14 @@ export declare type Word = {
|
|
|
8
8
|
text: string;
|
|
9
9
|
confidence: number;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type Line = Word[];
|
|
12
12
|
export declare class FullText {
|
|
13
13
|
words: Word[];
|
|
14
14
|
/**
|
|
15
15
|
* Order all text on a page into lines.
|
|
16
16
|
* WARNING: This feature is experimental.
|
|
17
17
|
*/
|
|
18
|
-
toLines():
|
|
18
|
+
toLines(): Line[];
|
|
19
19
|
/**
|
|
20
20
|
* WARNING: This feature is experimental.
|
|
21
21
|
*/
|
package/src/fields/fullText.js
CHANGED
|
@@ -27,22 +27,22 @@ exports.FullText = void 0;
|
|
|
27
27
|
const geometry = __importStar(require("../geometry"));
|
|
28
28
|
function orderLines(fullText) {
|
|
29
29
|
const lines = [];
|
|
30
|
-
const
|
|
30
|
+
const indexes = [];
|
|
31
31
|
let current = undefined;
|
|
32
32
|
fullText.forEach(() => {
|
|
33
33
|
let line = [];
|
|
34
34
|
fullText.forEach((word, idx) => {
|
|
35
|
-
if (!
|
|
35
|
+
if (!indexes.includes(idx)) {
|
|
36
36
|
if (current === undefined) {
|
|
37
37
|
current = word;
|
|
38
|
-
|
|
38
|
+
indexes.push(idx);
|
|
39
39
|
line = [current];
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
const centroid = geometry.getCentroid(word.polygon);
|
|
43
43
|
if (geometry.isPointInPolygonY(centroid, current.polygon)) {
|
|
44
44
|
line.push(word);
|
|
45
|
-
|
|
45
|
+
indexes.push(idx);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/fields/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { OrientationField } from "./orientation";
|
|
|
4
4
|
export { Locale } from "./locale";
|
|
5
5
|
export { Amount } from "./amount";
|
|
6
6
|
export { DateField } from "./date";
|
|
7
|
-
export { BaseField,
|
|
8
|
-
export {
|
|
9
|
-
export { FullText } from "./fullText";
|
|
7
|
+
export { BaseField, StringDict } from "./base";
|
|
8
|
+
export { FullText, Word } from "./fullText";
|
|
10
9
|
export { CompanyRegistration } from "./companyRegistration";
|
|
11
10
|
export { PositionField } from "./position";
|
|
11
|
+
export { TextField } from "./text";
|
package/src/fields/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TextField = exports.PositionField = exports.CompanyRegistration = exports.FullText = exports.BaseField = exports.DateField = exports.Amount = exports.Locale = exports.OrientationField = exports.PaymentDetails = exports.TaxField = void 0;
|
|
4
4
|
var tax_1 = require("./tax");
|
|
5
5
|
Object.defineProperty(exports, "TaxField", { enumerable: true, get: function () { return tax_1.TaxField; } });
|
|
6
6
|
var paymentDetails_1 = require("./paymentDetails");
|
|
@@ -13,16 +13,13 @@ var amount_1 = require("./amount");
|
|
|
13
13
|
Object.defineProperty(exports, "Amount", { enumerable: true, get: function () { return amount_1.Amount; } });
|
|
14
14
|
var date_1 = require("./date");
|
|
15
15
|
Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return date_1.DateField; } });
|
|
16
|
-
var
|
|
17
|
-
Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return
|
|
18
|
-
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_1.Field; } });
|
|
19
|
-
var apiBuilder_1 = require("./apiBuilder");
|
|
20
|
-
Object.defineProperty(exports, "ListField", { enumerable: true, get: function () { return apiBuilder_1.ListField; } });
|
|
21
|
-
Object.defineProperty(exports, "ListFieldValue", { enumerable: true, get: function () { return apiBuilder_1.ListFieldValue; } });
|
|
22
|
-
Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return apiBuilder_1.ClassificationField; } });
|
|
16
|
+
var base_1 = require("./base");
|
|
17
|
+
Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return base_1.BaseField; } });
|
|
23
18
|
var fullText_1 = require("./fullText");
|
|
24
19
|
Object.defineProperty(exports, "FullText", { enumerable: true, get: function () { return fullText_1.FullText; } });
|
|
25
20
|
var companyRegistration_1 = require("./companyRegistration");
|
|
26
21
|
Object.defineProperty(exports, "CompanyRegistration", { enumerable: true, get: function () { return companyRegistration_1.CompanyRegistration; } });
|
|
27
22
|
var position_1 = require("./position");
|
|
28
23
|
Object.defineProperty(exports, "PositionField", { enumerable: true, get: function () { return position_1.PositionField; } });
|
|
24
|
+
var text_1 = require("./text");
|
|
25
|
+
Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return text_1.TextField; } });
|
package/src/fields/locale.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class Locale extends
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
/** The
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
1
|
+
import { BaseField, BaseFieldConstructor } from "./base";
|
|
2
|
+
export declare class Locale extends BaseField {
|
|
3
|
+
/** Locale in ISO format. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** The confidence score of the prediction. */
|
|
6
|
+
confidence: number;
|
|
7
|
+
/** ISO 639-1 language code */
|
|
8
|
+
language?: string;
|
|
9
|
+
/** ISO 3166-1 alpha-2 country code */
|
|
10
|
+
country?: string;
|
|
11
|
+
/** ISO 4217 currency code */
|
|
12
|
+
currency?: string;
|
|
9
13
|
/**
|
|
10
14
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
11
15
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
12
16
|
* @param {boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
13
17
|
*/
|
|
14
|
-
constructor({ prediction, reconstructed, valueKey }:
|
|
18
|
+
constructor({ prediction, reconstructed, valueKey, }: BaseFieldConstructor);
|
|
15
19
|
toString(): string;
|
|
16
20
|
}
|
package/src/fields/locale.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Locale = void 0;
|
|
4
|
-
const
|
|
5
|
-
class Locale extends
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
class Locale extends base_1.BaseField {
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
9
9
|
* @param {boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
10
10
|
*/
|
|
11
|
-
constructor({ prediction, reconstructed = false, valueKey = "value" }) {
|
|
11
|
+
constructor({ prediction, reconstructed = false, valueKey = "value", }) {
|
|
12
12
|
super({ prediction, valueKey, reconstructed });
|
|
13
|
+
this.confidence = prediction.confidence ? prediction.confidence : 0.0;
|
|
13
14
|
this.language = undefined;
|
|
14
15
|
this.country = undefined;
|
|
15
16
|
this.currency = undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { BaseField, BaseFieldConstructor } from "./
|
|
1
|
+
import { BaseField, BaseFieldConstructor } from "./base";
|
|
2
2
|
interface OrientationFieldConstructor extends BaseFieldConstructor {
|
|
3
3
|
pageId: number;
|
|
4
4
|
}
|
|
5
5
|
export declare class OrientationField extends BaseField {
|
|
6
|
+
/** Degrees of the rotation. */
|
|
6
7
|
value: number;
|
|
8
|
+
/** Page id. */
|
|
7
9
|
pageId: number;
|
|
8
10
|
/**
|
|
9
11
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OrientationField = void 0;
|
|
4
|
-
const
|
|
5
|
-
class OrientationField extends
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
class OrientationField extends base_1.BaseField {
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { StringDict } from "./base";
|
|
1
2
|
import { Field } from "./field";
|
|
2
3
|
interface PaymentDetailsConstructor {
|
|
3
|
-
prediction:
|
|
4
|
+
prediction: StringDict;
|
|
4
5
|
valueKey?: string;
|
|
5
6
|
accountNumberKey?: string;
|
|
6
7
|
ibanKey?: string;
|
|
@@ -11,6 +12,8 @@ interface PaymentDetailsConstructor {
|
|
|
11
12
|
}
|
|
12
13
|
export declare class PaymentDetails extends Field {
|
|
13
14
|
#private;
|
|
15
|
+
/** Synonym for the `iban` property */
|
|
16
|
+
value?: string | undefined;
|
|
14
17
|
/** The account number. */
|
|
15
18
|
accountNumber: number | undefined;
|
|
16
19
|
/** The account IBAN. */
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var _a, _PaymentDetails_isKeySet;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.PaymentDetails = void 0;
|
|
10
10
|
const field_1 = require("./field");
|
|
@@ -21,38 +21,41 @@ class PaymentDetails extends field_1.Field {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor({ prediction, valueKey = "iban", accountNumberKey = "account_number", ibanKey = "iban", routingNumberKey = "routing_number", swiftKey = "swift", reconstructed = false, pageId = undefined, }) {
|
|
23
23
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
24
|
-
_PaymentDetails_instances.add(this);
|
|
25
24
|
this.accountNumber = undefined;
|
|
26
25
|
this.iban = undefined;
|
|
27
26
|
this.routingNumber = undefined;
|
|
28
27
|
this.swift = undefined;
|
|
29
|
-
__classPrivateFieldGet(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
__classPrivateFieldGet(
|
|
28
|
+
if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[accountNumberKey])) {
|
|
29
|
+
this.accountNumber = prediction[accountNumberKey];
|
|
30
|
+
}
|
|
31
|
+
if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[ibanKey])) {
|
|
32
|
+
this.iban = prediction[ibanKey];
|
|
33
|
+
}
|
|
34
|
+
if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[routingNumberKey])) {
|
|
35
|
+
this.routingNumber = prediction[routingNumberKey];
|
|
36
|
+
}
|
|
37
|
+
if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[swiftKey])) {
|
|
38
|
+
this.swift = prediction[swiftKey];
|
|
39
|
+
}
|
|
33
40
|
}
|
|
34
41
|
toString() {
|
|
35
42
|
let str = "";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
if (this.accountNumber !== undefined) {
|
|
44
|
+
str += `${this.accountNumber}; `;
|
|
45
|
+
}
|
|
46
|
+
if (this.iban !== undefined) {
|
|
47
|
+
str += `${this.iban}; `;
|
|
48
|
+
}
|
|
49
|
+
if (this.routingNumber !== undefined) {
|
|
50
|
+
str += `${this.routingNumber}; `;
|
|
51
|
+
}
|
|
52
|
+
if (this.swift !== undefined) {
|
|
53
|
+
str += `${this.swift}; `;
|
|
42
54
|
}
|
|
43
55
|
return str;
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
58
|
exports.PaymentDetails = PaymentDetails;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
this[key] = value;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
this[key] = undefined;
|
|
57
|
-
}
|
|
59
|
+
_a = PaymentDetails, _PaymentDetails_isKeySet = function _PaymentDetails_isKeySet(value) {
|
|
60
|
+
return typeof value === "string" && value !== "N/A";
|
|
58
61
|
};
|
package/src/fields/position.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StringDict } from "./base";
|
|
2
2
|
import { Polygon } from "../geometry";
|
|
3
3
|
export interface PositionFieldConstructor {
|
|
4
|
-
prediction:
|
|
4
|
+
prediction: StringDict;
|
|
5
5
|
valueKey?: string;
|
|
6
6
|
pageId?: number | undefined;
|
|
7
7
|
}
|