A Cython wrapper for MeCab
Project description
fugashi
Fugashi is a Cython wrapper for MeCab.
See the blog post for background on why Fugashi exists and some of the design decisions.
Any reasonable version of MeCab should work, but it's recommended you install from source.
Usage
from fugashi import Tagger
tagger = Tagger('-Owakati')
text = "麩菓子(ふがし)は、麩を主材料とした日本の菓子。"
tagger.parse(text)
# => '麩 菓子 ( ふ が し ) は 、 麩 を 主材 料 と し た 日本 の 菓子 。'
for word in tagger.parseToNodeList(text):
print(word, word.feature.lemma, word.pos, sep='\t')
# "feature" is the Unidic feature data as a named tuple
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.parseToNodeList(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 want to use MeCab but don't have a C compiler, use natto-py.
- If you don't want to deal with installing MeCab at all, try SudachiPy.
Note that these are both slower than Fugashi according to a benchmark I wrote.
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-0.1.12rc3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39e5477ba89a5f590c386362ec0a89c4eb30aa42c4373334a8ab37724102b170 |
|
MD5 | b68174d0ba7c5f82dfa0e2e169bc59a3 |
|
BLAKE2b-256 | 44e1671b41ad1385ccb3f8805e389bd227781fa93100c920e982a0005afeea39 |
Hashes for fugashi-0.1.12rc3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c60d5e0f57226850d8e8b701759a8c65e573ff059b78dea6451af6ecf52256c8 |
|
MD5 | e8836cd90ebdc549da73f5bf3d800748 |
|
BLAKE2b-256 | 511ec6635ea79a10824428111e3240ef5da108704f854b7c15bc93fd83677761 |
Hashes for fugashi-0.1.12rc3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcfb7d235d424b2ceff6d51335481a9cfcf248e9f99621207a7e3c3df40fe3d5 |
|
MD5 | 58bcdeb943c01bb7742479d1122483df |
|
BLAKE2b-256 | f0b70de0364ecaceffcbe1341b5db8fbe99da9e9a4e2ff49fc91da396dc346d9 |
Hashes for fugashi-0.1.12rc3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 371c2f6ac4e984ac1219a0b8e342c7d81a6732edf59a2ce6abfeaf0da4c176b8 |
|
MD5 | 958ee4594cf666fb3fd5c859e67a161b |
|
BLAKE2b-256 | c9ef0f55d3bdda22db04324c5456a52a04b84c08efeb29fd1035afd79740754b |
Hashes for fugashi-0.1.12rc3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 434416ea42b1256c79edbacfdac3c75f84df575dfe3affa899517f0b5e719fa2 |
|
MD5 | 90b333d32298d99f9410ceeb7edc13df |
|
BLAKE2b-256 | ce4d786912dee1d023670d91142817da74256d5d30200780474585a953f4f869 |
Hashes for fugashi-0.1.12rc3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 703bd8e3ba6df217bc6b7201685ba96d1bca35f023d346635644be8511070efb |
|
MD5 | bcd02a13531b2e25d22ddba965635ec4 |
|
BLAKE2b-256 | 18cec45926a6ea0dce75a1fcc37d118ea7eea5f1b9aa33c474762db0bbdf06f9 |
Hashes for fugashi-0.1.12rc3-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88280dbe64021f7955bafb33d6b2950c1ef0a119540c9e2a2c0741fdd3cac849 |
|
MD5 | bdd3e4a2fb0b9c3f7f7134c041c60d86 |
|
BLAKE2b-256 | 7aeaece09ed9f052f28f55ace443900f89d4cee6ae3fdcd3f16cee2ee8c0cabb |
Hashes for fugashi-0.1.12rc3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe2b846069a3bc7bfb64cc5adcb4fe8a4b81c47dc7cb1af6637828efc7dc57b2 |
|
MD5 | 93ea21257a055ca9bc8fce0796d97925 |
|
BLAKE2b-256 | fe58de8ed6035c8cc92348c6db960c2f4cc72f7102d2dbd199e069a08e05f419 |