spiegel-keyman/common/predictive-text
2023-02-09 12:12:18 +07:00
..
docs chore(common): use /usr/bin/env bash 2022-07-25 14:59:37 +10:00
testing chore(web): embedded web cleanup 2022-05-12 07:37:10 +10:00
unit_tests chore(common): add builder_term function 2023-02-08 12:49:54 +07:00
.build-builder chore(common/models): minor tweaks per review 2022-10-05 09:04:23 +07:00
.gitignore fix(common): Actually adds polyfill (and fixes .gitignore) 2019-12-10 09:24:23 +07:00
browser.tsconfig.json chore(web): eliminates es6-shim TS project 2022-05-31 09:35:52 +07:00
build.sh chore(common): automatically apply _builder_check_color 2023-02-09 12:12:18 +07:00
embedded_worker.d.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
index.d.ts chore(web): move lm-worker into its own folder 2022-04-14 15:33:23 +10:00
index.ts change(common/models): adds optional 'testMode' param to LMLayer config 2022-10-31 09:34:22 +07:00
node-defaultWorker.ts refactor(common/lmlayer): Adapts to rework of base PR 2020-04-17 11:18:13 +07:00
package.json chore(web): updates karma dev-dependency 2022-09-22 09:13:20 +07:00
promise-store.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00
README.md feat(common): lerna now npm-installed locally 2020-04-21 15:55:43 +07:00
tsconfig.json chore(web): eliminates es6-shim TS project 2022-05-31 09:35:52 +07:00
virtualizedWorker.ts change(common/lmlayer): a bit more PR review polish 2020-04-20 23:18:22 +07:00
web-defaultWorker.ts refactor(common/lmlayer): Adapts to rework of base PR 2020-04-17 11:18:13 +07:00
worker-interface.d.ts chore(web): replace lerna with npm workspaces and ts projects 2022-04-12 21:02:33 +10:00

Language Modelling Layer (LMLayer)

Provide predictions and corrections while you type!

See Worker Communication Protocol for a semi-formal specification on how the Worker and the main thread communicate.

System dependencies

You will need Bash and Node.js >= 10.0.

Build

Run build.sh. This will also automatically install dependencies with npm.

./build.sh

Two-stage compilation process

Since the primary LMLayer code runs within a Web Worker, build.sh compiles the LMLayer in two stages:

  1. Compile the inner worker code

    1. Compile the TypeScript sources for only the Worker code.
    2. Wrap the Worker code as embedded_worker.js
  2. Compile the top-level code

    1. Include embedded_worker.js verbatim using a TypeScript directive.
    2. Compile the top-level TypeScript code.
    3. Unwrap the Worker code at runtime.

Test

This will run both headless unit tests, and in-browser unit tests and integration tests:

./build.sh -test

Test-Driven Development

I like to use entr to automatically build and re-run the unit tests anytime I change a source code file. Here's the command I run in separate window:

git ls-files | entr -c ./build.sh -tdd

Importantly, ./build.sh -tdd skips running the in-browser tests, and skips downloading/updating npm dependencies.