-
Notifications
You must be signed in to change notification settings - Fork 0
/
write-fingerspelling-dictionaries.js
28 lines (20 loc) · 1.08 KB
/
write-fingerspelling-dictionaries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env node
// this file parses a dictionary, and creates 2 new json files
// one that is all the fingerspellings (e.g. every stroke is a single letter)
// and one that is the fingersepllings stripped out.
// it is a modififcation of the phrase-parser.js
const fs = require('fs')
const { entryIsFingerspelling } = require('./dictionary-filters')
const main = require('./top-10000-project-gutenberg-words')
const fingerSpellings = Object.entries(main)
.filter(entryIsFingerspelling)
const fingerSpellingsObject = Object.fromEntries(fingerSpellings)
const entryIsInFingerspellings = ([chord]) => {
const fingerspellingChords = Object.keys(fingerSpellingsObject)
return fingerspellingChords.includes(chord)
}
const withoutFingerSpellings = Object.entries(main)
.filter((entry) => !entryIsInFingerspellings(entry))
const withoutFingerSpellingsObject = Object.fromEntries(withoutFingerSpellings)
fs.writeFileSync('fingerspellings.json', JSON.stringify(fingerSpellingsObject, null, 2))
fs.writeFileSync('withoutFingerspellings.json', JSON.stringify(withoutFingerSpellingsObject, null, 2))