Skip to main content

Wrapper of `mecab`, which provide interface like `janome`.

Project description

wakame

janomeライクなインターフェイスを提供するmecabのラッパーです.

利用方法

import MeCab
from wakame.tokenizer import Tokenizer
from wakame.analyzer import Analyzer
from wakame.charfilter import *
from wakame.tokenfilter import *

text = '和布ちゃんこんにちは'

# 基本的な使い方
tokenizer = Tokenizer()
tokens = tokenizer.tokenize(text)
for token in tokens:
    print(token)

# 分かち書き
tokens = tokenizer.tokenize(text, wakati=True)
print(tokens)

# 辞書をNEologdにする場合
tokenizer = Tokenizer(use_neologd=True)
tokens = tokenizer.tokenize(text)
for token in tokens:
    print(token)

# filterを利用する場合
char_filters = [RegexReplaceCharFilter('和布', 'wakame')]
token_filters = [POSKeepFilter('名詞'), POSStopFilter(['名詞,接尾'])]
analyzer = Analyzer(tokenizer, char_filters=char_filters, token_filters=token_filters)
tokens = analyzer.analyze(text)
for token in tokens:
    print(token)

# tokenの情報をDataFrameで用いる場合
tokenizer = Tokenizer()
analyzer = Analyzer(tokenizer)
df = analyzer.analyze_with_dataframe(text)
print(df)

インストール

MeCabのインストール(必須)

brew install mecab
brew install mecab-ipadic

mecab-ipadic-NEologdのインストール(任意)

brew install git curl xz
git clone --depth 1 git@github.com:neologd/mecab-ipadic-neologd.git
cd mecab-ipadic-neologd
./bin/install-mecab-ipadic-neologd -n

詳しくはこちらを参照してください

mecab-python3のインストール(必須)

brew install swig
pip install mecab-python3

wakameのインストール(必須)

pip install wakame

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wakame-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

wakame-0.3.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file wakame-0.3.0.tar.gz.

File metadata

  • Download URL: wakame-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for wakame-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0daeb96b3475ea0af188c994ddb18f17eb6243d3bffd28e401d1bad041446592
MD5 8fcdb8f74c9bf772a56c1b6897e5d095
BLAKE2b-256 6fb69ce7a53aa65a77f5df48e24f6dcfae7c0ac8b0ea2eb715ae313e0682c4a4

See more details on using hashes here.

File details

Details for the file wakame-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: wakame-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for wakame-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23bb34bb9614f57df0dfe4afe3a902c3e7773a1b10192c47afefb50d02be9fdf
MD5 fb76698bfccf4f6f1b0185db992a2ec2
BLAKE2b-256 2164747ee43d453c684e412a61cf1f03a2cd23a9bbdc519384637eddc9c921c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page