mindee 3.10.2 → 4.0.0
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 +19 -0
- package/README.md +103 -41
- package/package.json +6 -6
- package/src/cli.js +96 -70
- package/src/client.d.ts +34 -65
- package/src/client.js +108 -172
- package/src/geometry/boundingBox.d.ts +5 -0
- package/src/geometry/boundingBox.js +2 -0
- package/src/geometry/boundingBoxUtils.d.ts +22 -0
- package/src/geometry/boundingBoxUtils.js +66 -0
- package/src/geometry/index.d.ts +6 -0
- package/src/geometry/index.js +21 -0
- package/src/geometry/minMax.d.ts +4 -0
- package/src/geometry/minMax.js +2 -0
- package/src/geometry/point.d.ts +2 -0
- package/src/geometry/point.js +2 -0
- package/src/geometry/polygon.d.ts +4 -0
- package/src/geometry/polygon.js +7 -0
- package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
- package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
- package/src/http/endpoint.d.ts +44 -0
- package/src/http/endpoint.js +188 -0
- package/src/http/error.d.ts +2 -0
- package/src/http/error.js +9 -0
- package/src/http/index.d.ts +3 -0
- package/src/http/index.js +11 -0
- package/src/http/mindeeApi.d.ts +20 -0
- package/src/http/mindeeApi.js +73 -0
- package/src/index.d.ts +4 -4
- package/src/index.js +33 -26
- package/src/{inputs → input}/base.d.ts +4 -3
- package/src/{inputs → input}/base.js +9 -7
- package/src/{inputs → input}/index.d.ts +1 -1
- package/src/{inputs → input}/index.js +1 -2
- package/src/{inputs → input}/sources.d.ts +10 -11
- package/src/{inputs → input}/sources.js +9 -9
- package/src/parsing/common/apiRequest.d.ts +10 -0
- package/src/parsing/common/apiRequest.js +13 -0
- package/src/parsing/common/apiResponse.d.ts +6 -0
- package/src/parsing/common/apiResponse.js +10 -0
- package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
- package/src/parsing/common/asyncPredictResponse.js +39 -0
- package/src/parsing/common/document.d.ts +13 -0
- package/src/parsing/common/document.js +34 -0
- package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
- package/src/parsing/common/extras/cropperExtra.js +26 -0
- package/src/parsing/common/extras/extras.d.ts +11 -0
- package/src/parsing/common/extras/extras.js +18 -0
- package/src/parsing/common/index.d.ts +9 -0
- package/src/parsing/common/index.js +20 -0
- package/src/parsing/common/inference.d.ts +26 -0
- package/src/parsing/common/inference.js +56 -0
- package/src/parsing/common/mvisionV1.d.ts +8 -0
- package/src/parsing/common/mvisionV1.js +17 -0
- package/src/parsing/common/ocr.d.ts +8 -0
- package/src/parsing/common/ocr.js +13 -0
- package/src/parsing/common/ocrPage.d.ts +16 -0
- package/src/parsing/common/ocrPage.js +66 -0
- package/src/{fields → parsing/common}/orientation.d.ts +2 -2
- package/src/{fields → parsing/common}/orientation.js +4 -4
- package/src/parsing/common/page.d.ts +12 -0
- package/src/parsing/common/page.js +40 -0
- package/src/parsing/common/predictResponse.d.ts +6 -0
- package/src/parsing/common/predictResponse.js +12 -0
- package/src/parsing/common/prediction.d.ts +2 -0
- package/src/parsing/common/prediction.js +6 -0
- package/src/parsing/common/product.d.ts +4 -0
- package/src/parsing/common/product.js +2 -0
- package/src/parsing/common/stringDict.d.ts +3 -0
- package/src/parsing/common/stringDict.js +2 -0
- package/src/parsing/common/summaryHelper.d.ts +8 -0
- package/src/parsing/common/summaryHelper.js +22 -0
- package/src/parsing/custom/classificationField.d.ts +16 -0
- package/src/parsing/custom/classificationField.js +14 -0
- package/src/parsing/custom/index.d.ts +3 -0
- package/src/parsing/custom/index.js +12 -0
- package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
- package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
- package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
- package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
- package/src/parsing/index.d.ts +3 -0
- package/src/parsing/index.js +29 -0
- package/src/{fields → parsing/standard}/amount.d.ts +2 -2
- package/src/{fields → parsing/standard}/amount.js +5 -5
- package/src/{fields → parsing/standard}/base.d.ts +5 -5
- package/src/{fields → parsing/standard}/base.js +3 -2
- package/src/{fields → parsing/standard}/classification.d.ts +1 -1
- package/src/{fields → parsing/standard}/classification.js +3 -3
- package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
- package/src/parsing/standard/companyRegistration.js +14 -0
- package/src/{fields → parsing/standard}/date.d.ts +1 -1
- package/src/{fields → parsing/standard}/date.js +2 -2
- package/src/{fields → parsing/standard}/field.d.ts +3 -4
- package/src/{fields → parsing/standard}/field.js +6 -7
- package/src/parsing/standard/index.d.ts +12 -0
- package/src/parsing/standard/index.js +27 -0
- package/src/{fields → parsing/standard}/locale.d.ts +4 -4
- package/src/parsing/standard/locale.js +42 -0
- package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
- package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
- package/src/{fields → parsing/standard}/position.d.ts +2 -2
- package/src/{fields → parsing/standard}/position.js +5 -5
- package/src/{fields → parsing/standard}/tax.d.ts +3 -3
- package/src/{fields → parsing/standard}/tax.js +3 -3
- package/src/{fields → parsing/standard}/text.d.ts +2 -2
- package/src/{fields → parsing/standard}/text.js +4 -4
- package/src/parsing/standard/word.d.ts +10 -0
- package/src/parsing/standard/word.js +2 -0
- package/src/pdf/pdfOperation.d.ts +1 -1
- package/src/pdf/pdfOperation.js +3 -3
- package/src/product/cropper/cropperV1.d.ts +9 -0
- package/src/product/cropper/cropperV1.js +16 -0
- package/src/product/cropper/cropperV1Document.d.ts +8 -0
- package/src/product/cropper/cropperV1Document.js +26 -0
- package/src/product/custom/customV1.d.ts +10 -0
- package/src/product/custom/customV1.js +17 -0
- package/src/product/custom/customV1Document.d.ts +9 -0
- package/src/product/custom/customV1Document.js +43 -0
- package/src/product/custom/customV1Page.d.ts +7 -0
- package/src/product/custom/customV1Page.js +24 -0
- package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
- package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
- package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
- package/src/product/financialDocument/financialDocumentV1.js +16 -0
- package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
- package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
- package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
- package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
- package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
- package/src/product/fr/idCard/idCardV1.d.ts +10 -0
- package/src/product/fr/idCard/idCardV1.js +17 -0
- package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
- package/src/product/fr/idCard/idCardV1Document.js +70 -0
- package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
- package/src/product/fr/idCard/idCardV1Page.js +23 -0
- package/src/{documents → product}/index.d.ts +2 -7
- package/src/{documents → product}/index.js +3 -14
- package/src/product/invoice/invoiceV4.d.ts +9 -0
- package/src/product/invoice/invoiceV4.js +16 -0
- package/src/product/invoice/invoiceV4Document.d.ts +44 -0
- package/src/product/invoice/invoiceV4Document.js +146 -0
- package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
- package/src/product/invoice/invoiceV4LineItem.js +101 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
- package/src/product/passport/passportV1.d.ts +9 -0
- package/src/product/passport/passportV1.js +16 -0
- package/src/product/passport/passportV1Document.d.ts +31 -0
- package/src/product/passport/passportV1Document.js +75 -0
- package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
- package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
- package/src/product/receipt/receiptV4.d.ts +9 -0
- package/src/product/receipt/receiptV4.js +15 -0
- package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
- package/src/product/receipt/receiptV4Document.js +67 -0
- package/src/product/receipt/receiptV5.d.ts +9 -0
- package/src/product/receipt/receiptV5.js +16 -0
- package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
- package/src/product/receipt/receiptV5Document.js +108 -0
- package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
- package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
- package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
- package/src/product/us/bankCheck/bankCheckV1.js +17 -0
- package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
- package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
- package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
- package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
- package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
- package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
- package/src/product/us/index.d.ts +2 -0
- package/src/product/us/index.js +7 -0
- package/src/api/documentResponse.d.ts +0 -25
- package/src/api/documentResponse.js +0 -50
- package/src/api/endpoint.d.ts +0 -63
- package/src/api/endpoint.js +0 -216
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -13
- package/src/api/predictResponse.d.ts +0 -33
- package/src/api/predictResponse.js +0 -52
- package/src/documents/cropper/cropperV1.d.ts +0 -7
- package/src/documents/cropper/cropperV1.js +0 -35
- package/src/documents/custom/customV1.d.ts +0 -10
- package/src/documents/custom/customV1.js +0 -53
- package/src/documents/document.d.ts +0 -47
- package/src/documents/document.js +0 -76
- package/src/documents/documentConfig.d.ts +0 -42
- package/src/documents/documentConfig.js +0 -118
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
- package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
- package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
- package/src/documents/financialDocument/financialDocumentV0.js +0 -140
- package/src/documents/financialDocument/financialDocumentV1.js +0 -197
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
- package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
- package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
- package/src/documents/fr/idCard/idCardV1.js +0 -79
- package/src/documents/invoice/checks.d.ts +0 -5
- package/src/documents/invoice/checks.js +0 -87
- package/src/documents/invoice/invoiceLineItem.js +0 -66
- package/src/documents/invoice/invoiceV3.d.ts +0 -49
- package/src/documents/invoice/invoiceV3.js +0 -156
- package/src/documents/invoice/invoiceV4.d.ts +0 -45
- package/src/documents/invoice/invoiceV4.js +0 -166
- package/src/documents/invoice/reconstruction.d.ts +0 -6
- package/src/documents/invoice/reconstruction.js +0 -78
- package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
- package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
- package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
- package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
- package/src/documents/passport/passportV1.d.ts +0 -43
- package/src/documents/passport/passportV1.js +0 -220
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
- package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
- package/src/documents/receipt/receiptV3.d.ts +0 -25
- package/src/documents/receipt/receiptV3.js +0 -136
- package/src/documents/receipt/receiptV4.js +0 -78
- package/src/documents/receipt/receiptV5.js +0 -137
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
- package/src/documents/us/index.d.ts +0 -1
- package/src/documents/us/index.js +0 -5
- package/src/fields/companyRegistration.js +0 -14
- package/src/fields/fullText.d.ts +0 -27
- package/src/fields/fullText.js +0 -92
- package/src/fields/index.d.ts +0 -12
- package/src/fields/index.js +0 -28
- package/src/fields/locale.js +0 -45
- package/src/math/index.d.ts +0 -1
- package/src/math/index.js +0 -5
- package/src/math/precision.d.ts +0 -1
- package/src/math/precision.js +0 -13
- /package/src/{inputs → input}/pageOptions.d.ts +0 -0
- /package/src/{inputs → input}/pageOptions.js +0 -0
- /package/src/{documents → product}/eu/index.d.ts +0 -0
- /package/src/{documents → product}/eu/index.js +0 -0
- /package/src/{documents → product}/fr/index.d.ts +0 -0
- /package/src/{documents → product}/fr/index.js +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _OcrPage_instances, _OcrPage_areWordsOnSameLine, _OcrPage_toLines;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OcrPage = void 0;
|
|
10
|
+
const geometry_1 = require("../../geometry");
|
|
11
|
+
class OcrPage {
|
|
12
|
+
constructor(rawPrediction) {
|
|
13
|
+
_OcrPage_instances.add(this);
|
|
14
|
+
/** Flat list of all words read */
|
|
15
|
+
this.allWords = [];
|
|
16
|
+
/** List of words by which line they are on */
|
|
17
|
+
this.allLines = [];
|
|
18
|
+
const allWords = [];
|
|
19
|
+
rawPrediction["all_words"] &&
|
|
20
|
+
rawPrediction["all_words"].forEach((word) => {
|
|
21
|
+
allWords.push(word);
|
|
22
|
+
});
|
|
23
|
+
this.allWords = allWords.sort((word1, word2) => (0, geometry_1.compareOnY)(word1.polygon, word2.polygon));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get all words on the page as ordered lines
|
|
27
|
+
* @returns Sorted lines on the pages
|
|
28
|
+
*/
|
|
29
|
+
getAllLines() {
|
|
30
|
+
if (!this.allLines || this.allLines.length === 0) {
|
|
31
|
+
this.allLines = __classPrivateFieldGet(this, _OcrPage_instances, "m", _OcrPage_toLines).call(this);
|
|
32
|
+
}
|
|
33
|
+
return this.allLines;
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return this.getAllLines()
|
|
37
|
+
.map((line) => line.map((word) => word.text).join(" "))
|
|
38
|
+
.join("\n");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.OcrPage = OcrPage;
|
|
42
|
+
_OcrPage_instances = new WeakSet(), _OcrPage_areWordsOnSameLine = function _OcrPage_areWordsOnSameLine(currentWord, nextWord) {
|
|
43
|
+
const currentInNext = (0, geometry_1.isPointInPolygonY)((0, geometry_1.getCentroid)(currentWord.polygon), nextWord.polygon);
|
|
44
|
+
const nextInCurrent = (0, geometry_1.isPointInPolygonY)((0, geometry_1.getCentroid)(nextWord.polygon), currentWord.polygon);
|
|
45
|
+
return nextInCurrent || currentInNext;
|
|
46
|
+
}, _OcrPage_toLines = function _OcrPage_toLines() {
|
|
47
|
+
const lines = [];
|
|
48
|
+
const lineIdx = [];
|
|
49
|
+
this.allWords.forEach((current, idxCurrent) => {
|
|
50
|
+
if (!lineIdx.includes(idxCurrent)) {
|
|
51
|
+
lines.push([current]);
|
|
52
|
+
lineIdx.push(idxCurrent);
|
|
53
|
+
}
|
|
54
|
+
this.allWords.forEach((next, idxNext) => {
|
|
55
|
+
if (idxCurrent === idxNext || lineIdx.includes(idxNext)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (__classPrivateFieldGet(this, _OcrPage_instances, "m", _OcrPage_areWordsOnSameLine).call(this, current, next)) {
|
|
59
|
+
lineIdx.push(idxNext);
|
|
60
|
+
lines[lines.length - 1].push(next);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
lines.forEach((line) => line.sort((word1, word2) => (0, geometry_1.compareOnX)(word1.polygon, word2.polygon)));
|
|
65
|
+
return lines;
|
|
66
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseField, BaseFieldConstructor } from "
|
|
1
|
+
import { BaseField, BaseFieldConstructor } from "../standard";
|
|
2
2
|
interface OrientationFieldConstructor extends BaseFieldConstructor {
|
|
3
3
|
pageId: number;
|
|
4
4
|
}
|
|
@@ -13,7 +13,7 @@ export declare class OrientationField extends BaseField {
|
|
|
13
13
|
/**
|
|
14
14
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
15
15
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
16
|
-
* @param {Boolean} reconstructed -
|
|
16
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
17
17
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
18
18
|
*/
|
|
19
19
|
constructor({ prediction, valueKey, reconstructed, pageId, }: OrientationFieldConstructor);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OrientationField = void 0;
|
|
4
|
-
const
|
|
4
|
+
const standard_1 = require("../standard");
|
|
5
5
|
/**
|
|
6
6
|
* The clockwise rotation to apply (in degrees) to make the image upright.
|
|
7
7
|
*/
|
|
8
|
-
class OrientationField extends
|
|
8
|
+
class OrientationField extends standard_1.BaseField {
|
|
9
9
|
/**
|
|
10
10
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
11
11
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
12
|
-
* @param {Boolean} reconstructed -
|
|
12
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
13
13
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
14
14
|
*/
|
|
15
|
-
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
15
|
+
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
|
|
16
16
|
super({ prediction, valueKey, reconstructed });
|
|
17
17
|
const orientations = [0, 90, 180, 270];
|
|
18
18
|
this.pageId = pageId;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Extras } from "./extras/extras";
|
|
2
|
+
import { OrientationField } from "./orientation";
|
|
3
|
+
import { Prediction } from "./prediction";
|
|
4
|
+
import { StringDict } from "./stringDict";
|
|
5
|
+
export declare class Page<T extends Prediction> {
|
|
6
|
+
id: number;
|
|
7
|
+
orientation?: OrientationField;
|
|
8
|
+
prediction: T;
|
|
9
|
+
extras?: Extras;
|
|
10
|
+
constructor(predictionType: new (rawPrediction: StringDict, pageId: number) => T, rawPrediction: StringDict, pageId: number, orientation?: StringDict);
|
|
11
|
+
toString(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Page = void 0;
|
|
4
|
+
const cropperExtra_1 = require("./extras/cropperExtra");
|
|
5
|
+
const extras_1 = require("./extras/extras");
|
|
6
|
+
const orientation_1 = require("./orientation");
|
|
7
|
+
class Page {
|
|
8
|
+
constructor(predictionType, rawPrediction, pageId, orientation) {
|
|
9
|
+
if (pageId !== undefined && orientation !== undefined) {
|
|
10
|
+
this.orientation = new orientation_1.OrientationField({
|
|
11
|
+
prediction: orientation,
|
|
12
|
+
pageId: pageId,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
orientation = undefined;
|
|
17
|
+
}
|
|
18
|
+
this.id = pageId;
|
|
19
|
+
this.prediction = new predictionType(rawPrediction["prediction"], pageId);
|
|
20
|
+
if (rawPrediction["extras"] &&
|
|
21
|
+
Object.keys(rawPrediction["extras"].length > 0)) {
|
|
22
|
+
const extras = {};
|
|
23
|
+
Object.entries(rawPrediction["extras"]).forEach(([extraKey, extraValue]) => {
|
|
24
|
+
switch (extraKey) {
|
|
25
|
+
case "cropper":
|
|
26
|
+
extras["cropper"] = new cropperExtra_1.CropperExtra(extraValue);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.extras = new extras_1.Extras(extras);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
toString() {
|
|
33
|
+
const title = `Page ${this.id}`;
|
|
34
|
+
return `${title}
|
|
35
|
+
${"-".repeat(title.length)}
|
|
36
|
+
${this.prediction.toString()}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Page = Page;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApiResponse } from "./apiResponse";
|
|
2
|
+
import { Document, Inference, StringDict } from ".";
|
|
3
|
+
export declare class PredictResponse<T extends Inference> extends ApiResponse {
|
|
4
|
+
document: Document<T>;
|
|
5
|
+
constructor(inferenceClass: new (rawPrediction: StringDict) => T, rawPrediction: StringDict);
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PredictResponse = void 0;
|
|
4
|
+
const apiResponse_1 = require("./apiResponse");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
class PredictResponse extends apiResponse_1.ApiResponse {
|
|
7
|
+
constructor(inferenceClass, rawPrediction) {
|
|
8
|
+
super(rawPrediction);
|
|
9
|
+
this.document = new _1.Document(inferenceClass, rawPrediction["document"]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.PredictResponse = PredictResponse;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function cleanOutString(outStr: string): string;
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param columnSizes Size of each column in the table
|
|
5
|
+
* @param separator character for a separator
|
|
6
|
+
* @returns A separator for table lines
|
|
7
|
+
*/
|
|
8
|
+
export declare function lineSeparator(columnSizes: number[], separator: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lineSeparator = exports.cleanOutString = void 0;
|
|
4
|
+
function cleanOutString(outStr) {
|
|
5
|
+
const lines = / \n/gm;
|
|
6
|
+
return outStr.replace(lines, "\n");
|
|
7
|
+
}
|
|
8
|
+
exports.cleanOutString = cleanOutString;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param columnSizes Size of each column in the table
|
|
12
|
+
* @param separator character for a separator
|
|
13
|
+
* @returns A separator for table lines
|
|
14
|
+
*/
|
|
15
|
+
function lineSeparator(columnSizes, separator) {
|
|
16
|
+
let outStr = " +";
|
|
17
|
+
columnSizes.forEach((size) => {
|
|
18
|
+
outStr += separator.repeat(size) + "+";
|
|
19
|
+
});
|
|
20
|
+
return outStr;
|
|
21
|
+
}
|
|
22
|
+
exports.lineSeparator = lineSeparator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StringDict } from "../common";
|
|
2
|
+
export declare class ClassificationField {
|
|
3
|
+
/** The value for the classification. */
|
|
4
|
+
value: string;
|
|
5
|
+
/**
|
|
6
|
+
* The confidence score of the prediction.
|
|
7
|
+
* Note: Score is calculated on **word selection**, not its textual content (OCR).
|
|
8
|
+
*/
|
|
9
|
+
confidence: number;
|
|
10
|
+
pageId?: number;
|
|
11
|
+
constructor({ prediction, pageId, }: {
|
|
12
|
+
prediction: StringDict;
|
|
13
|
+
pageId?: number;
|
|
14
|
+
});
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassificationField = void 0;
|
|
4
|
+
class ClassificationField {
|
|
5
|
+
constructor({ prediction, pageId, }) {
|
|
6
|
+
this.value = prediction["value"];
|
|
7
|
+
this.confidence = prediction["confidence"];
|
|
8
|
+
this.pageId ?? (this.pageId = pageId);
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return `${this.value}`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ClassificationField = ClassificationField;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListFieldValue = exports.ListField = exports.ClassificationField = exports.getLineItems = exports.LineItems = exports.Line = void 0;
|
|
4
|
+
var lineItems_1 = require("./lineItems");
|
|
5
|
+
Object.defineProperty(exports, "Line", { enumerable: true, get: function () { return lineItems_1.Line; } });
|
|
6
|
+
Object.defineProperty(exports, "LineItems", { enumerable: true, get: function () { return lineItems_1.LineItems; } });
|
|
7
|
+
Object.defineProperty(exports, "getLineItems", { enumerable: true, get: function () { return lineItems_1.getLineItems; } });
|
|
8
|
+
var classificationField_1 = require("./classificationField");
|
|
9
|
+
Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return classificationField_1.ClassificationField; } });
|
|
10
|
+
var listField_1 = require("./listField");
|
|
11
|
+
Object.defineProperty(exports, "ListField", { enumerable: true, get: function () { return listField_1.ListField; } });
|
|
12
|
+
Object.defineProperty(exports, "ListFieldValue", { enumerable: true, get: function () { return listField_1.ListFieldValue; } });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BBox, Polygon } from "../../geometry";
|
|
2
|
-
import { ListField, ListFieldValue } from "./
|
|
2
|
+
import { ListField, ListFieldValue } from "./listField";
|
|
3
3
|
export declare class Line {
|
|
4
4
|
/**
|
|
5
5
|
* Number of the current line.
|
|
6
|
-
* Starts
|
|
6
|
+
* Starts at 1.
|
|
7
7
|
*/
|
|
8
8
|
rowNumber: number;
|
|
9
9
|
/**
|
|
@@ -16,7 +16,7 @@ export declare class Line {
|
|
|
16
16
|
bbox: BBox;
|
|
17
17
|
/**
|
|
18
18
|
* The height tolerance used to build the line.
|
|
19
|
-
* It helps when the height of
|
|
19
|
+
* It helps when the height of a line can vary unexpectedly.
|
|
20
20
|
*/
|
|
21
21
|
heightTolerance: number;
|
|
22
22
|
constructor(rowNumber: number, heightTolerance: number);
|
|
@@ -38,4 +38,4 @@ export declare class LineItems {
|
|
|
38
38
|
rows: Line[];
|
|
39
39
|
constructor(lines: Line[]);
|
|
40
40
|
}
|
|
41
|
-
export declare function getLineItems(anchorNames: string[],
|
|
41
|
+
export declare function getLineItems(anchorNames: string[], heightLineTolerance: number, fieldNamesTargeted: string[], fields: Map<string, ListField>): LineItems;
|
|
@@ -4,8 +4,7 @@ exports.getLineItems = exports.LineItems = exports.Line = void 0;
|
|
|
4
4
|
const handler_1 = require("../../errors/handler");
|
|
5
5
|
const errors_1 = require("../../errors");
|
|
6
6
|
const geometry_1 = require("../../geometry");
|
|
7
|
-
const
|
|
8
|
-
const math_1 = require("../../math");
|
|
7
|
+
const listField_1 = require("./listField");
|
|
9
8
|
class Line {
|
|
10
9
|
constructor(rowNumber, heightTolerance) {
|
|
11
10
|
this.rowNumber = rowNumber;
|
|
@@ -29,7 +28,10 @@ class Line {
|
|
|
29
28
|
* Check if the bbox fits the current line.
|
|
30
29
|
*/
|
|
31
30
|
contains(bbox) {
|
|
32
|
-
|
|
31
|
+
if (Math.abs(bbox[1] - this.bbox[1]) <= this.heightTolerance) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return Math.abs(this.bbox[1] - bbox[1]) <= this.heightTolerance;
|
|
33
35
|
}
|
|
34
36
|
updateField(name, fieldValue) {
|
|
35
37
|
if (!this.fields.has(name)) {
|
|
@@ -48,7 +50,7 @@ class Line {
|
|
|
48
50
|
existingField.polygon,
|
|
49
51
|
fieldValue.polygon,
|
|
50
52
|
]);
|
|
51
|
-
this.fields.set(name, new
|
|
53
|
+
this.fields.set(name, new listField_1.ListFieldValue({
|
|
52
54
|
content: mergedContent,
|
|
53
55
|
confidence: existingField.confidence * fieldValue.confidence,
|
|
54
56
|
polygon: (0, geometry_1.getBoundingBoxFromBBox)(mergedBbox),
|
|
@@ -64,10 +66,10 @@ class LineItems {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
exports.LineItems = LineItems;
|
|
67
|
-
function getLineItems(anchorNames,
|
|
69
|
+
function getLineItems(anchorNames, heightLineTolerance, fieldNamesTargeted, fields) {
|
|
68
70
|
const fieldsToTransformIntoLines = new Map([...fields].filter(([k]) => fieldNamesTargeted.includes(k)));
|
|
69
71
|
const anchorName = findBestAnchor(anchorNames, fieldsToTransformIntoLines);
|
|
70
|
-
const lineItemsPrepared = prepare(anchorName, fieldsToTransformIntoLines,
|
|
72
|
+
const lineItemsPrepared = prepare(anchorName, fieldsToTransformIntoLines, heightLineTolerance);
|
|
71
73
|
lineItemsPrepared.rows.forEach((currentLine) => {
|
|
72
74
|
fieldsToTransformIntoLines.forEach((field, fieldName) => {
|
|
73
75
|
field.values.forEach((listFieldValue) => {
|
|
@@ -97,14 +99,14 @@ function findBestAnchor(possibleAnchorNames, fields) {
|
|
|
97
99
|
}
|
|
98
100
|
return anchorName;
|
|
99
101
|
}
|
|
100
|
-
function prepare(anchorName, fields,
|
|
102
|
+
function prepare(anchorName, fields, heightLineTolerance) {
|
|
101
103
|
const lineItemsPrepared = [];
|
|
102
104
|
const anchorField = fields.get(anchorName);
|
|
103
105
|
if (anchorField === undefined || anchorField.values.length === 0) {
|
|
104
106
|
handler_1.errorHandler.throw(new errors_1.MindeeError("No lines have been detected."));
|
|
105
107
|
}
|
|
106
108
|
let currentLineNumber = 1;
|
|
107
|
-
let currentLine = new Line(currentLineNumber,
|
|
109
|
+
let currentLine = new Line(currentLineNumber, heightLineTolerance);
|
|
108
110
|
if (anchorField !== undefined) {
|
|
109
111
|
let currentValue = anchorField.values[0];
|
|
110
112
|
currentLine.extendWith(currentValue.polygon);
|
|
@@ -114,7 +116,7 @@ function prepare(anchorName, fields, heigthLineTolerance) {
|
|
|
114
116
|
if (!currentLine.contains(currentFieldBbox)) {
|
|
115
117
|
lineItemsPrepared.push(currentLine);
|
|
116
118
|
currentLineNumber++;
|
|
117
|
-
currentLine = new Line(currentLineNumber,
|
|
119
|
+
currentLine = new Line(currentLineNumber, heightLineTolerance);
|
|
118
120
|
}
|
|
119
121
|
currentLine.extendWithBbox(currentFieldBbox);
|
|
120
122
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FieldConstructor } from "../../fields/field";
|
|
1
|
+
import { FieldConstructor } from "../standard";
|
|
3
2
|
import { Polygon } from "../../geometry";
|
|
4
|
-
|
|
5
|
-
/** The value for the classification. */
|
|
6
|
-
value: string;
|
|
7
|
-
/**
|
|
8
|
-
* The confidence score of the prediction.
|
|
9
|
-
* Note: Score is calculated on **word selection**, not its textual content (OCR).
|
|
10
|
-
*/
|
|
11
|
-
confidence: number;
|
|
12
|
-
constructor({ prediction }: {
|
|
13
|
-
prediction: StringDict;
|
|
14
|
-
});
|
|
15
|
-
toString(): string;
|
|
16
|
-
}
|
|
3
|
+
import { StringDict } from "../common";
|
|
17
4
|
export declare class ListFieldValue {
|
|
18
5
|
/** Extracted content of the prediction */
|
|
19
6
|
content: string | number;
|
|
@@ -42,7 +29,7 @@ export declare class ListField {
|
|
|
42
29
|
reconstructed: boolean;
|
|
43
30
|
/** The document page on which the information was found. */
|
|
44
31
|
pageId: number;
|
|
45
|
-
constructor({ prediction, reconstructed, pageId }: FieldConstructor);
|
|
32
|
+
constructor({ prediction, reconstructed, pageId, }: FieldConstructor);
|
|
46
33
|
contentsList(): Array<string | number>;
|
|
47
34
|
contentsString(separator?: string): string;
|
|
48
35
|
toString(): string;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListField = exports.ListFieldValue =
|
|
3
|
+
exports.ListField = exports.ListFieldValue = void 0;
|
|
4
4
|
const geometry_1 = require("../../geometry");
|
|
5
|
-
class ClassificationField {
|
|
6
|
-
constructor({ prediction }) {
|
|
7
|
-
this.value = prediction["value"];
|
|
8
|
-
this.confidence = prediction["confidence"];
|
|
9
|
-
}
|
|
10
|
-
toString() {
|
|
11
|
-
return `${this.value}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.ClassificationField = ClassificationField;
|
|
15
5
|
class ListFieldValue {
|
|
16
6
|
constructor(prediction) {
|
|
17
7
|
/**
|
|
@@ -28,7 +18,7 @@ class ListFieldValue {
|
|
|
28
18
|
this.confidence = prediction["confidence"];
|
|
29
19
|
if (prediction["polygon"]) {
|
|
30
20
|
this.polygon = prediction["polygon"];
|
|
31
|
-
this.bbox = (0, geometry_1.getBoundingBox)(prediction
|
|
21
|
+
this.bbox = (0, geometry_1.getBoundingBox)(prediction["polygon"]);
|
|
32
22
|
}
|
|
33
23
|
}
|
|
34
24
|
toString() {
|
|
@@ -37,12 +27,12 @@ class ListFieldValue {
|
|
|
37
27
|
}
|
|
38
28
|
exports.ListFieldValue = ListFieldValue;
|
|
39
29
|
class ListField {
|
|
40
|
-
constructor({ prediction, reconstructed = false, pageId }) {
|
|
30
|
+
constructor({ prediction = {}, reconstructed = false, pageId, }) {
|
|
41
31
|
this.values = [];
|
|
42
32
|
this.confidence = prediction["confidence"];
|
|
43
33
|
this.reconstructed = reconstructed;
|
|
44
34
|
this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
|
|
45
|
-
if (
|
|
35
|
+
if (prediction["values"] !== undefined) {
|
|
46
36
|
prediction["values"].forEach((field) => {
|
|
47
37
|
this.values.push(new ListFieldValue(field));
|
|
48
38
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.standard = exports.custom = exports.common = void 0;
|
|
27
|
+
exports.common = __importStar(require("./common"));
|
|
28
|
+
exports.custom = __importStar(require("./custom"));
|
|
29
|
+
exports.standard = __importStar(require("./standard"));
|
|
@@ -3,13 +3,13 @@ export declare function floatToString(value: number): string;
|
|
|
3
3
|
/**
|
|
4
4
|
* A field containing an amount value.
|
|
5
5
|
*/
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class AmountField extends Field {
|
|
7
7
|
/** The value. */
|
|
8
8
|
value?: number;
|
|
9
9
|
/**
|
|
10
10
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
11
11
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
12
|
-
* @param {Boolean} reconstructed -
|
|
12
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
13
13
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
14
14
|
*/
|
|
15
15
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AmountField = exports.floatToString = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
5
|
function floatToString(value) {
|
|
6
6
|
return value.toLocaleString(undefined, {
|
|
@@ -13,14 +13,14 @@ exports.floatToString = floatToString;
|
|
|
13
13
|
/**
|
|
14
14
|
* A field containing an amount value.
|
|
15
15
|
*/
|
|
16
|
-
class
|
|
16
|
+
class AmountField extends field_1.Field {
|
|
17
17
|
/**
|
|
18
18
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
19
19
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
20
|
-
* @param {Boolean} reconstructed -
|
|
20
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
21
21
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
22
22
|
*/
|
|
23
|
-
constructor({ prediction, valueKey = "value", reconstructed = false, pageId = undefined, }) {
|
|
23
|
+
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
|
|
24
24
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
25
25
|
/** The value. */
|
|
26
26
|
this.value = undefined;
|
|
@@ -37,4 +37,4 @@ class Amount extends field_1.Field {
|
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.AmountField = AmountField;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
[index: string]: any;
|
|
3
|
-
};
|
|
1
|
+
import { StringDict } from "../common";
|
|
4
2
|
export interface BaseFieldConstructor {
|
|
5
3
|
prediction: StringDict;
|
|
6
4
|
valueKey?: string;
|
|
7
5
|
reconstructed?: boolean;
|
|
6
|
+
pageId?: number;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* Base class for most fields.
|
|
@@ -14,12 +13,13 @@ export declare class BaseField {
|
|
|
14
13
|
value?: string | number;
|
|
15
14
|
/** `true` when the field was reconstructed or computed using other fields. */
|
|
16
15
|
reconstructed: boolean;
|
|
16
|
+
pageId?: number;
|
|
17
17
|
/**
|
|
18
18
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
19
19
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
20
|
-
* @param {Boolean} reconstructed -
|
|
20
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
21
21
|
*/
|
|
22
|
-
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
22
|
+
constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
|
|
23
23
|
compare(other: BaseField): boolean;
|
|
24
24
|
/**
|
|
25
25
|
* @param {BaseField[]} array - Array of Fields
|
|
@@ -8,9 +8,9 @@ class BaseField {
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
10
10
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
11
|
-
* @param {Boolean} reconstructed -
|
|
11
|
+
* @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
12
12
|
*/
|
|
13
|
-
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
13
|
+
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
|
|
14
14
|
/** The value. */
|
|
15
15
|
this.value = undefined;
|
|
16
16
|
this.reconstructed = reconstructed;
|
|
@@ -19,6 +19,7 @@ class BaseField {
|
|
|
19
19
|
valueKey in prediction &&
|
|
20
20
|
prediction[valueKey] !== null) {
|
|
21
21
|
this.value = prediction[valueKey];
|
|
22
|
+
this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
compare(other) {
|
|
@@ -7,5 +7,5 @@ export declare class ClassificationField extends BaseField {
|
|
|
7
7
|
confidence: number;
|
|
8
8
|
/** The classification. */
|
|
9
9
|
value?: string;
|
|
10
|
-
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
10
|
+
constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
|
|
11
11
|
}
|
|
@@ -6,9 +6,9 @@ const base_1 = require("./base");
|
|
|
6
6
|
* Represents a classifier value.
|
|
7
7
|
*/
|
|
8
8
|
class ClassificationField extends base_1.BaseField {
|
|
9
|
-
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
10
|
-
super({ prediction, valueKey, reconstructed });
|
|
11
|
-
this.confidence = prediction
|
|
9
|
+
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
|
|
10
|
+
super({ prediction, valueKey, reconstructed, pageId });
|
|
11
|
+
this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.ClassificationField = ClassificationField;
|
|
@@ -2,7 +2,7 @@ import { Field, FieldConstructor } from "./field";
|
|
|
2
2
|
/**
|
|
3
3
|
* A company registration item.
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class CompanyRegistrationField extends Field {
|
|
6
6
|
/** Registration identifier. */
|
|
7
7
|
value?: string;
|
|
8
8
|
/** Type of company registration. */
|