UNPKG

speech-rule-engine

Version:

A standalone speech rule engine for XML structures, based on the original engine from ChromeVox.

33 lines 1.11 kB
import { Options } from '../common/options.js'; export const SemanticHeuristics = { factory: null, options: new Options(), updateFactory: function (nodeFactory) { SemanticHeuristics.factory = nodeFactory; }, heuristics: new Map(), flags: { combine_juxtaposition: true, convert_juxtaposition: true, multioperator: true }, blacklist: {}, add: function (heuristic) { const name = heuristic.name; SemanticHeuristics.heuristics.set(name, heuristic); if (!SemanticHeuristics.flags[name]) { SemanticHeuristics.flags[name] = false; } }, run: function (name, root, opt_alternative) { const heuristic = SemanticHeuristics.heuristics.get(name); return heuristic && !SemanticHeuristics.blacklist[name] && (SemanticHeuristics.flags[name] || heuristic.applicable(root)) ? heuristic.apply(root) : opt_alternative ? opt_alternative(root) : root; } }; //# sourceMappingURL=semantic_heuristic_factory.js.map