Giter Club home page Giter Club logo

node-mecab's Introduction

node-mecab

MeCab wrapper for Node.js

Requirements

Install

npm i @enjoyjs/node-mecab

API

analyze(text: string, options?: MecabOptions): Promise<string>

import { analyze } from "@enjoyjs/node-mecab";

const result = await analyze("こんにちは世界");
console.log(result);
こんにちは      感動詞,*,*,*,*,*,こんにちは,コンニチハ,コンニチワ
世界    名詞,一般,*,*,*,*,世界,セカイ,セカイ
EOS

analyzeSync(text: string, options?: MecabOptions): string

import { analyzeSync } from "@enjoyjs/node-mecab";

const result = analyzeSync("こんにちは世界");
console.log(result);

tokenize(text: string, options?: MecabOptions): Promise<Token[]>

import { tokenize } from "@enjoyjs/node-mecab";

const result = await tokenize("こんにちは世界");
console.log(result);
[
  # 省略
  {
    id: 12,
    surface: 'こんにちは',
    feature: {
      pos: '感動詞',
      posSubs: [ undefined, undefined, undefined ],
      conjugatedType: undefined,
      conjugatedForm: undefined,
      basicForm: 'こんにちは',
      reading: 'コンニチハ',
      pronunciation: 'コンニチワ'
    },
    startPosition: 0,
    endPosition: 15,
    rcAttr: 3,
    lcAttr: 3,
    posid: 2,
    charType: 6,
    stat: 'NORMAL',
    isbest: true,
    alpha: 0,
    beta: 0,
    prob: 0,
    cost: 4033,
    _: []
  },
  {
    id: 30,
    surface: '世界',
    feature: {
      pos: '名詞',
      posSubs: [ '一般', undefined, undefined ],
      conjugatedType: undefined,
      conjugatedForm: undefined,
      basicForm: '世界',
      reading: 'セカイ',
      pronunciation: 'セカイ'
    },
    startPosition: 15,
    endPosition: 21,
    rcAttr: 1285,
    lcAttr: 1285,
    posid: 38,
    charType: 2,
    stat: 'NORMAL',
    isbest: true,
    alpha: 0,
    beta: 0,
    prob: 0,
    cost: 10546,
    _: []
  },
  # 省略
]

tokenizeSync(text: string, options?: MecabOptions): Token[]

import { tokenizeSync } from "@enjoyjs/node-mecab";

const result = tokenizeSync("こんにちは世界");
console.log(result);

wakati(text: string, options?: MecabOptions): Promise<string[][]>

import { wakati } from "@enjoyjs/node-mecab";

const result = await wakati("こんにちは世界");
console.log(result);
[ [ 'こんにちは', '世界' ] ]

wakatiSync(text: string, options?: MecabOptions): string[][]

import { wakatiSync } from "@enjoyjs/node-mecab";

const result = wakatiSync("こんにちは世界");
console.log(result);

Contribution

Issue、Pull requestは日本語で構いません。 不具合等ありましたらPull requestを投げていただけると幸いです。

License

MIT License

node-mecab's People

Contributors

renovate-bot avatar renovate[bot] avatar yuseisui avatar laquinh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.