semvec/pypi-packages huggingface dataset:
okura 0.1.1
Okura makes it easier to manipulate MeCab parsing results.
License: BSD-3-Clause
Requires Python: >=3.6,<4.0
Keywords: mecab,ipadic,unidic,neologd,nlp

=====
Okura
=====

|PyPI version| |Python Versions|

.. |PyPI version| image:: https://badge.fury.io/py/okura.svg
   :target: https://pypi.org/project/okura/

.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/okura.svg
   :target: https://pypi.org/project/okura/


Okura makes it easier to manipulate MeCab parsing results.


Installation
============

.. code:: bash

    $ pip install okura

Usage
=====

Morphological analysis results can be more easily handled as a Word object.

.. code-block:: python

    import okura

    tokenize = okura.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 : 基本形
    #

It is also available as a dict object.

.. code-block:: python

    import okura

    tokenize = okura.tokenizer()
    words = tokenize('楽しかった')
    for word in words:
        print(word.to_dict())

    # {'surface': '楽しかっ', 'pos': ['形容詞', '自立'], 'base': '楽しい', 'c_type': '形容詞・イ段', 'c_form': '連用タ接続'}
    # {'surface': 'た', 'pos': ['助動詞'], 'base': 'た', 'c_type': '特殊・タ', 'c_form': '基本形'}


You can also specify a MeCab dictionary.
The `node-format` is automatically set according to the dictionary, so you don't have to worry about it.

.. code-block:: python

    import okura

    tokenize = okura.tokenizer(dicdir='/path/to/mecab/dic/dir/')
    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()

    # (UniDic Results)
    # surface: 楽しかっ
    # pos    : ['形容詞', '一般']
    # base   : 楽しい
    # c_type : 形容詞
    # c_form : 連用形-促音便
    #
    # surface: た
    # pos    : ['助動詞']
    # base   : た
    # c_type : 助動詞-タ
    # c_form : 終止形-一般
    #

References
==========

* MeCab: https://taku910.github.io/mecab/
* UniDic: https://unidic.ninjal.ac.jp/
* mecab-ipadic-NEologd: https://github.com/neologd/mecab-ipadic-neologd