Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/golbin/node-mecab-ya
Yet another mecab wrapper for nodejs
https://github.com/golbin/node-mecab-ya
Last synced: 18 days ago
JSON representation
Yet another mecab wrapper for nodejs
- Host: GitHub
- URL: https://github.com/golbin/node-mecab-ya
- Owner: golbin
- Created: 2016-04-09T14:33:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-10-20T01:08:16.000Z (about 2 years ago)
- Last Synced: 2024-10-11T21:21:42.073Z (about 1 month ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 106
- Watchers: 9
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mecab-ya
Yet another mecab wrapper for nodejs and the main purpose is easy to use.
[Mecab](http://taku910.github.io/mecab/) is a morphological analyzer for Japanease language.
And you can use this for Korean language with [mecab-ko](https://bitbucket.org/eunjeon/mecab-ko/).
## Install
```bash
$ npm install mecab-ya
```## Requirements
You need mecab or mecab-ko for Korean language.
If you don't have mecab yet, you can install with the prepared script.
```bash
$ node_modules/mecab-ya/bin/install-mecab
```For the Korean language.
```bash
$ node_modules/mecab-ya/bin/install-mecab ko
```## Usage
mecab-ya use the mecab library in the `node_modules/mecab-ya/mecab` directory.
But, you can set a mecab library path like below.
```
MECAB_LIB_PATH=/usr/local/lib node index.js
```OR
```
MECAB_LIB_PATH=/usr/local/lib/mecab-ko node index.js
```So, you can select a mecab library for specific language when you use this and you can distribute this as a builtin library for AWS Lambda like that.
## Examples
```
var mecab = require('mecab-ya');var text = '아버지가방에들어가신다';
mecab.pos(text, function (err, result) {
console.log(result);
/*
[ [ '아버지', 'NNG' ],
[ '가', 'JKS' ],
[ '방', 'NNG' ],
[ '에', 'JKB' ],
[ '들어가', 'VV' ],
[ '신다', 'EP+EC' ] ]
*/
});mecab.morphs(text, function (err, result) {
console.log(result);
/*
[ '아버지', '가', '방', '에', '들어가', '신다' ]
*/
});mecab.nouns(text, function (err, result) {
console.log(result);
/*
[ '아버지', '방' ]
*/
});mecab.all(text, function (err, result) {
console.log(result);
/*
[
[
'아버지', 'NNG',
'*', 'F',
'아버지', '*',
'*', '*',
'*'
],
[
'가', 'JKS', '*',
'F', '가', '*',
'*', '*', '*'
],
// ... and so on
]
*/
});
```
Synchronous versions are also available (just add 'Sync' to the function name)
ex) `console.log(mecab.posSync("아버지가방에들어가신다"))`You can find out a simple example on [node-mecab-ya-example](https://github.com/golbin/node-mecab-ya-example)
## TODO
- Make for Chinese.
- Use CJK at the same time.# License
MIT