// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*- // // This file is part of Genie // // Copyright 2020 The Board of Trustees of the Leland Stanford Junior University // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: Giovanni Campagna // Templates for converting one-shot commands into continuous commands import * as $runtime from "../../sentence-generator/runtime"; import type $SentenceGenerator from "../../sentence-generator/generator"; import * as $SentenceGeneratorTypes from "../../sentence-generator/types"; import * as $I18n from "../../i18n/index"; import { Ast, } from 'thingtalk'; import * as C from '../ast_manip'; import * as S from '../state_manip'; import * as D from '../dialogue_acts'; import ThingpediaLoader from '../load-thingpedia'; export const notification_preamble : $SentenceGeneratorTypes.NonTerminal = "notification_preamble"; export const notification_error_preamble : $SentenceGeneratorTypes.NonTerminal = "notification_error_preamble"; export const add_separate_stream_to_query : $SentenceGeneratorTypes.NonTerminal = "add_separate_stream_to_query"; export const add_separate_stream : $SentenceGeneratorTypes.NonTerminal = "add_separate_stream"; /** * Load the templates in this file. * * This is an autogenerated method that will be called by the {@link SentenceGenerator} * when the templates are imported. */ export async function $load($options : $SentenceGeneratorTypes.GrammarOptions, $locale : $I18n.LanguagePack, $grammar : $SentenceGenerator, $loader : ThingpediaLoader) : Promise { $grammar.declareSymbol("notification_preamble"); $grammar.addRule("notification_preamble", [new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined)], $locale._("reminder:"), ((ctx : S.ContextInfo) : (S.ContextInfo)|null => D.checkIsReminder(ctx, 'say')), S.contextKeyFn, { priority: (1) }); $grammar.addRule("notification_preamble", [new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined)], $locale._("alert:"), ((ctx : S.ContextInfo) : (S.ContextInfo)|null => D.checkIsReminder(ctx, 'alert')), S.contextKeyFn, { priority: (1) }); $grammar.addRule("notification_preamble", [new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined)], $locale._("alert:"), ((ctx : S.ContextInfo) : (S.ContextInfo)|null => D.checkIsReminder(ctx, 'timer_expire')), S.contextKeyFn, { priority: (1) }); $grammar.addRule("notification_preamble", [new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined), new $runtime.NonTerminal("ctx_notification_app_name", "app", undefined)], $locale._("notification from ${app}:"), ((ctx : S.ContextInfo, app : Ast.Value) : (S.ContextInfo)|null => ctx), S.contextKeyFn, { }); $grammar.addRule("notification_preamble", [new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined)], '', ((ctx : S.ContextInfo) : (S.ContextInfo)|null => ctx.state.dialogueActParam === null ? ctx : null), S.contextKeyFn, { priority: (-1) }); $grammar.declareSymbol("notification_error_preamble"); $grammar.addRule("notification_error_preamble", [new $runtime.NonTerminal("sorry_preamble", "sorry", undefined), new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined), new $runtime.NonTerminal("ctx_notification_app_name", "app", undefined)], $locale._("${sorry} {there was an error in|an error occurred in} ${app}:"), ((sorry : string, ctx : S.ContextInfo, app : Ast.Value) : (S.ContextInfo)|null => ctx), S.contextKeyFn, { }); $grammar.addRule("notification_error_preamble", [new $runtime.NonTerminal("sorry_preamble", "sorry", undefined), new $runtime.NonTerminal("ctx_with_notification", "ctx", undefined)], $locale._("${sorry} {there was an error}:"), ((sorry : string, ctx : S.ContextInfo) : (S.ContextInfo)|null => ctx.state.dialogueActParam === null ? ctx : null), S.contextKeyFn, { }); $grammar.declareSymbol("add_separate_stream_to_query"); if ($options.flags.timer) { $grammar.addRule("add_separate_stream_to_query", [new $runtime.NonTerminal("timer", "stream", undefined)], $locale._("{send this to me|send it to me|i want to see this|i want this|send this} ${stream}"), ((stream : Ast.FunctionCallExpression) : (Ast.Expression)|null => stream), C.expressionKeyFn, { }); } $grammar.addRule("add_separate_stream_to_query", [new $runtime.NonTerminal("stream", "stream", undefined)], $locale._("{send this to me|send it to me|i want to see this|i want this|send this} ${stream}"), ((stream : Ast.Expression) : (Ast.Expression)|null => stream), C.expressionKeyFn, { }); $grammar.declareSymbol("add_separate_stream"); $grammar.addRule("add_separate_stream", [new $runtime.NonTerminal("stream", "stream", undefined)], $locale._("{do this|do it|do it automatically} ${stream}"), ((stream : Ast.Expression) : (Ast.Expression)|null => stream), C.expressionKeyFn, { }); if ($options.flags.timer) { $grammar.addRule("add_separate_stream", [new $runtime.NonTerminal("timer", "stream", undefined)], $locale._("{do this|do it|do it automatically} ${stream}"), ((stream : Ast.FunctionCallExpression) : (Ast.Expression)|null => stream), C.expressionKeyFn, { }); } };