Skip to content

Commit 94a3b12

Browse files
committed
minor fixes for term frequency
1 parent 7255ea0 commit 94a3b12

File tree

190 files changed

+153696
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+153696
-17
lines changed
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
1+
const fs = require('fs');
2+
var csvdata = require('csvdata');
3+
var writeFile = require('write');
4+
var createFile = require('create-file');
5+
let writeStream = fs.createWriteStream('secret.txt');
16
var LineByLineReader = require('line-by-line'),
27
lr = new LineByLineReader('French_v1.txt');
38
var sw = require('stopword');
49
var total ="";
5-
10+
// var logStream = fs.createWriteStream('log.txt', {'flags': 'a'});
611
lr.on('error', function (err) {
712
// 'err' contains error object
813

914
});
10-
15+
var arr1=[];
1116
lr.on('line', function (line) {
1217
// 'line' contains the current line without the trailing newline character.
13-
total = total + " " + line.toLowerCase();
14-
//console.log(total);
18+
total = line.toLowerCase();
19+
var oldString = total.split(' ');
20+
// sw.sv contains swedish stopwords
21+
var newString = sw.removeStopwords(oldString, sw.fr);
22+
newString = newString +'\n';
23+
arr1.push(newString);
24+
// logStream.write(newString);
25+
fs.appendFile('FrenchStopWordsRemoved.txt', newString, (err) => {
26+
// throws an error, you could also catch it here
27+
if (err) throw err;
28+
29+
// success case, the file was saved
30+
console.log('saved!');
31+
});
32+
console.log(total);
1533
});
1634

1735
lr.on('end', function () {
1836
// All lines are read, file is closed now.
19-
console.log(total);
20-
console.log(total.length);
21-
const oldString = total.split(' ');
22-
// sw.sv contains swedish stopwords
23-
const newString = sw.removeStopwords(oldString, sw.fr);
24-
console.log(newString);
25-
console.log(newString.length)
37+
// console.log(total);
38+
console.log(total.length);
39+
csvdata.write('./stoppedString.csv', arr1, {header: 'Text'});
40+
// console.log(newString);
41+
// console.log(newString.length);
2642
});

0 commit comments

Comments
 (0)