-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (23 loc) · 1.17 KB
/
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
// ---------------------------------------------------------------------------------------------------------------------
// Markov text generator for a PDF source
//
// ---------------------------------------------------------------------------------------------------------------------
const fs = require('fs');
const pdf = require('pdf-parse');
const markov = require('markov-text-generator').default;
// ---------------------------------------------------------------------------------------------------------------------
let response = fs.readFileSync('/home/todom/Downloads/Plf Response to MTD.pdf');
let petition = fs.readFileSync('/home/todom/Downloads/Plaintiff\'s Second Amended Petition.pdf');
return Promise.all([pdf(response, { max: 33 }), pdf(petition, { max: 28 })])
.then(function(data)
{
const gen = new markov();
let text = data[0].text + data[1].text;
gen.setTrainingText(text);
for(var i = 0; i < 10; i++)
{
console.log(gen.generateText(50));
console.log();
}
});
// ---------------------------------------------------------------------------------------------------------------------