/// import Stream from 'stream'; import * as Tp from 'thingpedia'; import { SchemaRetriever } from 'thingtalk'; import { SentenceExample } from '../parsers'; import { AnyEntity } from '../../utils/entity-utils'; interface Constant { key: string; value: AnyEntity; display: string; unit?: string; } interface SampleResult { id: string; utterance: string; target_code: string; depth: number; sentence_length: number; num_functions: number; num_entities: number; num_pp: number; num_filters: number; prim_type: string; function_signature: string; context?: string; context_utterance?: string; assistant_action?: string; } interface SampleOptions { rng: () => number; debug: boolean; functionHighValueList?: Set; } interface SamplingStrategy { init(): StateType; iterate(state: StateType): Iterable<[string, SampleResult[]]>; collect(state: StateType, input: SentenceExample, result: SampleResult, options: SampleOptions): void; sample(key: string, choices: SampleResult[], options: SampleOptions): SampleResult[]; } interface BySentenceSampleState { s: number; sentences: string[]; bags: Map; } declare const SAMPLING_STRATEGIES: { bySignature: SamplingStrategy>; byCode: SamplingStrategy>; bySentence: SamplingStrategy; }; interface SentenceSamplerOptions { samplingStrategy?: keyof typeof SAMPLING_STRATEGIES; functionHighValueList?: Set; functionBlackList?: Set; deviceBlackList?: Set; functionWhiteList?: Set; deviceWhiteList?: Set; compoundOnly: boolean; locale: string; timezone: string; rng: () => number; debug: boolean; } export default class SentenceSampler extends Stream.Transform { private _tpClient; private _schemaRetriever; private _constants; private _options; private _samplingStrategy; private _samplingState; private _detokenizer; constructor(tpClient: Tp.BaseClient, schemaRetriever: SchemaRetriever, constants: Record, options: SentenceSamplerOptions); private _run; _transform(input: SentenceExample, encoding: BufferEncoding, callback: (err?: Error) => void): void; _flush(callback: () => void): void; } export {};