import { Ast, Type } from 'thingtalk'; import * as SentenceGeneratorRuntime from '../sentence-generator/runtime'; import { GrammarOptions } from '../sentence-generator/types'; import SentenceGenerator from '../sentence-generator/generator'; import * as ThingTalkUtils from '../utils/thingtalk'; import * as I18n from '../i18n'; import { ParamSlot } from './utils'; export interface ParsedPlaceholderPhrase { names: string[]; replaceable: SentenceGeneratorRuntime.Replaceable; } interface NormalizedResultPhraseList { top: ParsedPlaceholderPhrase[]; list: ParsedPlaceholderPhrase[]; list_concat: ParsedPlaceholderPhrase[]; empty: ParsedPlaceholderPhrase[]; } interface FollowUpRecord { schema: Ast.FunctionDef; params: string[]; condition?: { name: string; value: string; }; } /** * Initialize templates that depend on Thingpedia. * * This class will load the information in Thingpedia manifests and * primitive template files, and initialize the templates defined * in {@link CommonTemplates}. * * This class should not be constructed directly. Instead, an appropriately * initialized loader can be retrieved from {@link SentenceGenerator.tpLoader}. */ export default class ThingpediaLoader { private _grammar; private _schemas; private _tpClient; private _langPack; private _options; private _describer; private _entities; private _errorMessages; private _resultPhrases; private _followUps; private _initialFunction; types: Map; params: ParamSlot[]; projections: Array<{ pname: string; pslot: ParamSlot; category: string; pronoun: string; base: string; canonical: string; }>; idQueries: Map; compoundArrays: { [key: string]: InstanceType; }; globalWhiteList: string[] | null; standardSchemas: { timer: Ast.FunctionDef; attimer: Ast.FunctionDef; ontimer: Ast.FunctionDef; say: Ast.FunctionDef | null; alert: Ast.FunctionDef | null; timer_expire: Ast.FunctionDef | null; get_gps: Ast.FunctionDef | null; get_time: Ast.FunctionDef | null; }; entitySubTypeMap: Record; private _subEntityMap; constructor(grammar: SentenceGenerator, langPack: I18n.LanguagePack, options: GrammarOptions); init(): Promise; get locale(): string; get timezone(): string | undefined; get flags(): { [key: string]: boolean; }; get describer(): ThingTalkUtils.Describer; get initialFunction(): Ast.FunctionDef | null; isIDType(type: Type): boolean; getFollowUp(functionName: string): FollowUpRecord | undefined; getResultPhrases(functionName: string): NormalizedResultPhraseList; getErrorMessages(functionName: string): Record; private _addRule; private _tryGetStandard; private _recordType; private _addOutParam; private _getConstantNT; private _collectByPOS; private _getRuleAttributes; private _recordInputParam; private _recordBooleanOutputParam; private _recordOutputParam; private _recordOutputParamByType; private _addProjections; private _loadTemplate; private _addPrimitiveTemplate; /** * Convert a primitive template into a regular template that introduces a * coreference. */ private _addCoreferencePrimitiveTemplate; private _getPrimitiveTemplatePriority; /** * Convert a primitive template into a regular template that performs * a join with parameter passing by replacing exactly one placeholder * with a whole query or stream, and replacing the other placeholders with constants * or undefined. */ private _addPlaceholderReplacementJoinPrimitiveTemplate; /** * Convert a primitive template into a regular template that uses * only constants and undefined. */ private _addConstantOrUndefinedPrimitiveTemplate; private _makeExampleFromAction; private _makeExampleFromQuery; private _recordFunction; private _loadFunction; private _loadPlaceholderPhraseCommon; private _loadCustomErrorMessages; private _loadCustomResultPhrases; private _loadDevice; private _loadEntityType; private _addEntityConstants; private _loadDataset; private _safeLoadTemplate; private _getAllDeviceNames; private _loadMetadata; } export {};