A morphological analyzer using mecab dictionary.
Project description
pyawabi
pyawabi
is a python warapper for awabi(https://github.com/nakagami/awabi).
Requirements
- python3.6+
- Rust https://www.rust-lang.org/learn/get-started
- python3-dev packages https://github.com/PyO3/pyo3#usage
- MeCab dictionary https://github.com/nakagami/awabi#requirements-and-how-to-install
Install
$ pip install pyawabi
How to use
pyawabi command
$ echo 'すもももももももものうち' | pyawabi
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS
$ echo 'すもももももももものうち' | pyawabi -N 2
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS
use as package
use function
>>> import pyawabi
>>> import pprint
>>> pp = pprint.PrettyPrinter()
>>> pp.pprint(pyawabi.tokenize("すもももももももものうち"))
[('すもも', '名詞,一般,*,*,*,*,すもも,スモモ,スモモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('の', '助詞,連体化,*,*,*,*,の,ノ,ノ'),
('うち', '名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ')]
>>> pp.pprint(pyawabi.tokenize_n_best("すもももももももものうち", 2))
[[('すもも', '名詞,一般,*,*,*,*,すもも,スモモ,スモモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('の', '助詞,連体化,*,*,*,*,の,ノ,ノ'),
('うち', '名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ')],
[('すもも', '名詞,一般,*,*,*,*,すもも,スモモ,スモモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('の', '助詞,連体化,*,*,*,*,の,ノ,ノ'),
('うち', '名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ')]]
>>>
use tokenizer object
>>> tok = pyawabi.Tokenizer()
>>> pp.pprint(tok.tokenize("すもももももももものうち"))
[('すもも', '名詞,一般,*,*,*,*,すもも,スモモ,スモモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('も', '助詞,係助詞,*,*,*,*,も,モ,モ'),
('もも', '名詞,一般,*,*,*,*,もも,モモ,モモ'),
('の', '助詞,連体化,*,*,*,*,の,ノ,ノ'),
('うち', '名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ')]
>>>
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
pyawabi-0.2.6.tar.gz
(5.0 kB
view details)
File details
Details for the file pyawabi-0.2.6.tar.gz
.
File metadata
- Download URL: pyawabi-0.2.6.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14250a66484bc7419452b7f707c0a61d7c55d8adafea0601b90e6b40c1d69432 |
|
MD5 | 902664b9130ccf04f0fe6adaf5cbb482 |
|
BLAKE2b-256 | 60a04c0157bb2bdacbefc95dc2a078c1dfa543187e7adb192610aa67e0b72e17 |