mindee
Version:
Mindee Client Library for Node.js
44 lines (43 loc) • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocaleField = void 0;
const base_1 = require("./base");
/**
* The locale detected on the document.
*/
class LocaleField extends base_1.BaseField {
/**
* @param {BaseFieldConstructor} constructor Constructor parameters.
*/
constructor({ prediction = {}, reconstructed = false, pageId = undefined, }) {
const valueKey = prediction["value"] ? "value" : "language";
super({ prediction, valueKey, reconstructed, pageId });
this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
this.language =
prediction["language"] !== undefined ? prediction["language"] : undefined;
this.country =
prediction["country"] !== undefined ? prediction["country"] : undefined;
this.currency =
prediction["currency"] !== undefined ? prediction["currency"] : undefined;
}
/**
* Default string representation.
*/
toString() {
let outStr = "";
if (this.value) {
outStr += `${this.value}; `;
}
if (this.language) {
outStr += `${this.language}; `;
}
if (this.country) {
outStr += `${this.country}; `;
}
if (this.currency) {
outStr += `${this.currency};`;
}
return outStr.trimEnd();
}
}
exports.LocaleField = LocaleField;