Skip to content

Instantly share code, notes, and snippets.

@Hugo-ter-Doest
Created May 4, 2020 08:09
Show Gist options
  • Save Hugo-ter-Doest/0f2c158a1acd7e9a3fd71ee043e7e2c3 to your computer and use it in GitHub Desktop.
Save Hugo-ter-Doest/0f2c158a1acd7e9a3fd71ee043e7e2c3 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var natural = require('./lib/natural');
var data = fs.readFileSync('./data.txt', 'utf8');
var sentenceTok = new natural.SentenceTokenizer();
var aggressiveTok = new natural.AggressiveTokenizer();
var sentences = sentenceTok.tokenize(data);
//console.log(sentences);
sentences.forEach(function(s) {
var words = aggressiveTok.tokenize(s);
console.log(words);
});
// and then concatenate arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment