A Cython MeCab wrapper for fast, pythonic Japanese tokenization.
Project description
fugashi
Fugashi is a Cython wrapper for MeCab, a Japanese tokenizer and morphological analysis tool. Wheels are provided for Linux, OSX, and Win64, and UniDic is easy to install.
issueを英語で書く必要はありません。
See the blog post for background on why Fugashi exists and some of the design decisions, or see this guide for a basic introduction to Japanese tokenization.
If you are on an unsupported platform (like PowerPC), you'll need to install MeCab first. It's recommended you install from source.
Usage
from fugashi import Tagger
tagger = Tagger('-Owakati')
text = "麩菓子は、麩を主材料とした日本の菓子。"
tagger.parse(text)
# => '麩 菓子 は 、 麩 を 主材 料 と し た 日本 の 菓子 。'
for word in tagger(text):
print(word, word.feature.lemma, word.pos, sep='\t')
# "feature" is the Unidic feature data as a named tuple
Installing a Dictionary
Fugashi requires a dictionary. UniDic is recommended, and two easy-to-install versions are provided.
- unidic-lite, a 2013 version of Unidic that's relatively small
- unidic, the latest UniDic 2.3.0, which is 1GB on disk and requires a separate download step
If you just want to make sure things work you can start with unidic-lite
, but
for more serious processing unidic
is recommended. For production use you'll
generally want to generate your own dictionary too; for details see the MeCab
documentation.
To get either of these dictionaries, you can install them directly using pip
or do the below:
pip install fugashi[unidic-lite]
# The full version of UniDic requires a separate download step
pip install fugashi[unidic]
python -m unidic download
Dictionary Use
Fugashi is written with the assumption you'll use Unidic to process Japanese, but it supports arbitrary dictionaries.
If you're using a dictionary besides Unidic you can use the GenericTagger like this:
from fugashi import GenericTagger
tagger = GenericTagger()
# parse can be used as normal
tagger.parse('something')
# features from the dictionary can be accessed by field numbers
for word in tagger(text):
print(word.surface, word.feature[0])
You can also create a dictionary wrapper to get feature information as a named tuple.
from fugashi import GenericTagger, create_feature_wrapper
CustomFeatures = create_feature_wrapper('CustomFeatures', 'alpha beta gamma')
tagger = GenericTagger(wrapper=CustomFeatures)
for word in tagger.parseToNodeList(text):
print(word.surface, word.feature.alpha)
Alternatives
If you have a problem with Fugashi feel free to open an issue. However, there are some cases where it might be better to use a different library.
- If you don't want to deal with installing MeCab at all, try SudachiPy.
- If you need to work with Korean, try KoNLPy.
License and Copyright Notice
Fugashi is released under the terms of the MIT license. Please copy it far and wide.
Fugashi is a wrapper for MeCab, and Fugashi wheels include MeCab binaries.
MeCab is copyrighted free software by Taku Kudo <taku@chasen.org>
and Nippon
Telegraph and Telephone Corporation, and is redistributed under the BSD
License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for fugashi-1.0.5a6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b8a97635102b457aeeeaaf9f65b0442cdebc0e30ee3e665b18c4bf7ed02732a |
|
MD5 | 177005d7b32774fa6ee6279229bebea3 |
|
BLAKE2b-256 | e803205c8016863b4bf1eb62ec342ca27725dabc57e6ede59577f3faeb44dcdc |
Hashes for fugashi-1.0.5a6-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65ebaded38999e19db32fe1aac5289890515a24d330714c79e502e4f66badc7 |
|
MD5 | 73c69ec845a0a55b4eedcdc59c1a4e79 |
|
BLAKE2b-256 | dbe45c65dd77b8cb462d47cefe0d0d18e3e6b5caf05e8982b30b6b7c091f1b27 |
Hashes for fugashi-1.0.5a6-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2f35e4ac39a9d92206fe360701fc46bb3e3c3a6bcf094b3e7c37e40c9b687ab |
|
MD5 | ef4569ccc9a5b2ba2d2d851481ac4a66 |
|
BLAKE2b-256 | 0877409a2ea62fbdf52d00c808b8673ae16304760841acf2338216f033617fa3 |
Hashes for fugashi-1.0.5a6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75433ddb0173122bbf2649233c11d5c9e4075773d7b742bc06d37d31cb4d5685 |
|
MD5 | a608553cba727cbf8a87f6eb132f14c9 |
|
BLAKE2b-256 | 32ee55ddff1c6e67bed913041b69ebdde8bffb29bf9b287f5a377875dedfc5b0 |
Hashes for fugashi-1.0.5a6-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fa69a2dbf95ee724f03550ae518a9c356981b0471b4bad3950bc940d017eaf4 |
|
MD5 | 37a03b949899bd2d6f11f23cb249b34f |
|
BLAKE2b-256 | c887e95f7612ae0f8dd769372702f379202e98a0a7a06f86c982efba928d2e57 |
Hashes for fugashi-1.0.5a6-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e91443908553fbdb229c103880deb8941d156069c1c8fba148b9482b662d277 |
|
MD5 | e65d74ad33b1732949f0235cc1888bcc |
|
BLAKE2b-256 | c147765d5ba76ed581077e6a4b7d098cd8c8c194c91c701c0658f24f57781748 |
Hashes for fugashi-1.0.5a6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4c92acd0897695914c30cd26d557baf59328125d2c0eb66d039f6847fc32f24 |
|
MD5 | 95b677a26cf979279f3c4492acd060db |
|
BLAKE2b-256 | 211d1ae196860df8f4a4015c9cb55d0e9a266a3256cc7cf4f002b17e69b4d92e |
Hashes for fugashi-1.0.5a6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e52c36b9d5656555809d9103b99369437f4166440c199519138cb650175ad2ea |
|
MD5 | 4d63e3685476a97953085ffcee558094 |
|
BLAKE2b-256 | e8fde74e6f8e6fd06f81932665a282732fe45060975594e506be09a55794ca00 |
Hashes for fugashi-1.0.5a6-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 868355fcacbda394a2417087b901d31fadefe61688b91938967d6f28a3273b5e |
|
MD5 | 760b20d2677ba44a827a94d719601ddb |
|
BLAKE2b-256 | fe2e0c3de9d3b18e8d3f25b049f14f5e976257f72d1cb0911590b7d321d0c488 |
Hashes for fugashi-1.0.5a6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f0e6aceb6cbdb6d7b8a5d36255f2c4d4e298dec474c2904928678d0733ea1f |
|
MD5 | 22eec469a7b352dcee1bc2383046a848 |
|
BLAKE2b-256 | 73cb2efadb36006d30780df355b2843e9ae834dbcebe281ebe508f2c879cf8f3 |
Hashes for fugashi-1.0.5a6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f54a52f0596456f10e305622086b03c6be2054a7d6476b9fddc6faa47014432 |
|
MD5 | f83b4065de8a984bfc31613d87ca7ccb |
|
BLAKE2b-256 | 513f078b60ce120412f71e8b77f9730547585772e0b18e4cdf1b8c2cdf1f943f |
Hashes for fugashi-1.0.5a6-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 365344a47822eacc24b352bd3136c96d3bdd8dd812bb2783ea9ab9743cd3c90c |
|
MD5 | c9e5a6456e463c928d1275949edd03c8 |
|
BLAKE2b-256 | c708806760325be05f206a7b124a298a84b26f6238a1fd2532e10f519be94cc3 |
Hashes for fugashi-1.0.5a6-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b8d8e707c69dfec1a8926b0b0acd97b471d21fa23826948036bcefff9ebc8e1 |
|
MD5 | 4f31fdbebde83859cb842d4ad1290e8e |
|
BLAKE2b-256 | c803deda8695bc37b7acb49a71f164acd4551ef7c35ca88856c53755385a1871 |
Hashes for fugashi-1.0.5a6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dba86c4c85ac5d1875e8995214d5b7d0bb34d9afef63a4665e8167e92cc6abf2 |
|
MD5 | 00daa7523cd8758c19c6144f2e20643c |
|
BLAKE2b-256 | de75f798dd0ee121f12f57a68341a88f5f729f81c8d3f422db6029cb98eb9c39 |
Hashes for fugashi-1.0.5a6-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac92f281a2ea481fb76a7beca9810ab37a3bf8db03572e9b7c29bcadfe119c81 |
|
MD5 | 203d507e06d2ad70ad77394d9e96730e |
|
BLAKE2b-256 | 602069144d1eab86d2b54562b500d4a0fa709ac97caf73508a840390ca4d071f |