UNPKG

mindee

Version:

Mindee Client Library for Node.js

40 lines (39 loc) 1.32 kB
import { BaseField } from "./base.js"; /** * The locale detected on the document. */ export class LocaleField extends 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(); } }