spiegel-keyman/common/predictive-text
2019-08-07 10:36:49 +07:00
..
docs Update worker-communication-protocol.md 2019-07-03 09:49:25 +07:00
testing
unit_tests Adjusts old unit test accordingly. 2019-08-07 10:36:49 +07:00
worker Fixes double-space bug. 2019-08-07 09:38:55 +07:00
.gitignore
build.sh
embedded_worker.d.ts
index.d.ts Merge branch 'web-lmlayer-model-registration' into lmlayer-wordbreak-spec 2019-03-07 09:04:00 +07:00
index.ts Addresses most concerns of recent PR review. 2019-07-03 09:41:50 +07:00
message.d.ts Moves .isKeep prop to .tag == 'keep'. 2019-07-04 08:09:30 +07:00
package-lock.json Keep suggestion now always gets quoted 'displayAs' 2019-07-22 10:20:59 +07:00
package.json [LMLayer] Make license consistent with rest of Keyman 2019-07-26 06:52:31 +10:00
promise-store.ts
README.md
tsconfig.json

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 >= 6.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.