UNPKG

fast-topics

Version:

Unsupervised topic extraction from text using Latent Dirichlet Allocation in WebAssembly

48 lines (47 loc) 1.83 kB
import type { GetTopicsOptions } from "./GetTopicsOptions"; /** * set WASM initialisation function to fetching a URL of the .wasm file */ export declare const initWithFetch: (url?: string) => () => Promise<void>; /** * set WASM initialisation function to ArrayBuffer binary (slower than fetching URL) */ export declare const initWithBinary: (binary: ArrayBuffer) => () => Promise<void>; /** * set the initialisation function. Defaults to fetch URL. */ export declare const setInitFunction: (initFunc: any) => void; /** * initialise WASM by fetching a URL of the .wasm file */ export declare function initialiseWasm(url: string): any; /** * initialise WASM with an ArrayBuffer binary (slower than fetching URL) */ export declare function initialiseWasm(binary: ArrayBuffer): any; /** * Return type of getTopics. Contains keys `{ docs, topics }` which are each arrays. * `docs` is an array of the documents (with the same indexes as the input documents). * `topics` is an array of the generated topics, and their indexes match the topic references in documents. */ export interface GetTopicsReturnType { docs: Record<string, { topic: number; rank: number; }>[]; topics: Record<string, { word: number; rank: number; }>[]; } /** * Get the topics in a set of documents (strings). * @param docs - an array of strings, where each string is a "document". * @param opts - options for the topic extraction */ export declare const getTopics: (docs: string[], opts?: Partial<GetTopicsOptions>) => GetTopicsReturnType; /** * Returns true if getTopics() is ready to be called. This depends on the WebAssembly module being instantiated first. */ export declare const isGetTopicsReady: () => boolean; export type { GetTopicsOptions };