Giter Site home page Giter Site logo

raku-mecab's Introduction

Actions Status

NAME

MeCab - A Raku bindings for libmecab ( http://taku910.github.io/mecab/ )

SYNOPSIS

EXAMPLE 1

use MeCab;
use MeCab::Tagger;

my Str $text = "すもももももももものうち。";
my $mecab-tagger = MeCab::Tagger.new('-C');
loop ( my MeCab::Node $node = $mecab-tagger.parse-tonode($text); $node; $node = $node.next ) {
       say ($node.surface, $node.feature).join("\t");
}

# OUTPUT«
#         BOS/EOS,*,*,*,*,*,*,*,*
# すもも  名詞,一般,*,*,*,*,すもも,スモモ,スモモ
# も      助詞,係助詞,*,*,*,*,も,モ,モ
# もも    名詞,一般,*,*,*,*,もも,モモ,モモ
# も      助詞,係助詞,*,*,*,*,も,モ,モ
# もも    名詞,一般,*,*,*,*,もも,モモ,モモ
# の      助詞,連体化,*,*,*,*,の,ノ,ノ
# うち    名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
# 。      記号,句点,*,*,*,*,。,。,。
#         BOS/EOS,*,*,*,*,*,*,*,*
# »

EXAMPLE 2

use MeCab;
use MeCab::Lattice;
use MeCab::Tagger;
use MeCab::Model;

my MeCab::Model $model .= new;
my MeCab::Tagger $tagger = $model.create-tagger;
my MeCab::Lattice $lattice = $model.create-lattice;
$lattice.add-request-type(MECAB_NBEST);
$lattice.sentence("今日も");

if $tagger.parse($lattice) {
   say $lattice.nbest-tostr(2);
}

# OUTPUT«
# 今日    名詞,副詞可能,*,*,*,*,今日,キョウ,キョー
# も      助詞,係助詞,*,*,*,*,も,モ,モ
# EOS
# 今日    名詞,副詞可能,*,*,*,*,今日,コンニチ,コンニチ
# も      助詞,係助詞,*,*,*,*,も,モ,モ
# EOS
# »

DESCRIPTION

MeCab is a Raku bindings for libmecab ( http://taku910.github.io/mecab/ ).

NOTICE

COMPATIBILITY

MeCab currently doesn't support Windows. It supports Linux/Unix or Mac OS X.

BUILDING MeCab

MeCab depends on the following:

  • wget

  • mecab-0.996

  • mecab-ipadic-2.7.0-20070801

Once the build starts, it automatically downloads mecab-0.996 and mecab-ipadic-2.7.0-20070801 with wget and installs these stuffs under the $HOME/.p6mecab directory, where $HOME is your home directory.

Use 3rd-party dictionary

mecab-ipadic-neologd

  • Step1: download and install neologd

Example:

$ git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git
$ cd mecab-ipadic-neologd
$ export PATH=$HOME/.p6mecab/bin:$PATH
$ ./bin/install-mecab-ipadic-neologd -p $HOME/.p6mecab/lib/mecab/dic/ipadic-neologd
  • Step2: Use .new(:dicdir(PATH_TO_THE_DIR))

Example:

use MeCab;
use MeCab::Tagger;

my Str $text = "トランプ大統領 ワシントンで大規模軍事パレードを指示";
my $mecab-tagger = MeCab::Tagger.new(:dicdir("$*HOME/.p6mecab/lib/mecab/dic/ipadic-neologd"));
loop ( my MeCab::Node $node = $mecab-tagger.parse-tonode($text); $node; $node = $node.next ) {
       say ($node.surface, $node.feature).join("\t");
}

# OUTPUT«
#         BOS/EOS,*,*,*,*,*,*,*,*
# トランプ大統領  名詞,固有名詞,人名,一般,*,*,ドナルド・トランプ,トランプダイトウリョウ,トランプダイトウリョー
# ワシントン      名詞,固有名詞,地域,一般,*,*,ワシントン,ワシントン,ワシントン
# で      助詞,格助詞,一般,*,*,*,で,デ,デ
# 大規模  名詞,一般,*,*,*,*,大規模,ダイキボ,ダイキボ
# 軍事パレード    名詞,固有名詞,一般,*,*,*,軍事パレード,グンジパレード,グンジパレード
# を      助詞,格助詞,一般,*,*,*,を,ヲ,ヲ
# 指示    名詞,サ変接続,*,*,*,*,指示,シジ,シジ
#         BOS/EOS,*,*,*,*,*,*,*,*
# »

AUTHOR

titsuki [email protected]

COPYRIGHT AND LICENSE

Copyright 2016 titsuki

libmecab ( http://taku910.github.io/mecab/ ) by Taku Kudo is licensed under the GPL, LGPL or BSD Licenses.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

raku-mecab's People

Contributors

samcv avatar titsuki avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

samcv

raku-mecab's Issues

Migrate to github actions

The CI environment for this repository is unavailable now.
But I won't change Free plan to the other plan since travis-ci requires too high charge for me :)

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.