-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest.js
More file actions
41 lines (35 loc) · 1.26 KB
/
test.js
File metadata and controls
41 lines (35 loc) · 1.26 KB
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
31
32
33
34
35
36
37
38
39
40
41
var toolbox = require('toolbox');
var nlpsum = require('nlpsum').main;
var _ = require('underscore');
var sum = new nlpsum();
var sources = ["example-01","example-02","example-03","example-04"];
_.each(sources, function(filename) {
toolbox.file.read(filename+".txt", function(content) {
var types = ["fractal","wordFrequency","sinFrequency","sinWordFrequency"];
_.each(types, function(type) {
generateSummary(filename, content, type);
});
});
})
function generateSummary(filename, content, type) {
switch (type) {
default:
case "fractal":
var summary = sum.fractalSummary(content, 6);
break;
case "wordFrequency":
var summary = sum.wordFrequencySummary(content, 5);
break;
case "sinFrequency":
var summary = sum.sinFrequencySummary(content, 5);
break;
case "sinWordFrequency":
var summary = sum.sinWordFrequencySummary(content, 5);
break;
}
console.log("\n\n-------------- ["+filename+"]["+type+"] --------------");
console.log(summary.text);
toolbox.file.write("output/"+filename+"-"+type+"-data.json", JSON.stringify(summary, null, 4));
toolbox.file.write("output/"+filename+"-"+type+"-summary.txt", summary.text);
toolbox.file.write("output/"+filename+"-"+type+"-tagged.json", JSON.stringify(sum.tag(summary.text), null, 4));
}