mindee
Version:
Mindee Client Library for Node.js
21 lines (20 loc) • 939 B
JavaScript
import { Inference, Page } from "../../../v1/parsing/common/index.js";
import { GeneratedV1Document } from "./generatedV1Document.js";
import { GeneratedV1Page } from "./generatedV1Page.js";
/**
* Generated API V1 inference results.
*/
export class GeneratedV1 extends Inference {
constructor(rawPrediction) {
super(rawPrediction);
/** The endpoint's name. Note: placeholder for custom APIs. */
this.endpointName = "custom";
/** The endpoint's version. Note: placeholder for custom APIs. */
this.endpointVersion = "1";
/** The document's pages. */
this.pages = [];
this.prediction = new GeneratedV1Document(rawPrediction["prediction"]);
this.pages = rawPrediction["pages"].length > 0 && Object.keys(rawPrediction["pages"][0]["prediction"]).length > 0 ?
rawPrediction["pages"].map((page) => new Page(GeneratedV1Page, page, page["id"])) : [];
}
}