{"id":16837836,"url":"https://github.com/hankcs/iparser","last_synced_at":"2025-04-11T05:14:13.572Z","repository":{"id":62571487,"uuid":"123822988","full_name":"hankcs/iparser","owner":"hankcs","description":"Yet another dependency parser, integrated with tokenizer, tagger and visualization tool. ","archived":false,"fork":false,"pushed_at":"2018-03-18T15:42:32.000Z","size":71,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T05:14:07.789Z","etag":null,"topics":["dependency-parser","natural-language-processing","part-of-speech-tagger","visualization","word-segmentation"],"latest_commit_sha":null,"homepage":"http://iparser.hankcs.com/","language":"Python","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/hankcs.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":"2018-03-04T19:50:01.000Z","updated_at":"2024-08-01T02:18:16.000Z","dependencies_parsed_at":"2022-11-03T18:26:28.123Z","dependency_job_id":null,"html_url":"https://github.com/hankcs/iparser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankcs%2Fiparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankcs%2Fiparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankcs%2Fiparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankcs%2Fiparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hankcs","download_url":"https://codeload.github.com/hankcs/iparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345268,"owners_count":21088245,"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":["dependency-parser","natural-language-processing","part-of-speech-tagger","visualization","word-segmentation"],"created_at":"2024-10-13T12:19:01.650Z","updated_at":"2025-04-11T05:14:13.553Z","avatar_url":"https://github.com/hankcs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IParser: Industrial Strength Dependency Parser\n\nYet another multilingual dependency parser, integrated with tokenizer, part-of-speech tagger and visualization tool. IParser can parse raw sentence to dependency tree in CoNLL format, and is able to visualize trees in your browser. \n\n[See live demo!](http://iparser.hankcs.com/)\n\nCurrently, iparser is in a prototype state. It makes no warranty and may not be ready for practical usage.\n\n## Install\n\n```\npip3 install iparser --process-dependency-links\n```\n\n## Quick Start\n\n### CLI\n\n#### Interactive Shell\n\nYou can play with IParser in an interactive mode:\n\n```\n$ iparser parse\nI looove iparser!\n1\tI\t_\t_\tPRP\t_\t2\tnsubj\t_\t_\n2\tlooove\t_\t_\tVBP\t_\t0\troot\t_\t_\n3\tiparser\t_\t_\tNN\t_\t2\tdobj\t_\t_\n4\t!\t_\t_\t.\t_\t2\tpunct\t_\t_\n```\nYou type a sentence, hit enter, IParser will output its dependency tree.\n\n- Use `iparser segment` or `iparser tag` for word segmentation or part-of-speech tagging\n- Some models may take a while to load\n- IParser is language-agnostic, pre-trained models are provided for both English and Chinese, shipped in the installation package. The default model is PTB (English), you can switch to CTB (Chinese) via appending `--language cn`\n- Append `--help` to see the detailed manual\n\n#### Pipeline\n\n```\n$ iparser segment \u003c\u003c\u003c '商品和服务'        \n商品 和 服务\n\n$ iparser tag \u003c\u003c\u003c 'I looove iparser!'   \nI/PRP looove/VBP iparser/NN !/.\n\n$ iparser parse \u003c\u003c\u003c 'I looove iparser!' \n1\tI\t_\t_\tPRP\t_\t2\tnsubj\t_\t_\n2\tlooove\t_\t_\tVBP\t_\t0\troot\t_\t_\n3\tiparser\t_\t_\tNN\t_\t2\tdobj\t_\t_\n4\t!\t_\t_\t.\t_\t2\tpunct\t_\t_\n```\n\n- `iparser` is a compatible pipeline for standard I/O redirection. You can use `iparser` directly in terminal without writing codes.\n\n### API\n\n#### IParser\n\nThe all-in-one interface is provided by class `IParser`:\n\n```\n$ python3\n\u003e\u003e\u003e from iparser import *\n\u003e\u003e\u003e iparser = IParser(pos_config_file=PTB_POS, dep_config_file=PTB_DEP)\n\u003e\u003e\u003e print(iparser.tag('I looove iparser!'))\n[('I', 'PRP'), ('looove', 'VBP'), ('iparser', 'NN'), ('!', '.')]\n\u003e\u003e\u003e print(iparser.parse('I looove iparser!'))\n1\tI\t_\t_\tPRP\t_\t2\tnsubj\t_\t_\n2\tlooove\t_\t_\tVBP\t_\t0\troot\t_\t_\n3\tiparser\t_\t_\tNN\t_\t2\tdobj\t_\t_\n4\t!\t_\t_\t.\t_\t2\tpunct\t_\t_\n```\n\nYou can load models trained on different corpora to support multilingual:\n\n```\n\u003e\u003e\u003e iparser = IParser(seg_config_file=CTB_SEG, pos_config_file=CTB_POS, dep_config_file=CTB_DEP)\n\u003e\u003e\u003e print(iparser.parse('我爱依存分析！'))\n1\t我\t_\t_\tPN\t_\t2\tnsubj\t_\t_\n2\t爱\t_\t_\tVV\t_\t0\troot\t_\t_\n3\t依存\t_\t_\tVV\t_\t2\tccomp\t_\t_\n4\t分析\t_\t_\tVV\t_\t3\tcomod\t_\t_\n5\t！\t_\t_\tPU\t_\t2\tpunct\t_\t_\n```\n\nIf you only want to perform an intermediate step, you can checkout the following APIs.\n\n#### Word Segmentation\n\n```\n\u003e\u003e\u003e segmenter = Segmenter(CTB_SEG).load()\n\u003e\u003e\u003e segmenter.segment('下雨天地面积水')\n['下雨天', '地面', '积水']\n```\n\n- Notice that you need to call `load` to indicate that you want to load a pre-trained model, not to prepare an empty model for training.\n\n#### Part-of-Speech Tagging\n\n```\n\u003e\u003e\u003e tagger = POSTagger(PTB_POS).load()\n\u003e\u003e\u003e tagger.tag('I looove languages'.split())\n[('I', 'PRP'), ('looove', 'VBP'), ('languages', 'NNS')]\n```\n\n- `POSTagger` is not responsible for word segmentation. Do segmentation in advance or use `IParser` for convenience.\n\n#### Dependency Parsing\n\n```\n\u003e\u003e\u003e parser = DepParser(PTB_DEP).load()\n\u003e\u003e\u003e sentence = [('Is', 'VBZ'), ('this', 'DT'), ('the', 'DT'), ('future', 'NN'), ('of', 'IN'), ('chamber', 'NN'), ('music', 'NN'), ('?', '.')]\n\u003e\u003e\u003e print(parser.parse(sentence))\n1\tIs\t_\t_\tVBZ\t_\t4\tcop\t_\t_\n2\tthis\t_\t_\tDT\t_\t4\tnsubj\t_\t_\n3\tthe\t_\t_\tDT\t_\t4\tdet\t_\t_\n4\tfuture\t_\t_\tNN\t_\t0\troot\t_\t_\n5\tof\t_\t_\tIN\t_\t4\tprep\t_\t_\n6\tchamber\t_\t_\tNN\t_\t7\tnn\t_\t_\n7\tmusic\t_\t_\tNN\t_\t5\tpobj\t_\t_\n8\t?\t_\t_\t.\t_\t4\tpunct\t_\t_\n```\n\n- `DepParser` is neither responsible for segmentation nor tagging. \n- The input must be a list of tuples of word and tag.\n\n### Server\n\n```\n$ iparser serve --help\nusage: iparser serve [-h] [--port PORT]\n\nA http server for IParser\n\noptional arguments:\n  -h, --help   show this help message and exit\n  --port PORT\n```\n\n- The default URL is http://localhost:8666/\n- You can also view the live demo at http://iparser.hankcs.com/\n\n\n## Train Models\n\nIParser is designed to be language-agnostic, which means it has universal language support, only need to prepare some corpora of a desired language. \n\n### Corpus Format\n\nThe format is described here: https://github.com/hankcs/TreebankPreprocessing\n\n### Configuration File\n\nIParser employs configuration files to ensure the same network is created before and after serialization, in training phase and testing phase accordingly. This is important for research engineers who want to fine-tune those hyper parameters, or train new models on third language corpora. Configuration template files are provided with all configurable parameters for users to adjust. \n\nYou can check out templates shipped with the `iparsermodels`, e.g.\n\n```\npython3\n\u003e\u003e\u003e from iparser import *\n\u003e\u003e\u003e PTB_DEP\n'/usr/local/python3/lib/python3.6/site-packages/iparsermodels/ptb/dep/config.ini'\n```\n\n### CLI\n\nThe CLI is not only capable for prediction, but can also perform training. Only requires a configuration file.\n\n```\n$ iparser segment --help\nusage: iparser segment [-h] [--config CONFIG] [--action ACTION]\n\noptional arguments:\n  -h, --help       show this help message and exit\n  --config CONFIG  path to config file\n  --action ACTION  Which action (train, test, predict)?\n```\n\n- `--action train` is what you are looking for.\n\n### API\n\nThe training APIs can be found in `tests/train_parser.py` etc.\n\n## Performance\n\n![tag](http://wx1.sinaimg.cn/large/006Fmjmcly1fpgvl4ijsoj31kw07zgn9.jpg)\n\n![dep](http://wx3.sinaimg.cn/large/006Fmjmcly1fpgvlqpigpj31kw0bmjtt.jpg)\n\nThe character model seems to be useless for English and Chinese, so it is disabled by default.\n\n## Acknowledgments\n\n- Bi-LSTM-CRF implementation modified from a Dynet-1.x version by [rguthrie3](https://github.com/rguthrie3/BiLSTM-CRF).\n- BiAffine implementation extended from [jcyk](https://github.com/jcyk/Dynet-Biaffine-dependency-parser), added a subword LSTM layer with attention, as introduced in [Stanford's Graph-based Neural Dependency Parser at the CoNLL 2017 Shared Task](https://web.stanford.edu/~tdozat/files/TDozat-CoNLL2017-Paper.pdf).\n- Visualization part is adopted from [Annodoc](https://github.com/spyysalo/annodoc), an annotation documentation support system which is used as a wrapper of BRAT.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankcs%2Fiparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhankcs%2Fiparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankcs%2Fiparser/lists"}