0.0.3 • Published 10 years ago

node-trigger v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

node-trigger

MeCab connector for Node.js

Build Status Coverage Status Code Climate Dependency Status

NPM NPM

System Requirements

$ echo '今日は残業' | mecab
今日	名詞,副詞可能,*,*,*,*,今日,キョウ,キョー,,
は	助詞,係助詞,*,*,*,*,は,ハ,ワ,,
残業	名詞,サ変接続,*,*,*,*,残業,ザンギョウ,ザンギョー,,
EOS

Usage

Installation command is npm install node-trigger.

Quick example

var should = require("should")
  , MeCab = require('node-trigger').MeCab
  ;

    var process = MeCab.parse("今日は残業。明日も残業。");

    var result = {};

    process.on('record', function (record, index) {
      if (record[1] === '名詞') {
        var count = result[record[0]];
        result[record[0]] = count ? ++count : 1;
      }
    });

    process.on('error', function (error) {
      done(error);
    });

    process.on('end', function (count) {
      result.should.eql({ '今日': 1, '残業': 2, '明日': 1 });
      done(null, result, count);
    });

Example 1

    var process = MeCab.parse("今日は残業。明日も残業。");

Example 2

    var process = MeCab.parse(fs.createReadStream("path.to.text_file"));

License

MIT license, go wild.

Change Log

1.0 → 1.1

Add Steming Filter.

  • DoubleByte to SingleByte
 ABC → ABC
 123 → 123
  • Capital to Small
 iPhone → iphone
0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago