Skip to content

Commit

Permalink
Regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 25, 2020
1 parent 67d584e commit 94d4226
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 274,919 deletions.
34 changes: 23 additions & 11 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
const fs = require('fs')
const path = require('path')
var fs = require('fs')
var path = require('path')
var https = require('https')
var concat = require('concat-stream')
var bail = require('bail')

var root = 'corpus'
var endpoint =
'https://raw.githubusercontent.com/lorenbrichter/Words/master/Words/en.txt'

var data = fs
.readdirSync(root)
.flatMap(d => String(fs.readFileSync(path.join(root, d))).split('\n'))
.map(d => d.toLowerCase())
.filter(Boolean)
.sort()
https.request(endpoint, onrequest).end()

fs.createWriteStream('index.json').end(
JSON.stringify([...new Set(data)]) + '\n'
)
function onrequest(res) {
res.pipe(concat(onconcat)).on('error', bail)
}

function onconcat(buf) {
var data = fs
.readdirSync(root)
.flatMap(d => String(fs.readFileSync(path.join(root, d))).split('\n'))
.concat(String(buf).split('\n'))
.map(d => d.toLowerCase())
.filter(Boolean)
.sort()

fs.writeFile('index.json', JSON.stringify([...new Set(data)]) + '\n', bail)
}
Loading

0 comments on commit 94d4226

Please sign in to comment.