speech_rule.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { SREError } from '../common/engine.js';
  2. import { DynamicCstr } from './dynamic_cstr.js';
  3. import * as Grammar from './grammar.js';
  4. import { SpeechRuleContext } from './speech_rule_context.js';
  5. export declare class SpeechRule {
  6. name: string;
  7. dynamicCstr: DynamicCstr;
  8. precondition: Precondition;
  9. action: Action;
  10. context: SpeechRuleContext;
  11. constructor(name: string, dynamicCstr: DynamicCstr, precondition: Precondition, action: Action);
  12. toString(): string;
  13. }
  14. export declare enum ActionType {
  15. NODE = "NODE",
  16. MULTI = "MULTI",
  17. TEXT = "TEXT",
  18. PERSONALITY = "PERSONALITY"
  19. }
  20. interface ComponentType {
  21. type: ActionType;
  22. content?: string;
  23. attributes?: Attributes;
  24. grammar?: Grammar.State;
  25. }
  26. export declare class Component {
  27. type: ActionType;
  28. content: string;
  29. attributes: Attributes;
  30. grammar: Grammar.State;
  31. static grammarFromString(grammar: string): Grammar.State;
  32. static fromString(input: string): Component;
  33. static attributesFromString(attrs: string): {
  34. [key: string]: string | Grammar.State;
  35. };
  36. constructor({ type, content, attributes, grammar }: ComponentType);
  37. toString(): string;
  38. grammarToString(): string;
  39. getGrammar(): string[];
  40. attributesToString(): string;
  41. getAttributes(): string[];
  42. }
  43. type Attributes = {
  44. [key: string]: string;
  45. };
  46. export declare class Action {
  47. components: Component[];
  48. static fromString(input: string): Action;
  49. private static naiveSpan;
  50. private static addNaiveSpan;
  51. constructor(components: Component[]);
  52. toString(): string;
  53. }
  54. export declare class Precondition {
  55. query: string;
  56. private static queryPriorities;
  57. private static attributePriorities;
  58. constraints: string[];
  59. priority: number;
  60. rank: number;
  61. private static constraintValue;
  62. toString(): string;
  63. constructor(query: string, ...cstr: string[]);
  64. private calculatePriority;
  65. private presetPriority;
  66. }
  67. export declare class OutputError extends SREError {
  68. name: string;
  69. constructor(msg: string);
  70. }
  71. export {};