UNPKG

@thi.ng/text-analysis

Version:

Text tokenization, transformation & analysis transducers, utilities, stop words, porter stemming, vector encodings, similarities

40 lines 1.26 kB
import type { Transducer } from "@thi.ng/transducers"; /** * Transducer which emits ngrams of received input tokens. * * @remarks * Also see {@link withNgrams}. * * @example * ```ts * import { ngrams } from "@thi.ng/text-analysis"; * * console.log([...ngrams(2, " ", ["wish", "you", "were", "here"])]); * // [ "wish you", "you were", "were here" ] * ``` * * @param n * @param sep */ export declare function ngrams(n: number, sep?: string): Transducer<string, string>; export declare function ngrams(n: number, sep: string, src: Iterable<string>): IterableIterator<string>; /** * Transducer which emits original input tokens with their interleaved ngrams. * * @remarks * Also see {@link ngrams} to ONLY produce a sequence of ngrams. * * @example * ```ts * import { withNgrams } from "@thi.ng/text-analysis"; * * console.log([...withNgrams(2, " ", ["wish", "you", "were", "here"])]); * // [ "wish", "you", "wish you", "were", "you were", "here", "were here" ] * ``` * * @param n * @param sep */ export declare function withNgrams(n: number, sep?: string): Transducer<string, string>; export declare function withNgrams(n: number, sep: string, src: Iterable<string>): IterableIterator<string>; //# sourceMappingURL=ngrams.d.ts.map