{ "info": { "author": "Shih-hong Tsai", "author_email": "doublebite@iis.sinica.edu.tw", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Template from Equation\n\n\nThis library provides functions to create template (make template) from its associated equation (e.g. 2+5 -> n0+n1).\n\n\nThe term \"**equation template**\" is first introduced in Kushman et al.(2014). It represents the abstraction of equation systems. The concept of it are then used in many following works. We found a tool to create such templates useful but not publicly available. So we tried to write one and share with peers in the area of automatic math word problem solving in NLP.\n\n\nThe template generated would contain \"n0, n1, n2, ...\" for numbers and \"x0, x1, x2, ...\" for variables.\nFor example: \n+ 2+5 -> n0+n1\n+ 2+5*60/x = y -> n0 + n1 * n2 / x0 = x1\n\n\nIn some situations, we want to keep some constants in the equation unchanged. For example, to get the template of the equation \"2+7\\*60 = x\" for the problem *\"How many minutes is 2 hours and 7 minutes?\"*, we want to keep the constant \"60\" unchanged. In this situation, our function allows passing a number slot which contains only the numbers we want to substitute for our template. (See the Example Usage below).\n\n\nTo make template from equation, we use the ast trees. When traversing an AST tree, it returns \"n0, n1, n2, ...\" for the leaf nodes of numbers, and \"x0, x1, x2\" for variables. Then, an equation of \"2+5\\*x\" can be turned into its template \"n0+n1\\*x0\". (Using AST tree can help us avoid some subtle string matching difficulties of regular expression.)\n\n\n\n\n## Installation\n```\npip install template_from_equation\n```\n\n\n## Usage\n```python\n>>> from template_from_equation import Equation\n\n>>> eq1 = Equation(\"2+5\")\n>>> eq1\n2 + 5\n>>> eq1.get_template()\n'n0 + n1'\n\n>>> eq2 = Equation(\"2+7*60 = x\")\n>>> eq2\n2 + 7 * 60 = x\n>>> eq2.get_template()\n'n0 + n1 * n2 = x0'\n>>> eq2.get_template(num_slot=[2,7])\n'n0 + n1 * 60 = x0'\n\n>>> eq3 = Equation(\"2*x+5*12 = y\")\n>>> eq3.get_template()\n'n0 * x0 + n1 * n2 = x1'\n>>> eq3.get_template(num_slot=[2,5])\n'n0 * x0 + n1 * 12 = x1'\n```\n\n\n## Todo\n\n- [ ] An option to share tokens for repeated numbers, i.e. 2+5*2 -> n0 +n1 * n0\n- [ ] To parse the operator \"^\"\n\n\n\n## References\n+ [Kushman, Nate, et al. \"Learning to automatically solve algebra word problems.\" Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Vol. 1. 2014.](https://www.aclweb.org/anthology/P14-1026)\n+ [codegen](https://github.com/andreif/codegen): Some of the naming styles but not the code are adapted from codegen, which is a library to convert ast tree to python code \n\n\n## License\nThis project is licensed under the terms of the MIT license.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/doubleBite/Template-from-Equation", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "template-from-equation", "package_url": "https://pypi.org/project/template-from-equation/", "platform": "", "project_url": "https://pypi.org/project/template-from-equation/", "project_urls": { "Homepage": "https://github.com/doubleBite/Template-from-Equation" }, "release_url": "https://pypi.org/project/template-from-equation/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Create template from equation", "version": "0.1.2" }, "last_serial": 5428682, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7681995a8314897641c23472a232f86e", "sha256": "716d157e6e323220db6fae0f82494f972507d045fff459eef5d651947bd3d56b" }, "downloads": -1, "filename": "template_from_equation-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7681995a8314897641c23472a232f86e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4801, "upload_time": "2019-06-18T04:24:22", "url": "https://files.pythonhosted.org/packages/ab/ab/fd14b3223042a2f680758e1fbb078265947b26fdaf7d9d11bbd964144a45/template_from_equation-0.1-py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "06727ad68453ce74db89d1e182690ac7", "sha256": "1ae11d6297fe615cdec3afbe0c64ea0232152d546ddcaf619d306e00806cba5d" }, "downloads": -1, "filename": "template_from_equation-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "06727ad68453ce74db89d1e182690ac7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5702, "upload_time": "2019-06-21T03:12:13", "url": "https://files.pythonhosted.org/packages/e1/e2/86428d18cae0535f10a2fcd4ddf309f551c3299eba5686ed52aafdc34e04/template_from_equation-0.1.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "06727ad68453ce74db89d1e182690ac7", "sha256": "1ae11d6297fe615cdec3afbe0c64ea0232152d546ddcaf619d306e00806cba5d" }, "downloads": -1, "filename": "template_from_equation-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "06727ad68453ce74db89d1e182690ac7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5702, "upload_time": "2019-06-21T03:12:13", "url": "https://files.pythonhosted.org/packages/e1/e2/86428d18cae0535f10a2fcd4ddf309f551c3299eba5686ed52aafdc34e04/template_from_equation-0.1.2-py3-none-any.whl" } ] }