tm-corpus
v1.1.2
Published
Text mining library
Downloads
2
Readme
Text Mining nodejs Library
Simple
var tm = require("tm-corpus");
console.log(tm("silahkan hina aku sepuasnya kamu suci aku penuh dosa"));
output :
[ { word: 'aku', count: 2 },
{ word: 'silahkan', count: 1 },
{ word: 'hina', count: 1 },
{ word: 'sepuasnya', count: 1 },
{ word: 'kamu', count: 1 },
{ word: 'suci', count: 1 },
{ word: 'penuh', count: 1 },
{ word: 'dosa', count: 1 } ]
StopWords
Array
var tm = require("tm-corpus");
var opts = {
text: "silahkan hina aku sepuasnya kamu suci aku penuh dosa",
sw: ["aku","kamu"]
}
console.log(tm(opts));
output :
[ { word: 'silahkan', count: 1 },
{ word: 'hina', count: 1 },
{ word: 'sepuasnya', count: 1 },
{ word: 'suci', count: 1 },
{ word: 'penuh', count: 1 },
{ word: 'dosa', count: 1 } ]
String
var tm = require("tm-corpus");
var opts = {
text: "silahkan hina aku sepuasnya kamu suci aku penuh dosa",
sw: "aku kamu"
}
console.log(tm(opts));
output :
[ { word: 'silahkan', count: 1 },
{ word: 'hina', count: 1 },
{ word: 'sepuasnya', count: 1 },
{ word: 'suci', count: 1 },
{ word: 'penuh', count: 1 },
{ word: 'dosa', count: 1 } ]
Text mining from twitter
var Twitter = require('twitter');
var tm = require('tm-corpus');
var client = new Twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: ''
});
var text = [];
var opt = {count:100,q:"ahok"}
client.get('search/tweets',opt , function(error, tweets, response) {
tweets.statuses.forEach(function(data){
text.push(data.text);
});
console.log(tm(text.join(" ")))
});