Overview
In order to keep lessons (fundamentals, drills, collections; not stories) up to date with the latest dictionaries, we can add linter checks that flag changes that need to be made, which can then be made manually.
Background
This is a useful part of the larger work to make the static lesson generator project (which is not open source) redundant. Instead of generating lesson files with words and strokes from word lists and dictionaries, we could keep word lists in this project as the source of truth for lessons, and then use a linter to check what words match lesson criteria.
Linter checks
Filter: "Strokes that…" where a word now qualifies or no longer qualifies
If dictionaries change and a word no longer qualifies for a lesson (e.g. a word that is no longer a single-stroke word should be removed from the single-stroke briefs lesson), the linter should highlight what word no longer qualifies, what criteria it doesn't match, and for what lesson.
Likewise if a word now qualifies but isn't in a lesson.
Filter: "Words that…" where a word now qualifies or no longer qualifies
If "z-index" moves from the HTML dictionary to the CSS dictionary and should no longer appear in the "HTML" lesson and should now appear in a "CSS" lesson, the linter should highlight the word that no longer qualifies or now qualifies, what criteria it doesn't or does match, and for what lesson.
Filter: "Entries that…" where a word and stroke combo now qualify or no longer qualifies
If "rest" is changed from REFT
to R*ES
, it should no longer qualify for the "One-syllable words with F as V or S" lesson, even though it is still one syllable and has an "s" sound (the word qualifies) but the stroke has no F
(the stroke does not qualify).
Likewise for changed strokes that now qualify. Likewise for words that newly qualify. Likewise for words that no longer qualify.
Sorting
If "longest words" lesson has words of different lengths in any order, the linter should flag which lesson is out of order, what sorting method it is using, and what words fail the sorting method for that lesson.
De-duplication
Don't show "the" 3 times because it's in 3 dictionaries.
Linter requirements
Input:
- Dictionaries: a source dictionary or dictionaries in a given order (either the
typey-type.json
generated dictionary or the source dictionaries that it is generated from in a specific order; or perhaps specific domain dictionaries like html.json
)
- Lesson: a lesson name/id and all its criteria
- Word list: the lesson word list to check
- Affixes: preferred prefixes and suffixes (should these be moved into a shared file that is used directly by Typey Type? As a dictionary?)
Processing will need:
- Filters: individual "filter" criterion, such as "one syllable" or "stroke contains an asterisk"
- Lesson filter list: a way to specify all criteria for a lesson, e.g. "one syllable" AND "F as V or S" and no duplicates and what sorting method
- De-duplication: a way to de-duplicate words that appear repeatedly across dictionaries
- Sorting: sorting methods, such as default/unsorted or by word length
Output:
- a list of lessons that failed
- what filter, de-dup, or other check failed the lesson
- what word failed the filter
- what sorting failed the lesson
Tests:
- e.g. given "mysql", the "one syllable" filter should return
false
Approach
Create a node.js linter with tests to run on lessons. Perhaps use the lessonIndex.json
as source for lessons to check.