{ "info": { "author": "Shuo Li", "author_email": "contact@shuo.li", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# pycnnum\n\nChinese number <-> Arabic number conversion\n\n## Constants\n\n`NUMBERING_TYPES = ['low', 'mid', 'high']`: Chinese numbering type.\n\n `low` : `'\u5146'` = `'\u4ebf'` * 10 = $10^{9}$, `'\u4eac'` is $10^{10}$, etc.\n\n `mid` : `'\u5146'` = `'\u4ebf'` * `'\u4e07'` = $10^{12}$, `'\u4eac'` is $10^{16}$, etc.\n\n `high` : `'\u5146'` = `'\u4ebf'` * `'\u4ebf'` = $10^{16}$, `'\u4eac'` is $10^{32}$, etc.\n\n```python\nnumber = '\u96f6\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d'\n# 0-9\n\nbig_number_s = '\u96f6\u58f9\u8d30\u53c1\u8086\u4f0d\u9646\u67d2\u634c\u7396'\n# capital, simpilified Chinese number\n\nbig_number_t = '\u96f6\u58f9\u8cb3\u53c3\u8086\u4f0d\u9678\u67d2\u634c\u7396'\n# capital, traditional Chinese number\n\nunit_s = '\u4ebf\u5146\u4eac\u5793\u79ed\u7a70\u6c9f\u6da7\u6b63\u8f7d'\n# simpilified Chinese number units\n# power of each unit depends on the counting type.\n\nunit_t = '\u5104\u5146\u4eac\u5793\u79ed\u7a70\u6e9d\u6f97\u6b63\u8f09'\n# traditional Chinese number units\n# power of each unit depends on the counting type.\n\nsunit_s = '\u5341\u767e\u5343\u4e07'\n# simpilified Chinese number units\n# powers = [1, 2, 3, 4]\n\nsunit_t = '\u62fe\u4f70\u4edf\u842c'\n# traditional Chinese number units\n# powers = [1, 2, 3, 4]\n\nzero_alt = '\u3007'\n# alternative of 0\n\ntwo_alts = ['\u4e24', '\u5169']\n# alternatives of 2, can be used if it is not the last charactor\n\npositive = ['\u6b63', '\u6b63']\n# positive sign, [simplified, traditional]\n\nnegative = ['\u8d1f', '\u8ca0']\n# negative sign, [simplified, traditional]\n\npoint = ['\u70b9', '\u9ede']\n# point, [simplified, traditional]\n```\n\n## Methods\n\n```python\ncn2num(chinese_string, numbering_type=NUMBERING_TYPES[1])\n```\n\n `chinese_string` : input Chinese string, e.g. `'\u5341\u4e5d'`\n\n `numbering_type` : Chinese numbering type.\n\n `low` : `'\u5146'` = `'\u4ebf'` * 10 = $10^{9}$, `'\u4eac'` is $10^{10}$, etc.\n\n `mid` : `'\u5146'` = `'\u4ebf'` * `'\u4e07'` = $10^{12}$, `'\u4eac'` is $10^{16}$, etc.\n\n `high` : `'\u5146'` = `'\u4ebf'` * `'\u4ebf'` = $10^{16}$, `'\u4eac'` is $10^{32}$, etc.\n\n```python\nnum2cn(num, numbering_type=COUNTING_TYPES[1],\n big=False, traditional=False, alt_zero=False, alt_two=False,\n use_zeros=True )\n```\n\n `num` : int or float number, e.g. `10`, `-1.5`\n `numbering_type` : Chinese numbering type.\n\n `low` : `'\u5146'` = `'\u4ebf'` * 10 = $10^{9}$, `'\u4eac'` is $10^{10}$, etc.\n\n `mid` : `'\u5146'` = `'\u4ebf'` * `'\u4e07'` = $10^{12}$, `'\u4eac'` is $10^{16}$, etc.\n\n `high` : `'\u5146'` = `'\u4ebf'` * `'\u4ebf'` = $10^{16}$, `'\u4eac'` is $10^{32}$, etc.\n\n `big` : set to True to get capital Chinese numbers\n\n `traditional` : set to True to get traditional Chinese numbers\n\n `alt_zero` : set to True to use `'\u3007'` for 0\n\n `alt_two` : set to True to use `'\u4e24'` or `'\u5169'` when possible\n\n `use_zeros` : set to False to eliminate `0` when possible, e.g. `\u4e00\u5343\u96f6\u4e94\u767e` will be formated to `\u4e00\u5343\u4e94\u767e`\n\n## Example\n```python\nprint('num:', cn2num('\u5341'))\nprint('num:', cn2num('\u4e00\u4ebf\u516d\u70b9\u4e09'))\nc = num2cn(33212222222, numbering_type = 'high', alt_two = True, big = True, traditional= True)\nprint(c)\n```\n\nResult:\n\n```\nnum: 10\nnum: 160000000.3\n\u53c3\u4f70\u53c3\u62fe\u8cb3\u5104\u8cb3\u4edf\u8cb3\u4f70\u8cb3\u62fe\u8cb3\u842c\u8cb3\u4edf\u8cb3\u4f70\u8cb3\u62fe\u8cb3\n[Finished in 0.3s]\n```\n\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/zcold/pycnnum", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pycnnum", "package_url": "https://pypi.org/project/pycnnum/", "platform": "", "project_url": "https://pypi.org/project/pycnnum/", "project_urls": { "Homepage": "https://github.com/zcold/pycnnum" }, "release_url": "https://pypi.org/project/pycnnum/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "Chinese number <-> Arabic number conversion", "version": "1.0.1" }, "last_serial": 3942071, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "450f64d2b30ecf7599df51baca675a45", "sha256": "769c1fa7f62d37a40a430a3fbc9b50c800554ea6d0c180cf0b799d6ecafdd180" }, "downloads": -1, "filename": "pycnnum-1.0.0.zip", "has_sig": false, "md5_digest": "450f64d2b30ecf7599df51baca675a45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6457, "upload_time": "2015-08-28T08:36:42", "url": "https://files.pythonhosted.org/packages/b7/89/8569cdb43ea13d9439f0427203d5594b3365fcf4acf34dd39c69f2b4947f/pycnnum-1.0.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e2dfa6f3671338efda7286e852b95e8e", "sha256": "ae8556c2795624fa11077bc8330e16de0b68ddafefa8a8dfa8ef64abaf8715be" }, "downloads": -1, "filename": "pycnnum-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e2dfa6f3671338efda7286e852b95e8e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6156, "upload_time": "2018-06-08T07:10:21", "url": "https://files.pythonhosted.org/packages/dd/42/ca3efad36831c0123ea6fa147020f50e3f478ed26fcfcce6101e201f11fb/pycnnum-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16a7911a21472d08cedc558771f9af08", "sha256": "d92f1a6ebb7508401f10c5acadba2d4632336fbd8758fe5f068e8b452d2ec2a0" }, "downloads": -1, "filename": "pycnnum-1.0.1.tar.gz", "has_sig": false, "md5_digest": "16a7911a21472d08cedc558771f9af08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5645, "upload_time": "2018-06-08T07:10:23", "url": "https://files.pythonhosted.org/packages/00/d2/16597ca74e97a2c2458c4eae8739d0908c76861d1948fdf166f0fb0e93c6/pycnnum-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e2dfa6f3671338efda7286e852b95e8e", "sha256": "ae8556c2795624fa11077bc8330e16de0b68ddafefa8a8dfa8ef64abaf8715be" }, "downloads": -1, "filename": "pycnnum-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e2dfa6f3671338efda7286e852b95e8e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6156, "upload_time": "2018-06-08T07:10:21", "url": "https://files.pythonhosted.org/packages/dd/42/ca3efad36831c0123ea6fa147020f50e3f478ed26fcfcce6101e201f11fb/pycnnum-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16a7911a21472d08cedc558771f9af08", "sha256": "d92f1a6ebb7508401f10c5acadba2d4632336fbd8758fe5f068e8b452d2ec2a0" }, "downloads": -1, "filename": "pycnnum-1.0.1.tar.gz", "has_sig": false, "md5_digest": "16a7911a21472d08cedc558771f9af08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5645, "upload_time": "2018-06-08T07:10:23", "url": "https://files.pythonhosted.org/packages/00/d2/16597ca74e97a2c2458c4eae8739d0908c76861d1948fdf166f0fb0e93c6/pycnnum-1.0.1.tar.gz" } ] }