-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 893 Bytes
/
index.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
29
30
'use strict'
const program = require('commander')
const fs = require('fs')
const { extractFromHTML } = require('./lib/extractSentences')
const summarizeText = require('./lib/summarizeText')
const exportAsHTML = require('./lib/exportAsHTML')
program.version('0.0.1')
.option('-f, --filename [filename]', 'File path to generate summary of')
.option('-s, --sentences [num]', 'Number of sentences in summary')
.parse(process.argv)
if (!program.filename) {
console.log('filename parameter is required.')
program.help()
}
program.sentences = program.sentences || 5
program.sentences = Number(program.sentences)
fs.readFile(program.filename, function (err, data) {
if (err) {
console.error(err)
}
const { title, allsentences } = extractFromHTML(data)
const { selectedSentences } = summarizeText(allsentences, program.sentences)
exportAsHTML(title, selectedSentences)
})