{"id":17152348,"url":"https://github.com/jeongukjae/mecab-bind","last_synced_at":"2025-04-13T12:43:01.420Z","repository":{"id":50747378,"uuid":"367412998","full_name":"jeongukjae/mecab-bind","owner":"jeongukjae","description":"Binding MeCab Tagger to Python3 and TensorFlow","archived":false,"fork":false,"pushed_at":"2021-05-25T14:26:40.000Z","size":2490,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T03:41:42.472Z","etag":null,"topics":["python-binding","tensorflow-binding"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeongukjae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-14T15:58:00.000Z","updated_at":"2022-08-01T08:46:23.000Z","dependencies_parsed_at":"2022-09-24T19:04:37.863Z","dependency_job_id":null,"html_url":"https://github.com/jeongukjae/mecab-bind","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeongukjae%2Fmecab-bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeongukjae%2Fmecab-bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeongukjae%2Fmecab-bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeongukjae%2Fmecab-bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeongukjae","download_url":"https://codeload.github.com/jeongukjae/mecab-bind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717226,"owners_count":21150387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python-binding","tensorflow-binding"],"created_at":"2024-10-14T21:43:27.722Z","updated_at":"2025-04-13T12:43:01.395Z","avatar_url":"https://github.com/jeongukjae.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mecab-bind\n\n* [mecab-bind](https://pypi.org/project/mecab-bind/): ![PyPI](https://img.shields.io/pypi/v/mecab-bind) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mecab-bind)\n* [mecab-tf](https://pypi.org/project/mecab-tf/): ![PyPI](https://img.shields.io/pypi/v/mecab-tf) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mecab-tf)\n\n[![Build and test binding modules](https://github.com/jeongukjae/mecab-bind/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/jeongukjae/mecab-bind/actions/workflows/build-and-test.yml)\n\nBinding MeCab Tagger to python and tensorflow\n\n## Installation\n\n* Python binding: `pip install mecab-bind`\n* TensorFlow binding: `pip install mecab-tf`\n\n### Compatible TensorFlow version\n\n|mecab-tf|tensorflow version|python version|\n|---|---|---|\n|2.4.0|2.4.x|3.6, 3.7, 3.8|\n|2.5.0|2.5.x|3.6, 3.7, 3.8, 3.9|\n\n## Usage\n\n### Python Binding\n\n```python\n\u003e\u003e\u003e import mecab\n\u003e\u003e\u003e tagger = mecab.Tagger(mecab.get_model_args(\"./test-data/dic\")) # pass dictionary path instead of \"./test-data/dic\"\n\u003e\u003e\u003e dic_infos = tagger.get_dictionary_info()\n\u003e\u003e\u003e tagger.get_dictionary_info()\n[\u003cDictionaryInfo filename=./test-data/dic/sys.dic, charset=UTF-8, size=4335, type=0, lsize=346, rsize=346, version=102\u003e]\n\u003e\u003e\u003e tagger.parse_node_with_lattice(\"シリーズ中、カンフーシーンが一番多い。\")\n[\n    \u003cNode surface=\"\", feature=\"BOS/EOS,*,*,*,*,*,*,*,*\"\u003e,\n    \u003cNode surface=\"シリーズ\", feature=\"名詞,一般,*,*,*,*,*\"\u003e,\n    \u003cNode surface=\"中\", feature=\"接頭詞,数接続,*,*,*,*,中,ナカ,ナカ\"\u003e,\n    \u003cNode surface=\"、\", feature=\"記号,読点,*,*,*,*,、,、,、\"\u003e,\n    \u003cNode surface=\"カンフーシーン\", feature=\"名詞,一般,*,*,*,*,*\"\u003e,\n    \u003cNode surface=\"が\", feature=\"助詞,格助詞,一般,*,*,*,が,ガ,ガ\"\u003e,\n    \u003cNode surface=\"一番\", feature=\"名詞,副詞可能,*,*,*,*,一番,イチバン,イチバン\"\u003e,\n    \u003cNode surface=\"多い\", feature=\"形容詞,自立,*,*,形容詞・アウオ段,基本形,多い,オオイ,オーイ\"\u003e,\n    \u003cNode surface=\"。\", feature=\"記号,句点,*,*,*,*,。,。,。\"\u003e,\n    \u003cNode surface=\"\", feature=\"BOS/EOS,*,*,*,*,*,*,*,*\"\u003e\n]\n\u003e\u003e\u003e tagger.parse_nbest_with_lattice(\"シリーズ中、カンフーシーンが一番多い。\", 10)\n[\n    [\n        \u003cNode surface=\"\", feature=\"BOS/EOS,*,*,*,*,*,*,*,*\"\u003e,\n        \u003cNode surface=\"シリーズ\", feature=\"名詞,一般,*,*,*,*,*\"\u003e,\n        \u003cNode surface=\"中\", feature=\"接頭詞,数接続,*,*,*,*,中,ナカ,ナカ\"\u003e,\n        ...\n    ],\n    [\n        \u003cNode surface=\"\", feature=\"BOS/EOS,*,*,*,*,*,*,*,*\"\u003e,\n        \u003cNode surface=\"シリーズ\", feature=\"名詞,一般,*,*,*,*,*\"\u003e,\n        \u003cNode surface=\"中\", feature=\"接頭詞,数接続,*,*,*,*,中,ナカ,ナカ\"\u003e,\n        \u003cNode surface=\"、\", feature=\"記号,読点,*,*,*,*,、,、,、\"\u003e,\n        ...\n    ],\n    ...\n]\n\u003e\u003e\u003e print(tagger.parse(\"シリーズ中、カンフーシーンが一番多い。\"))\nシリーズ        名詞,一般,*,*,*,*,*\n中      接頭詞,数接続,*,*,*,*,中,ナカ,ナカ\n、      記号,読点,*,*,*,*,、,、,、\nカンフーシーン  名詞,一般,*,*,*,*,*\nが      助詞,格助詞,一般,*,*,*,が,ガ,ガ\n一番    名詞,副詞可能,*,*,*,*,一番,イチバン,イチバン\n多い    形容詞,自立,*,*,形容詞・アウオ段,基本形,多い,オオイ,オーイ\n。      記号,句点,*,*,*,*,。,。,。\nEOS\n\n```\n\nBound commands\n\n* `mecab-dict-index`\n* `mecab-dict-gen`\n* `mecab-system-eval`\n* `mecab-cost-train`\n* `mecab-test-gen`\n* `mecab`\n\n### TensorFlow Binding\n\n```python\n\u003e\u003e\u003e import tensorflow as tf\n\u003e\u003e\u003e from mecab_tf.python.ops.mecab_ops import MecabTagger\n\u003e\u003e\u003e tagger = MecabTagger(\"./test-data/dic\")\n2021-05-20 05:35:48.759933: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\nTo enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n\u003e\u003e\u003e surfaces, features = tagger.tag([\"シリーズ中、カンフーシーンが一番多い。\", \"※撮影中に、ジェット・リーが失踪。\"])\n\u003e\u003e\u003e surfaces.shape\nTensorShape([2, None])\n\u003e\u003e\u003e features.shape\nTensorShape([2, None])\n\u003e\u003e\u003e for surface, feature in zip(surfaces[0], features[0]):  # print first sentence\n...     print(surface.numpy().decode('utf8'), feature.numpy().decode('utf8'))\n...\n BOS/EOS,*,*,*,*,*,*,*,*\nシリーズ 名詞,一般,*,*,*,*,*\n中 接頭詞,数接続,*,*,*,*,中,ナカ,ナカ\n、 記号,読点,*,*,*,*,、,、,、\nカンフーシーン 名詞,一般,*,*,*,*,*\nが 助詞,格助詞,一般,*,*,*,が,ガ,ガ\n一番 名詞,副詞可能,*,*,*,*,一番,イチバン,イチバン\n多い 形容詞,自立,*,*,形容詞・アウオ段,基本形,多い,オオイ,オーイ\n。 記号,句点,*,*,*,*,。,。,。\n BOS/EOS,*,*,*,*,*,*,*,*\n\u003e\u003e\u003e # you can pass any shape of string tensor\n\u003e\u003e\u003e _ = tagger.tag(\"シリーズ中、カンフーシーンが一番多い。\")\n\u003e\u003e\u003e _ = tagger.tag([[\"シリーズ中、カンフーシーンが一番多い。\", \"※撮影中に、ジェット・リーが失踪。\"]])\n```\n\nNote: If you use this Module in SavedModel format, it is recommended to use model_path as absolute path.\n      The `model_path` is serialized, not the dictionary data.\n\n## Prebuilt dictionaries\n\n* [prebuilt mecab-ko-dic (korean)](https://github.com/jeongukjae/mecab-ko-dic-prebuilt) and [example notebook](https://github.com/jeongukjae/mecab-ko-dic-prebuilt/blob/main/example-of-mecab-ko-dic-prebuilt--and-mecab-tf.ipynb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeongukjae%2Fmecab-bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeongukjae%2Fmecab-bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeongukjae%2Fmecab-bind/lists"}