{ "info": { "author": "Nitin Madnani", "author_email": "nmadnani@ets.org", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Topic :: Scientific/Engineering", "Topic :: Software Development" ], "description": "Introduction\r\n~~~~~~~~~~~~\r\n\r\n**python-zpar** is a python wrapper around the `ZPar\r\nparser `__.\r\nZPar was written by `Yue Zhang `__\r\nwhile he was at Oxford University. According to its home page: *ZPar is\r\na statistical natural language parser, which performs syntactic analysis\r\ntasks including word segmentation, part-of-speech tagging and parsing.\r\nZPar supports multiple languages and multiple grammar formalisms. ZPar\r\nhas been most heavily developed for Chinese and English, while it\r\nprovides generic support for other languages. ZPar is fast, processing\r\nabove 50 sentences per second using the standard Penn Teebank (Wall\r\nStreet Journal) data.*\r\n\r\nI wrote python-zpar since I needed a fast and efficient parser for my\r\nNLP work which is primarily done in Python and not C++. I wanted to be\r\nable to use this parser directly from Python without having to create a\r\nbunch of files and running them through subprocesses. python-zpar not\r\nonly provides a simply python wrapper but also provides an XML-RPC ZPar\r\nserver to make batch-processing of large files easier.\r\n\r\npython-zpar uses\r\n`ctypes `__, a very\r\ncool foreign function library bundled with Python that allows calling\r\nfunctions in C DLLs or shared libraries directly.\r\n\r\nInstallation\r\n~~~~~~~~~~~~\r\n\r\nCurrently, python-zpar only works on 64-bit linux and OS X systems.\r\nThose are the two platforms I use everyday. I am happy to try to get\r\npython-zpar working on other platforms over time. Pull requests are\r\nwelcome!\r\n\r\nIn order for python-zpar to work, it requires C functions that can be\r\ncalled directly. Since the only user-exposed entry point in ZPar is the\r\ncommand line client, I needed to write a shared library that would have\r\nfunctions built on top of the ZPar functionality but expose them in a\r\nway that ctypes could understand.\r\n\r\nTherefore, in order to build python-zpar from scratch, we need to\r\ndownload the ZPar source, patch it with new functionality and compile\r\nthe shared library. All of this happens automatically when you install\r\nwith pip:\r\n\r\n.. code-block:: bash\r\n\r\n pip install python-zpar\r\n\r\n**IMPORTANT**: On OS X, the installation will only work with ``gcc``\r\ninstalled using either `macports `__ or\r\n`homebrew `__. The zpar source cannot be compiled with\r\n``clang``. If you are having trouble compiling the code after cloning\r\nthe repository or installing the package using pip, you can try\r\nto explicitly override the C++ compiler:\r\n\r\n.. code-block:: bash\r\n\r\n CXX= make -e\r\n\r\nor\r\n\r\n.. code-block:: bash\r\n\r\n CXX= pip install python-zpar\r\n\r\n\r\nIf you are curious about what the C functions in the shared library\r\nmodule look like, see ``src/zpar.lib.cpp``.\r\n\r\nUsage\r\n~~~~~\r\n\r\nTo use python-zpar, you need the English models for ZPar. They can be\r\ndownloaded from the ZPar release page `here `__.\r\nThere are three models: a part-of-speech tagger, a constituency parser, and a\r\ndependency parser. For the purpose of the examples below, the models are\r\nin the ``english-models`` directory in the current directory.\r\n\r\nHere's a small example of how to use python-zpar:\r\n\r\n.. code-block:: python\r\n\r\n from six import print_\r\n from zpar import ZPar\r\n\r\n # use the zpar wrapper as a context manager\r\n with ZPar('english-models') as z:\r\n\r\n # get the parser and the dependency parser models\r\n tagger = z.get_tagger()\r\n depparser = z.get_depparser()\r\n\r\n # tag a sentence\r\n tagged_sent = tagger.tag_sentence(\"I am going to the market.\")\r\n print_(tagged_sent)\r\n\r\n # tag an already tokenized sentence\r\n tagged_sent = tagger.tag_sentence(\"Do n't you want to come with me to the market ?\", tokenize=False)\r\n print_(tagged_sent)\r\n\r\n # get the dependency parse of an already tagged sentence\r\n dep_parsed_sent = depparser.dep_parse_tagged_sentence(\"I/PRP am/VBP going/VBG to/TO the/DT market/NN ./.\")\r\n print_(dep_parsed_sent)\r\n\r\n # get the dependency parse of an already tokenized sentence\r\n dep_parsed_sent = depparser.dep_parse_sentence(\"Do n't you want to come with me to the market ?\", tokenize=False)\r\n print_(dep_parsed_sent)\r\n\r\nThe above code sample produces the following output:\r\n\r\n.. code-block::\r\n\r\n I/PRP am/VBP going/VBG to/TO the/DT market/NN ./.\r\n\r\n Do/VBP n't/RB you/PRP want/VBP to/TO come/VB with/IN me/PRP to/TO the/DT market/NN ?/.\r\n\r\n I PRP 1 SUB\r\n am VBP -1 ROOT\r\n going VBG 1 VC\r\n to TO 2 VMOD\r\n the DT 5 NMOD\r\n market NN 3 PMOD\r\n . . 1 P\r\n\r\n Do VBP -1 ROOT\r\n n't RB 0 VMOD\r\n you PRP 0 SUB\r\n want VBP 0 VMOD\r\n to TO 5 VMOD\r\n come VB 3 VMOD\r\n with IN 5 VMOD\r\n me PRP 6 PMOD\r\n to TO 5 VMOD\r\n the DT 10 NMOD\r\n market NN 8 PMOD\r\n ? . 0 P\r\n\r\n\r\nDetailed usage with comments is shown in the included file\r\n``examples/zpar_example.py``. Run ``python zpar_example.py -h`` to see a\r\nlist of all available options.\r\n\r\nZPar Server\r\n~~~~~~~~~~~\r\n\r\nThe package also provides an python XML-RPC implementation of a ZPar\r\nserver that makes it easier to process multiple sentences and files by\r\nloading the models just once (via the ctypes interface) and allowing\r\nclients to connect and request analyses. The implementation is in the\r\nexecutable ``zpar_server`` that is installed when you install the\r\npackage. The server is quite flexible and allows loading only the\r\nmodels that you need. Here's an example of how to start the server\r\nwith only the tagger and the dependency parser models loaded:\r\n\r\n.. code-block::\r\n\r\n $> zpar_server --modeldir english-models --models tagger parser depparser\r\n INFO:Initializing server ...\r\n Loading tagger from english-models/tagger\r\n Loading model... done.\r\n Loading constituency parser from english-models/conparser\r\n Loading scores... done. (65.9334s)\r\n Loading dependency parser from english-models/depparser\r\n Loading scores... done. (14.9623s)\r\n INFO:Registering introspection ...\r\n INFO:Starting server on port 8859...\r\n\r\nRun ``zpar_server -h`` to see a list of all options.\r\n\r\nOnce the server is running, you can connect to it using a client. An\r\nexample client is included in the file ``examples/zpar_client.py`` which\r\ncan be run as follows (note that if you specified a custom host and port\r\nwhen running the server, you'd need to specify the same here):\r\n\r\n.. code-block::\r\n\r\n $> cd examples\r\n $> python zpar_client.py\r\n\r\n INFO:Attempting connection to http://localhost:8859\r\n INFO:Tagging \"Don't you want to come with me to the market?\"\r\n INFO:Output: Do/VBP n't/RB you/PRP want/VBP to/TO come/VB with/IN me/PRP to/TO the/DT market/NN ?/.\r\n INFO:Tagging \"Do n't you want to come to the market with me ?\"\r\n INFO:Output: Do/VBP n't/RB you/PRP want/VBP to/TO come/VB to/TO the/DT market/NN with/IN me/PRP ?/.\r\n INFO:Parsing \"Don't you want to come with me to the market?\"\r\n INFO:Output: (SQ (VBP Do) (RB n't) (NP (PRP you)) (VP (VBP want) (S (VP (TO to) (VP (VB come) (PP (IN with) (NP (PRP me))) (PP (TO to) (NP (DT the) (NN market))))))) (. ?))\r\n INFO:Dep Parsing \"Do n't you want to come to the market with me ?\"\r\n INFO:Output: Do VBP -1 ROOT\r\n n't RB 0 VMOD\r\n you PRP 0 SUB\r\n want VBP 0 VMOD\r\n to TO 5 VMOD\r\n come VB 3 VMOD\r\n to TO 5 VMOD\r\n the DT 8 NMOD\r\n market NN 6 PMOD\r\n with IN 5 VMOD\r\n me PRP 9 PMOD\r\n ? . 0 P\r\n\r\n INFO:Tagging file /Users/nmadnani/work/python-zpar/examples/test.txt into test.tag\r\n INFO:Parsing file /Users/nmadnani/work/python-zpar/examples/test_tokenized.txt into test.parse\r\n\r\n\r\nNote that python-zpar and all of the example scripts should work with\r\nboth Python 2.7 and Python 3.4. I have tested python-zpar on both Linux\r\nand Mac but not on Windows.\r\n\r\nNode.js version\r\n~~~~~~~~~~~~~~~\r\n\r\nIf you want to use ZPar in your node.js app, check out my other project\r\n`node-zpar `__.\r\n\r\nLicense\r\n~~~~~~~\r\n\r\nAlthough python-zpar is licensed under the MIT license - which means\r\nthat you can do whatever you want with the wrapper code - ZPar itself is\r\nlicensed under GPL v3.\r\n\r\nToDo\r\n~~~~\r\n\r\n1. Improve error handling on both the python and C side.\r\n2. Expose more functionality, e.g., Chinese word segmentation, parsing\r\n etc.\r\n3. May be look into using `CFFI `__\r\n instead of ctypes.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.github.com/EducationalTestingService/python-zpar", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-zpar", "package_url": "https://pypi.org/project/python-zpar/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-zpar/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.github.com/EducationalTestingService/python-zpar" }, "release_url": "https://pypi.org/project/python-zpar/0.9.5/", "requires_dist": null, "requires_python": null, "summary": "A Wrapper around the ZPar statistical tagger/parser for English", "version": "0.9.5" }, "last_serial": 1636235, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "c84fb1bca0fc6a983d6cf59c9d7d0909", "sha256": "fb612ca3483a757fc69c21e121fa172b3f2903233bc281d0f55b0c8ac7ddc600" }, "downloads": -1, "filename": "python-zpar-0.2.tar.gz", "has_sig": false, "md5_digest": "c84fb1bca0fc6a983d6cf59c9d7d0909", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11530, "upload_time": "2014-10-07T22:26:16", "url": "https://files.pythonhosted.org/packages/23/2d/831a8d4982b55c560c62614b7ec5ff91418584aa09153288a514332d19f4/python-zpar-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "f2548d05687fa8b4670e772ba91b18a0", "sha256": "f720c4d99105b2cb91431ea1bbefb43c896852cc0777d2848410f8531216befe" }, "downloads": -1, "filename": "python-zpar-0.3.tar.gz", "has_sig": false, "md5_digest": "f2548d05687fa8b4670e772ba91b18a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11796, "upload_time": "2014-10-08T13:54:59", "url": "https://files.pythonhosted.org/packages/0b/47/664d4836a62ec8df820692b29061dc5679ceeaa7e97a617d70d24cfebc66/python-zpar-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "1f1523d309e11b922c5e028fd80aeaa8", "sha256": "88b1ce845a91a4dc585473489f1c957f744b5dec11087a6392ab896e30c70bfe" }, "downloads": -1, "filename": "python-zpar-0.4.tar.gz", "has_sig": false, "md5_digest": "1f1523d309e11b922c5e028fd80aeaa8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11997, "upload_time": "2014-10-18T03:27:12", "url": "https://files.pythonhosted.org/packages/9b/41/4574b0e2cb80e16a4ea3fd46dde68e378be83163bbe6032c5ee94bc253b8/python-zpar-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "eab6d9ef611298f084ac9adb704902c2", "sha256": "027cf2cfe28bac23ff5be1e17ed6a8d7f0430a5fc6af7028764d4b3018bf004b" }, "downloads": -1, "filename": "python-zpar-0.5.tar.gz", "has_sig": false, "md5_digest": "eab6d9ef611298f084ac9adb704902c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12897, "upload_time": "2014-10-27T20:42:20", "url": "https://files.pythonhosted.org/packages/ae/1d/c3090433016cc928bf8a902e3afef03d8491ac8d73473f7cf0bd46876b22/python-zpar-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "dd98dc19484a8759be2f6c92eb2a0dd4", "sha256": "24d1fa4f04e61fb0c4a0420308852ce7485bc329b4c53cad83e1a9bf04ddd8d7" }, "downloads": -1, "filename": "python-zpar-0.6.tar.gz", "has_sig": false, "md5_digest": "dd98dc19484a8759be2f6c92eb2a0dd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15316, "upload_time": "2014-10-29T18:19:16", "url": "https://files.pythonhosted.org/packages/54/29/e22560a118618812dd35dc6bb5eca4123c1986b49bf14cd128bf0285e31a/python-zpar-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "ac7d11cc163d6a0b4c9e6bed737ec665", "sha256": "43287393f6038bc86e80b9c1ceb634280b6f5a44b33bae0ecc0f30f2780a1849" }, "downloads": -1, "filename": "python-zpar-0.7.tar.gz", "has_sig": false, "md5_digest": "ac7d11cc163d6a0b4c9e6bed737ec665", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15056, "upload_time": "2014-11-08T02:11:04", "url": "https://files.pythonhosted.org/packages/ce/9c/78a83e0a6466838c6db1c1692c391b7a569af94ab55038da06e222ec167e/python-zpar-0.7.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "085179cfaf624ac617a167c5baa9e8bc", "sha256": "b86609827122a2d0203178b126b925cd7609800bf68874e84512baaa64208bca" }, "downloads": -1, "filename": "python-zpar-0.8.tar.gz", "has_sig": false, "md5_digest": "085179cfaf624ac617a167c5baa9e8bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15412, "upload_time": "2014-11-11T01:11:48", "url": "https://files.pythonhosted.org/packages/85/74/9ffe26c14c3ac7ae671755a39af4f9449d927b52fc108aacf20d9977b947/python-zpar-0.8.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "0a6f16f410a86be4a53fa0b94f15bd0e", "sha256": "b44bd6973db2d9bba404e48cd13b8c5b433c7817d23644f12de65129ae7ecdfc" }, "downloads": -1, "filename": "python-zpar-0.8.1.tar.gz", "has_sig": false, "md5_digest": "0a6f16f410a86be4a53fa0b94f15bd0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15274, "upload_time": "2014-11-17T14:01:47", "url": "https://files.pythonhosted.org/packages/d6/93/0bf2f5c3ed9bb265df9a89072ce6132d2bd416ab4adca2e4e7b4ad8377cb/python-zpar-0.8.1.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "9ce47ad5206c045acbaa546970933b9b", "sha256": "061cb1e700cd14198716106484522e47fe25581bce0413eabfcf73eddacd344e" }, "downloads": -1, "filename": "python-zpar-0.9.0.tar.gz", "has_sig": false, "md5_digest": "9ce47ad5206c045acbaa546970933b9b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18580, "upload_time": "2014-12-11T20:14:14", "url": "https://files.pythonhosted.org/packages/1c/a1/5561fa7bda2a71b114e0997e0cb947abef9fa8c0d60a06ecb2320933f4e5/python-zpar-0.9.0.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "4e129135cd735bb82cb99cb592dade40", "sha256": "0449a23775fc3ffd970f048cb91321fbccfdced7bc3529d8221b4568147a2ffa" }, "downloads": -1, "filename": "python-zpar-0.9.1.tar.gz", "has_sig": false, "md5_digest": "4e129135cd735bb82cb99cb592dade40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18624, "upload_time": "2014-12-12T22:03:13", "url": "https://files.pythonhosted.org/packages/b6/b2/992a1b7bb0222e8f31f17365ea0fb8fe662aa24905fd996e3f6cee906983/python-zpar-0.9.1.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "c260abe68fbaf54550a52fb500febf5e", "sha256": "0841a554b0b44de670085d700f987211f218532fa2e3e158e6cdbc5d075238f7" }, "downloads": -1, "filename": "python-zpar-0.9.2.tar.gz", "has_sig": false, "md5_digest": "c260abe68fbaf54550a52fb500febf5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19042, "upload_time": "2015-05-28T15:19:02", "url": "https://files.pythonhosted.org/packages/63/11/3866592b2e707974c7caa936467da138d04594cde6c19502fce90015720d/python-zpar-0.9.2.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "3a050ffc57d64ef5d7d2e97ff8de7be3", "sha256": "9615c6d75e08a9d5911750280c094c2ce8e2e62e4a691d0c6d10205f20661332" }, "downloads": -1, "filename": "python-zpar-0.9.3.tar.gz", "has_sig": false, "md5_digest": "3a050ffc57d64ef5d7d2e97ff8de7be3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19042, "upload_time": "2015-05-29T20:27:43", "url": "https://files.pythonhosted.org/packages/a5/4c/c580fac6dca9cec3f6e86ae788217dc7d35fb13f58bb4517e0db95d1d1ac/python-zpar-0.9.3.tar.gz" } ], "0.9.5": [ { "comment_text": "", "digests": { "md5": "d15d1a90dc4385cdd35f5e9e0858999a", "sha256": "6ec9be247d2aa9ebd9a13b3d480973b269d9958526c256f45d502aba57a858cf" }, "downloads": -1, "filename": "python-zpar-0.9.5.tar.gz", "has_sig": false, "md5_digest": "d15d1a90dc4385cdd35f5e9e0858999a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18585, "upload_time": "2015-07-16T14:18:56", "url": "https://files.pythonhosted.org/packages/73/80/6961436556d7720239234a41e564cd30eed632f0f3a39ca8d82f288fb858/python-zpar-0.9.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d15d1a90dc4385cdd35f5e9e0858999a", "sha256": "6ec9be247d2aa9ebd9a13b3d480973b269d9958526c256f45d502aba57a858cf" }, "downloads": -1, "filename": "python-zpar-0.9.5.tar.gz", "has_sig": false, "md5_digest": "d15d1a90dc4385cdd35f5e9e0858999a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18585, "upload_time": "2015-07-16T14:18:56", "url": "https://files.pythonhosted.org/packages/73/80/6961436556d7720239234a41e564cd30eed632f0f3a39ca8d82f288fb858/python-zpar-0.9.5.tar.gz" } ] }