Skip to main content

Converts MeCab parsing results to Python objects.

Project description

YouCab: Converts MeCab Parsing Results to Python Objects

PyPI Version Python Versions License Code style: black Imports: isort

Installation

Install MeCab

MeCab is required for YouCab to work. If it is not already installed, install MeCab first.

Install YouCab

$ pip install youcab

Tokenize Japanese sentence

In this example code, we generate a tokenizer with MeCab's default dictionary and run tokenization. The tokenizer converts text into a list of Word objects.

from youcab import youcab

tokenize = youcab.generate_tokenizer()
words = tokenize("本を読んだ")
for word in words:
    print("surface: " + word.surface)
    print("pos    : " + str(word.pos))
    print("base   : " + word.base)
    print("c_type : " + word.c_type)
    print("c_form : " + word.c_form)
    print("")
surface: 本
pos    : ['名詞', '一般']
base   : 本
c_type : 
c_form : 

surface: を
pos    : ['助詞', '格助詞', '一般']
base   : を
c_type : 
c_form : 

surface: 読ん
pos    : ['動詞', '自立']
base   : 読む
c_type : 五段・マ行
c_form : 連用タ接続

surface: だ
pos    : ['助動詞']
base   : だ
c_type : 特殊・タ
c_form : 基本形

Available for any MeCab dictionary

Dictionaries such as IPAdic, UniDic and neologd are available.

from youcab import youcab

tokenize = youcab.generate_tokenizer(dicdir="/path/to/mecab/dic/dir/")

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

youcab-0.1.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

youcab-0.1.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file youcab-0.1.2.tar.gz.

File metadata

  • Download URL: youcab-0.1.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/4.18.0-193.28.1.el8_2.x86_64

File hashes

Hashes for youcab-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b92de00bde5d2fdde9b418757748e33c3b617d6ba5a6aed7e26096c5ab472e25
MD5 c7fcb20480150dda78d79742e7ff449b
BLAKE2b-256 d9420662dd082bf26081cc39b835f51f39dc3df22c976b8a43f866b0ed70a282

See more details on using hashes here.

File details

Details for the file youcab-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: youcab-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/4.18.0-193.28.1.el8_2.x86_64

File hashes

Hashes for youcab-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 03fec365d7b5912f9b2ad8d1f040f767e2beec8136d99951d0b1537cfbad1c52
MD5 3b0b0d6f4b54f6bb67ddc65663123d4a
BLAKE2b-256 65203704287849bce1e639a8151dbc5e157b6cfc5d806fb5bd543e97a3361b1e

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