mindee
Version:
Mindee Client Library for Node.js
53 lines (52 loc) • 2.22 kB
TypeScript
import { StringDict } from "../common";
import { Extras } from "./extras/extras";
import { Page } from "./page";
import type { Prediction } from "./prediction";
import { Product } from "./product";
/**
*
* @typeParam DocT an extension of a `Prediction`. Is generic by default to
* allow for easier optional `PageT` generic typing.
* @typeParam PageT an extension of a `DocT` (`Prediction`). Should only be set
* if a document's pages have specific implementation.
*/
export declare abstract class Inference<DocT extends Prediction = Prediction, PageT extends DocT = DocT> {
/** A boolean denoting whether a given inference result was rotated. */
isRotationApplied?: boolean;
/** Name and version of a given product. */
product: Product;
/** Wrapper for a document's pages prediction. */
pages: Page<PageT>[];
/** A document's top-level `Prediction`. */
prediction: DocT;
/** Extraneous fields relating to specific tools for some APIs. */
extras?: Extras;
/** Name of a document's endpoint. Has a default value for OTS APIs. */
endpointName?: string;
/** A document's version. Has a default value for OTS APIs. */
endpointVersion?: string;
constructor(rawPrediction: StringDict);
/**
* Default string representation.
*/
toString(): string;
/**
* Takes in an input string and replaces line breaks with `\n`.
* @param outStr string to cleanup
* @returns cleaned out string
*/
static cleanOutString(outStr: string): string;
}
/**
* Factory to allow for static-like property access syntax in TypeScript.
* Used to retrieve endpoint data for standard products.
*/
export declare class InferenceFactory {
/**
* Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
* Note: this is needed to avoid passing anything other than the class of the object to the parse()/enqueue() call.
* @param inferenceClass Class of the product we are using
* @returns {Inference} An empty instance of a given product.
*/
static getEndpoint<T extends Inference>(inferenceClass: new (httpResponse: StringDict) => T): [string, string];
}