{ "info": { "author": "kissge", "author_email": "mail@yusuk.eki.do", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Natural Language :: Japanese", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: BSD", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Linguistic" ], "description": "natto-py\n========\n\nWhat is natto-py?\n-----------------\nA package leveraging FFI (foreign function interface), ``natto-py`` combines\nthe Python_ programming language with MeCab_, the part-of-speech and\nmorphological analyzer for the Japanese language. No compiler is necessary, as\nit is **not** a C extension. ``natto-py`` will run on Mac OS, Windows and\n\\*nix.\n\nYou can learn more about `natto-py at GitHub`_.\n\n|license| |travis| |version| |readthedocs|\n\nRequirements\n------------\n``natto-py`` requires the following:\n\n- An existing installation of `MeCab 0.996`_\n- A system dictionary, like `IPA`_, `Juman`_ or `Unidic`_\n- `cffi 0.8.6`_ or greater\n\nThe following Python versions are supported:\n\n- `Python 2.7`_\n- `Python 3.2`_\n- `Python 3.3`_\n- `Python 3.4`_\n- `Python 3.5`_\n- `Python 3.6`_\n\nInstallation\n------------\nInstall ``natto-py`` as you would any other Python package:\n\n.. code-block:: bash\n\n $ pip install natto-py\n\nThis will automatically install the ``cffi`` package, which ``natto-py`` uses\nto bind to the ``mecab`` library.\n\nAutomatic Configuration\n-----------------------\nAs long as the ``mecab`` (and ``mecab-config`` for \\*nix and Mac OS)\nexecutables are on your ``PATH``, ``natto-py`` does not require any explicit\nconfiguration.\n\n- On \\*nix and Mac OS, it queries ``mecab-config`` to discover the path to the ``libmecab.so`` or ``libmecab.dylib``, respectively.\n- On Windows, it queries the Windows Registry to locate the MeCab installation folder.\n- In order to convert character encodings to/from Unicode, ``natto-py`` will examine the charset of the ``mecab`` system dictionary.\n\nExplicit configuration via MECAB_PATH and MECAB_CHARSET\n-------------------------------------------------------\nIf ``natto-py`` for some reason cannot locate the ``mecab`` library,\nor if it cannot determine the correct charset used internally by\n``mecab``, then you will need to set the ``MECAB_PATH`` and ``MECAB_CHARSET``\nenvironment variables.\n\n- Set the ``MECAB_PATH`` environment variable to the exact name/path to your ``mecab`` library.\n- Set the ``MECAB_CHARSET`` environment variable to the ``charset`` character encoding used by your system dictionary.\n\ne.g., for Mac OS:\n\n.. code-block:: bash\n\n export MECAB_PATH=/usr/local/Cellar/mecab/0.996/lib/libmecab.dylib\n export MECAB_CHARSET=utf8\n\ne.g., for bash on UNIX/Linux:\n\n.. code-block:: bash\n\n export MECAB_PATH=/usr/local/lib/libmecab.so\n export MECAB_CHARSET=euc-jp\n\ne.g., on Windows:\n\n.. code-block:: bat\n\n set MECAB_PATH=C:\\Program Files\\MeCab\\bin\\libmecab.dll\n set MECAB_CHARSET=shift-jis\n\ne.g., from within a Python program:\n\n.. code-block:: python\n\n import os\n\n os.environ['MECAB_PATH']='/usr/local/lib/libmecab.so'\n os.environ['MECAB_CHARSET']='utf-16'\n\nUsage\n-----\nHere's a very quick guide to using ``natto-py``.\n\nInstantiate a reference to the ``mecab`` library, and display some details:\n\n.. code-block:: python\n\n from natto import MeCab\n\n nm = MeCab()\n print(nm)\n\n # displays details about the MeCab instance\n ,\n tagger=,\n lattice=,\n libpath=\"/usr/local/lib/libmecab.so\",\n options={},\n dicts=[,\n filepath=\"/usr/local/lib/mecab/dic/ipadic/sys.dic\",\n charset=utf8,\n type=0],\n version=0.996>\n\n----\n\nDisplay details about the ``mecab`` system dictionary used:\n\n.. code-block:: python\n\n sysdic = nm.dicts[0]\n print(sysdic)\n\n # displays the MeCab system dictionary info\n ,\n filepath=\"/usr/local/lib/mecab/dic/ipadic/sys.dic\",\n charset=utf8,\n type=0>\n\n----\n\nParse Japanese text and send the MeCab result as a single string to\n``stdout``:\n\n.. code-block:: python\n\n print(nm.parse('\u30d4\u30f3\u30c1\u306e\u6642\u306b\u306f\u5fc5\u305a\u30d2\u30fc\u30ed\u30fc\u304c\u73fe\u308c\u308b\u3002'))\n\n # MeCab result as a single string\n \u30d4\u30f3\u30c1 \u540d\u8a5e,\u4e00\u822c,*,*,*,*,\u30d4\u30f3\u30c1,\u30d4\u30f3\u30c1,\u30d4\u30f3\u30c1\n \u306e \u52a9\u8a5e,\u9023\u4f53\u5316,*,*,*,*,\u306e,\u30ce,\u30ce\n \u6642 \u540d\u8a5e,\u975e\u81ea\u7acb,\u526f\u8a5e\u53ef\u80fd,*,*,*,\u6642,\u30c8\u30ad,\u30c8\u30ad\n \u306b \u52a9\u8a5e,\u683c\u52a9\u8a5e,\u4e00\u822c,*,*,*,\u306b,\u30cb,\u30cb\n \u306f \u52a9\u8a5e,\u4fc2\u52a9\u8a5e,*,*,*,*,\u306f,\u30cf,\u30ef\n \u5fc5\u305a \u526f\u8a5e,\u52a9\u8a5e\u985e\u63a5\u7d9a,*,*,*,*,\u5fc5\u305a,\u30ab\u30ca\u30e9\u30ba,\u30ab\u30ca\u30e9\u30ba\n \u30d2\u30fc\u30ed\u30fc \u540d\u8a5e,\u4e00\u822c,*,*,*,*,\u30d2\u30fc\u30ed\u30fc,\u30d2\u30fc\u30ed\u30fc,\u30d2\u30fc\u30ed\u30fc\n \u304c \u52a9\u8a5e,\u683c\u52a9\u8a5e,\u4e00\u822c,*,*,*,\u304c,\u30ac,\u30ac\n \u73fe\u308c\u308b \u52d5\u8a5e,\u81ea\u7acb,*,*,\u4e00\u6bb5,\u57fa\u672c\u5f62,\u73fe\u308c\u308b,\u30a2\u30e9\u30ef\u30ec\u30eb,\u30a2\u30e9\u30ef\u30ec\u30eb\n \u3002 \u8a18\u53f7,\u53e5\u70b9,*,*,*,*,\u3002,\u3002,\u3002\n EOS\n\n----\n\nNext, try parsing the text with MeCab node parsing. A generator yielding the\nMeCabNode instances lets you efficiently iterate over the output without first\nmaterializing each and every resulting MeCabNode instance. The MeCabNode\ninstances yielded allow access to more detailed information about each\nmorpheme.\n\nHere we use a `Python with-statement`_ to automatically clean up after we\nfinish node parsing with the MeCab tagger. This is the recommended approach\nfor using ``natto-py`` in a production environment:\n\n.. code-block:: python\n\n # Use a Python with-statement to ensure mecab_destroy is invoked\n #\n with MeCab() as nm:\n for n in nm.parse('\u30d4\u30f3\u30c1\u306e\u6642\u306b\u306f\u5fc5\u305a\u30d2\u30fc\u30ed\u30fc\u304c\u73fe\u308c\u308b\u3002', as_nodes=True):\n ... # ignore any end-of-sentence nodes\n ... if not n.is_eos():\n ... print('{}\\t{}'.format(n.surface, n.cost))\n ...\n \u30d4\u30f3\u30c1 3348\n \u306e 3722\n \u6642 5176\n \u306b 5083\n \u306f 5305\n \u5fc5\u305a 7525\n \u30d2\u30fc\u30ed\u30fc 11363\n \u304c 10508\n \u73fe\u308c\u308b 10841\n \u3002 7127\n\n----\n\nMeCab output formatting is extremely flexible and is highly recommended for\nany serious natural language processing task. Rather than parsing the MeCab\noutput as a single, large string, use MeCab's ``--node-format`` option\n(short form ``-F``) to customize the node's ``feature`` attribute.\n\n- morpheme surface\n- part-of-speech\n- part-of-speech ID\n- pronunciation\n\nIt is good practice when using ``--node-format`` to also specify node \nformatting in the case where the morpheme cannot be found in the dictionary,\nby using ``--unk-format`` (short form ``-U``).\n\nThis example formats the node ``feature`` to capture the items above as a\ncomma-separated value:\n\n.. code-block:: python\n\n # MeCab options used:\n #\n # -F ... short-form of --node-format\n # %m ... morpheme surface\n # %f[0] ... part-of-speech\n # %h ... part-of-speech id (ipadic)\n # %f[8] ... pronunciation\n # \n # -U ... short-form of --unk-format\n # output ?,?,?,? for morphemes not in dictionary\n #\n with MeCab(r'-F%m,%f[0],%h,%f[8]\\n -U?,?,?,?\\n') as nm:\n for n in nm.parse('\u30d4\u30f3\u30c1\u306e\u6642\u306b\u306f\u5fc5\u305a\u30d2\u30fc\u30ed\u30fc\u304c\u73fe\u308c\u308b\u3002', as_nodes=True):\n ... # only normal nodes, ignore any end-of-sentence and unknown nodes\n ... if n.is_nor():\n ... print(n.feature)\n ...\n \u30d4\u30f3\u30c1,\u540d\u8a5e,38,\u30d4\u30f3\u30c1\n \u306e,\u52a9\u8a5e,24,\u30ce\n \u6642,\u540d\u8a5e,66,\u30c8\u30ad\n \u306b,\u52a9\u8a5e,13,\u30cb\n \u306f,\u52a9\u8a5e,16,\u30ef\n \u5fc5\u305a,\u526f\u8a5e,35,\u30ab\u30ca\u30e9\u30ba\n \u30d2\u30fc\u30ed\u30fc,\u540d\u8a5e,38,\u30d2\u30fc\u30ed\u30fc\n \u304c,\u52a9\u8a5e,13,\u30ac\n \u73fe\u308c\u308b,\u52d5\u8a5e,31,\u30a2\u30e9\u30ef\u30ec\u30eb\n \u3002,\u8a18\u53f7,7,\u3002\n\n\n----\n\n`Partial parsing`_ (\u5236\u7d04\u4ed8\u304d\u89e3\u6790), allows you to pass hints to MeCab on\nhow to tokenize morphemes when parsing. Most useful are boundary constraint\nparsing and feature constraint parsing.\n\nWith boundary constraint parsing, you can specify either a compiled ``re``\nregular expression object or a string to tell MeCab where the boundaries of\na morpheme should be. Use the ``boundary_constraints`` keyword. For hints on\ntokenization, please see `Regular expression operations`_ and `re.finditer`_\nin particular.\n\nThis example uses the ``-F`` node-format option to customize the resulting\n``MeCabNode`` feature attribute to extract:\n\n- ``%m`` - morpheme surface\n- ``%f[0]`` - node part-of-speech\n- ``%s`` - node ``stat`` status value, 1 is ``unknown``\n\nNote that any such morphemes captured will have node ``stat`` status of 1 (unknown):\n\n.. code-block:: python\n\n import re\n\n with MeCab(r'-F%m,\\s%f[0],\\s%s\\n') as nm:\n\n text = '\u4ffa\u306f\u52aa\u529b\u3057\u305f\u3088\u3063\uff1f \u304a\u524d\u306e10\u500d\u3001\u3044\u3084100\u500d1000\u500d\u3057\u305f\u3088\u3063\uff01'\n \n # capture 10\u500d, 100\u500d and 1000\u500d as single parts-of-speech\n pattern = re.compile('10+\u500d') \n\n for n in nm.parse(text, boundary_constraints=pattern, as_nodes=True):\n ... print(n.feature)\n ...\n \u4ffa, \u540d\u8a5e, 0\n \u306f, \u52a9\u8a5e, 0\n \u52aa\u529b, \u540d\u8a5e, 0\n \u3057, \u52d5\u8a5e, 0\n \u305f\u3088\u3063, \u52d5\u8a5e, 0\n \uff1f, \u8a18\u53f7, 0\n \u304a\u524d, \u540d\u8a5e, 0\n \u306e, \u52a9\u8a5e, 0\n 10\u500d, \u540d\u8a5e, 1\n \u3001, \u8a18\u53f7, 0\n \u3044\u3084, \u63a5\u7d9a\u8a5e, 0\n 100\u500d, \u540d\u8a5e, 1\n 1000\u500d, \u540d\u8a5e, 1\n \u3057, \u52d5\u8a5e, 0\n \u305f\u3088\u3063, \u52d5\u8a5e, 0\n \uff01, \u8a18\u53f7, 0\n EOS\n\nWith feature constraint parsing, you can provide instructions to MeCab\non what feature to use for a matching morpheme. Use the \n``feature_constraints`` keyword to pass in a ``tuple`` containing elements\nthat themselves are ``tuple`` instances with a specific morpheme (str) \nand a corresponding feature (str), in order of constraint precedence:\n\n.. code-block:: python\n\n with MeCab(r'-F%m,\\s%f[0],\\s%s\\n') as nm:\n\n text = '\u5fc3\u306e\u4e2d\u30673\u56de\u5531\u3048\u3001 \u30d2\u30fc\u30ed\u30fc\u898b\u53c2\uff01\u30d2\u30fc\u30ed\u30fc\u898b\u53c2\uff01\u30d2\u30fc\u30ed\u30fc\u898b\u53c2\uff01'\n features = (('\u30d2\u30fc\u30ed\u30fc\u898b\u53c2', '\u611f\u52d5\u8a5e'),)\n\n for n in nm.parse(text, feature_constraints=features, as_nodes=True):\n ... print(n.feature)\n ...\n \u5fc3, \u540d\u8a5e, 0\n \u306e, \u52a9\u8a5e, 0\n \u4e2d, \u540d\u8a5e, 0\n \u3067, \u52a9\u8a5e, 0\n 3, \u540d\u8a5e, 1\n \u56de, \u540d\u8a5e, 0\n \u5531\u3048, \u52d5\u8a5e, 0\n \u3001, \u8a18\u53f7, 0\n \u30d2\u30fc\u30ed\u30fc\u898b\u53c2, \u611f\u52d5\u8a5e, 1\n \uff01, \u8a18\u53f7, 0\n \u30d2\u30fc\u30ed\u30fc\u898b\u53c2, \u611f\u52d5\u8a5e, 1\n \uff01, \u8a18\u53f7, 0\n \u30d2\u30fc\u30ed\u30fc\u898b\u53c2, \u611f\u52d5\u8a5e, 1\n \uff01, \u8a18\u53f7, 0\n EOS\n\n\n----\n\nLearn More\n----------\n- Examples and more detailed information about ``natto-py`` can be found on the `project Wiki`_.\n- Working code in Jupyter notebook form can be found under this `project's notebooks directory`_.\n- `API documentation on Read the Docs`_.\n\nContributing to natto-py\n------------------------\n- Use git_ and `check out the latest code at GitHub`_ to make sure the\n feature hasn't been implemented or the bug hasn't been fixed yet.\n- `Browse the issue tracker`_ to make sure someone already hasn't requested it\n and/or contributed it.\n- Fork the project.\n- Start a feature/bugfix branch.\n- Commit and push until you are happy with your contribution.\n- Make sure to add tests for it. This is important so I don't break it in a\n future version unintentionally.\n- Please try not to mess with the ``setup.py``, ``CHANGELOG``, or version\n files. If you must have your own version, that is fine, but please isolate\n to its own commit so I can cherry-pick around it.\n- This project uses the following packages for development:\n\n - Sphinx_ for document generation\n - twine_ for secure uploads during release\n - unittest_ for unit tests, as it is very natural and easy-to-use\n - PyYAML_ for data loading during tests\n\nChangelog\n---------\nPlease see the ``CHANGELOG`` for the release history.\n\nCopyright\n---------\nCopyright |copy| 2018, Brooke M. Fujita. All rights reserved. Please see\nthe ``LICENSE`` file for further details.\n\n.. |version| image:: https://badge.fury.io/py/natto-py.svg\n :target: https://pypi.python.org/pypi/natto-py\n.. |travis| image:: https://travis-ci.org/buruzaemon/natto-py.svg?branch=master\n :target: https://travis-ci.org/buruzaemon/natto-py\n.. |license| image:: https://img.shields.io/badge/license-BSD-blue.svg\n :target: _\n.. |readthedocs| image:: https://readthedocs.org/projects/natto-py/badge/?version=master\n :target: http://natto-py.readthedocs.org/en/master/?badge=master\n :alt: Documentation Status\n.. _Python: http://www.python.org/\n.. _MeCab: http://taku910.github.io/mecab/\n.. _IPA: http://taku910.github.io/mecab/#download\n.. _Juman: http://taku910.github.io/mecab/#download\n.. _Unidic: http://taku910.github.io/mecab/#download\n.. _natto-py at GitHub: https://github.com/buruzaemon/natto-py\n.. _MeCab 0.996: http://taku910.github.io/mecab/#download\n.. _cffi 0.8.6: https://bitbucket.org/cffi/cffi\n.. _Python 2.7: https://docs.python.org/dev/whatsnew/2.7.html \n.. _Python 3.2: https://docs.python.org/dev/whatsnew/3.2.html\n.. _Python 3.3: https://docs.python.org/dev/whatsnew/3.3.html\n.. _Python 3.4: https://docs.python.org/dev/whatsnew/3.4.html \n.. _Python 3.5: https://docs.python.org/dev/whatsnew/3.5.html \n.. _Python 3.6: https://docs.python.org/dev/whatsnew/3.6.html \n.. _NLTK3's lead: https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0\n.. _Python with-statement: https://www.python.org/dev/peps/pep-0343/\n.. _Partial parsing: http://taku910.github.io/mecab/partial.html\n.. _Regular expression operations: https://docs.python.org/3/library/re.html\n.. _re.finditer: https://docs.python.org/3/library/re.html#re.finditer\n.. _project Wiki: https://github.com/buruzaemon/natto-py/wiki \n.. _project's notebooks directory: https://github.com/buruzaemon/natto-py/tree/master/notebooks\n.. _API documentation on Read the Docs: http://natto-py.readthedocs.org/en/master/\n.. _git: http://git-scm.com/downloads\n.. _check out the latest code at GitHub: https://github.com/buruzaemon/natto-py\n.. _Browse the issue tracker: https://github.com/buruzaemon/natto-py/issues\n.. _Sphinx: http://sphinx-doc.org/\n.. _twine: https://github.com/pypa/twine\n.. _unittest: http://pythontesting.net/framework/unittest/unittest-introduction/\n.. _PyYAML: https://github.com/yaml/pyyaml \n.. |copy| unicode:: 0xA9 .. copyright sign", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kissge/natto-py", "keywords": "MeCab \u548c\u5e03\u856a \u7d0d\u8c46 Japanese morphological analyzer NLP \u5f62\u614b\u7d20\u89e3\u6790 \u81ea\u7136\u8a00\u8a9e\u51e6\u7406 FFI binding \u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "natto-py-fork", "package_url": "https://pypi.org/project/natto-py-fork/", "platform": "", "project_url": "https://pypi.org/project/natto-py-fork/", "project_urls": { "Homepage": "https://github.com/kissge/natto-py" }, "release_url": "https://pypi.org/project/natto-py-fork/0.9.0/", "requires_dist": null, "requires_python": "", "summary": "A Tasty Python Binding with MeCab(FFI-based, no SWIG or compiler necessary)", "version": "0.9.0" }, "last_serial": 4911044, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "8763f8aea04275ccfc0a9c47ac484085", "sha256": "9f023ad0d5dac3747e4f78b6cf932d08fa44be381d839b9e10ee45b67af44411" }, "downloads": -1, "filename": "natto-py-fork-0.9.0.tar.gz", "has_sig": false, "md5_digest": "8763f8aea04275ccfc0a9c47ac484085", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36871, "upload_time": "2019-03-07T15:10:19", "url": "https://files.pythonhosted.org/packages/24/76/bcaea9ebfc02b3a7614ed8a1769c0b7fd819cfbc5877c9c5955e0cef106e/natto-py-fork-0.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8763f8aea04275ccfc0a9c47ac484085", "sha256": "9f023ad0d5dac3747e4f78b6cf932d08fa44be381d839b9e10ee45b67af44411" }, "downloads": -1, "filename": "natto-py-fork-0.9.0.tar.gz", "has_sig": false, "md5_digest": "8763f8aea04275ccfc0a9c47ac484085", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36871, "upload_time": "2019-03-07T15:10:19", "url": "https://files.pythonhosted.org/packages/24/76/bcaea9ebfc02b3a7614ed8a1769c0b7fd819cfbc5877c9c5955e0cef106e/natto-py-fork-0.9.0.tar.gz" } ] }