tm-corpus

1.1.2 • Public • Published

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(" ")))
});

yongleks

Readme

Keywords

Package Sidebar

Install

npm i tm-corpus

Weekly Downloads

1

Version

1.1.2

License

MIT

Last publish

Collaborators

  • anak10thn