npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mecab-ko-ts

v0.1.1

Published

mecab for korean, support typescript

Downloads

31

Readme

mecab-ko-ts

Table of Content

About

KOREAN README.md

mecab-ko-ts is an updated version of mecab-ya.
The TypeScript support and Sync feature have been updated.

Yet another mecab wrapper for nodejs and the main purpose is easy to use.
Mecab is a morphological analyzer for Japanease language.
And you can use this for Korean language with mecab-ko.

Install

$ npm install mecab-ko-ts

Requirements

You need mecab or mecab-ko for Korean language.

If you don't have mecab yet, you can install with the prepared script.

$ node_modules/mecab-ko-ts/bin/install-mecab

For the Korean language.

$ node_modules/mecab-ko-ts/bin/install-mecab ko

Usage

mecab-ko-ts use the mecab library in the node_modules/mecab-ko-ts/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

JavaScript

var mecab = require("mecab-ko-ts");

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
        ]
    */
});

TypeScript

import mecab from "mecab-ko-ts";

const 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
        ]
    */
});

Sync

Synchronous versions are also available (just add 'Sync' to the function name)

/*
    Example
*/
const mecab = require("mecab");

console.log(mecab.posSync("아버지가방에들어가신다"));
/*
        [ [ '아버지', 'NNG' ],
          [ '가', 'JKS' ],
          [ '방', 'NNG' ],
          [ '에', 'JKB' ],
          [ '들어가', 'VV' ],
          [ '신다', 'EP+EC' ] ]
    */

You can find out a simple example on node-mecab-ya-example

License

MIT License