github Speech-Rule-Engine/speech-rule-engine v4.0.0-beta.0
SRE in Typescript: First Beta

latest releases: v4.1.0-beta.10, v4.1.0-beta.8, v4.1.0-beta.9...
3 years ago

First Beta release of SRE in Typescript. Note, that unlike the alpha, this beta version already contains a number of breaking changes.

Mathmaps

  • Unicode mappings are again in files with a .json.
  • Likewise compile locale mappings are in a single .json file in lib/mathmaps.
  • Sources are now in the top level mathmaps directory.
  • Each locale also contains a messages subdirectory. These contains messages used for generating alphabets, font names etc. Note, that in the combined, minified version of the locale .json, messages always need to come first.

Structure and Build

  • All legacy JavaScript code has been removed.
  • The src file has been removed.
  • The mathmaps subdirectory has been moved to the top level.
  • The Makefile is now exclusively for building the unicode mapping files, one per locale.
  • Building sre is now done with npx tsc; npx webpack

Internal Changes

Changes to data structures, speech rules and code structure.

Simple Speech Rules

Simple speech rules for unicode symbols, functions and units are now handled separately from regular speech rules. That is, the data structure MathSimpleStore no longer inherits from MathStore. While this requires some additional logic for parsing, looking up, and selecting simple rules it reduces the memory footprint of functionality never required by simple rule stores.

Speech Rule Stores

Classes with interface SpeechRuleStore no longer have a trie for indexing speech rules. They are exclusively a container for storing rules together with a common context. Rule look up can only be done via findRule .
In particular stores do no longer provide a lookupRule method that matches rule applicability with respect to a given DOM node.
Rule lookup is not done on tries only.

Speech Rule Engine

The core engine no longer uses a SpeechRuleStore to lookup rules. Previously an active store would have been selected or constructed as a combination of stores, that the store's trie would be use for looking up rules. Now the engine uses a single trie only.

Speech rules are immediately sorted into the trie on load of a locale. While the trie can still be pruned, there is no longer any combining of rule store (into the active store) or reindexing of tries. The rule engine can therefore no longer be furnished with a selection of speech rules stores, only. It will always work with all rules of all locales currently loaded.

Locale Messages

Code for locales that was included in the compiled version has been considerably reduced. Only methods for number string generation and alphabet combinations remain. The latter are often shared between multiple locales. Consequently the growth of the size of sre.js should be small when adding new locales.

Messages for locales have been refactored into three categories, included in a new messages subdirectory and in the locale JSON structures:

  • alphabets: Strings for Greek and Latin alphabets and corresponding prefixes.
  • messages: Messages for MathSpeak, fonts, embellishments, roles, etc.
  • numbers: Strings necessary for generating numbers.

Future changes

The next step will be the devolution of preconditions of speech rules from their actions. That is common preconditions for speech rules will be stored in and loaded from a "base locale", while proper locales will only contain the respective actions.

Don't miss a new speech-rule-engine release

NewReleases is sending notifications on new releases.