word2number


Nameword2number JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://github.com/akshaynagpal/w2n
SummaryConvert number words eg. three hundred and forty two to numbers (342).
upload_time2017-06-02 15:45:14
maintainer
docs_urlNone
authorAkshay Nagpal
requires_python
licenseThe MIT License (MIT) Copyright (c) 2016 Akshay Nagpal (https://github.com/akshaynagpal) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords numbers convert words
VCS
bugtrack_url
requirements future
Travis-CI
coveralls test coverage No coveralls.
            |travis_pic| |codecov_pic|

==============
Word to Number
==============
This is a Python module to convert number words (eg. twenty one) to numeric digits (21). It works for positive numbers upto the range of 999,999,999,999 (i.e. billions).

++++++++++++
Installation
++++++++++++
Please ensure that you have **updated pip** to the latest version before installing word2number.

You can install the module using Python Package Index using the below command.

.. code-block:: python

  pip install word2number

Make sure you install all requirements given in requirements.txt

.. code-block:: python

  pip install -r requirements.txt

+++++
Usage
+++++
First you have to import the module using the below code.
.. code-block:: python

    from word2number import w2n

Then you can use the **word_to_num** method to convert a number-word to numeric digits, as shown below.

.. code-block:: python

    >>> print w2n.word_to_num("two million three thousand nine hundred and eighty four")
    2003984

    >>> print(w2n.word_to_num('two point three')) 
    2.3

    >>> print(w2n.word_to_num('112')) 
    112

    >>> print(w2n.word_to_num('point one')) 
    0.1

    >>> print(w2n.word_to_num('one hundred thirty-five')) 
    135

    >>> print(w2n.word_to_num('million million'))
    Error: Redundant number! Please enter a valid number word (eg. two million twenty three thousand and forty nine)
    None

    >>> print(w2n.word_to_num('blah'))
    Error: No valid number words found! Please enter a valid number word (eg. two million twenty three thousand and forty nine)
    None

+++++++++++
Bugs/Errors
+++++++++++

Please ensure that you have updated pip to the latest version before installing word2number.

If you find any bugs/errors in the usage of above code, please raise an issue through `Github <http://github.com/akshaynagpal/w2n>`_. If you don't know how to use Github or raise an issue through it, I suggest that you should learn it. Else, send an email to akshay2626@gmail.com with a clear example that can reproduce the issue.

++++++++++++
Contributors
++++++++++++
- Ben Batorsky (`bpben <https://github.com/bpben>`__)
- Alex (`ledovsky <https://github.com/ledovsky>`__)
- Tal Yarkoni (`tyarkoni <https://github.com/tyarkoni>`__)
- ButteredGroove (`ButteredGroove <https://github.com/ButteredGroove>`__)

.. |travis_pic| image:: https://travis-ci.org/akshaynagpal/w2n.svg?branch=master 
   :target: https://travis-ci.org/akshaynagpal/w2n

.. |codecov_pic| image:: https://codecov.io/gh/akshaynagpal/w2n/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/akshaynagpal/w2n
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/akshaynagpal/w2n",
    "name": "word2number",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "numbers, convert, words",
    "author": "Akshay Nagpal",
    "author_email": "akshay2626@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4a/29/a31940c848521f0725f0df6b25dca8917f13a2025b0e8fcbe5d0457e45e6/word2number-1.1.zip",
    "platform": "",
    "description": "|travis_pic| |codecov_pic|\r\n\r\n==============\r\nWord to Number\r\n==============\r\nThis is a Python module to convert number words (eg. twenty one) to numeric digits (21). It works for positive numbers upto the range of 999,999,999,999 (i.e. billions).\r\n\r\n++++++++++++\r\nInstallation\r\n++++++++++++\r\nPlease ensure that you have **updated pip** to the latest version before installing word2number.\r\n\r\nYou can install the module using Python Package Index using the below command.\r\n\r\n.. code-block:: python\r\n\r\n  pip install word2number\r\n\r\nMake sure you install all requirements given in requirements.txt\r\n\r\n.. code-block:: python\r\n\r\n  pip install -r requirements.txt\r\n\r\n+++++\r\nUsage\r\n+++++\r\nFirst you have to import the module using the below code.\r\n.. code-block:: python\r\n\r\n    from word2number import w2n\r\n\r\nThen you can use the **word_to_num** method to convert a number-word to numeric digits, as shown below.\r\n\r\n.. code-block:: python\r\n\r\n    >>> print w2n.word_to_num(\"two million three thousand nine hundred and eighty four\")\r\n    2003984\r\n\r\n    >>> print(w2n.word_to_num('two point three')) \r\n    2.3\r\n\r\n    >>> print(w2n.word_to_num('112')) \r\n    112\r\n\r\n    >>> print(w2n.word_to_num('point one')) \r\n    0.1\r\n\r\n    >>> print(w2n.word_to_num('one hundred thirty-five')) \r\n    135\r\n\r\n    >>> print(w2n.word_to_num('million million'))\r\n    Error: Redundant number! Please enter a valid number word (eg. two million twenty three thousand and forty nine)\r\n    None\r\n\r\n    >>> print(w2n.word_to_num('blah'))\r\n    Error: No valid number words found! Please enter a valid number word (eg. two million twenty three thousand and forty nine)\r\n    None\r\n\r\n+++++++++++\r\nBugs/Errors\r\n+++++++++++\r\n\r\nPlease ensure that you have updated pip to the latest version before installing word2number.\r\n\r\nIf you find any bugs/errors in the usage of above code, please raise an issue through `Github <http://github.com/akshaynagpal/w2n>`_. If you don't know how to use Github or raise an issue through it, I suggest that you should learn it. Else, send an email to akshay2626@gmail.com with a clear example that can reproduce the issue.\r\n\r\n++++++++++++\r\nContributors\r\n++++++++++++\r\n- Ben Batorsky (`bpben <https://github.com/bpben>`__)\r\n- Alex (`ledovsky <https://github.com/ledovsky>`__)\r\n- Tal Yarkoni (`tyarkoni <https://github.com/tyarkoni>`__)\r\n- ButteredGroove (`ButteredGroove <https://github.com/ButteredGroove>`__)\r\n\r\n.. |travis_pic| image:: https://travis-ci.org/akshaynagpal/w2n.svg?branch=master \r\n   :target: https://travis-ci.org/akshaynagpal/w2n\r\n\r\n.. |codecov_pic| image:: https://codecov.io/gh/akshaynagpal/w2n/branch/master/graph/badge.svg\r\n   :target: https://codecov.io/gh/akshaynagpal/w2n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)\r\n\r\nCopyright (c) 2016 Akshay Nagpal (https://github.com/akshaynagpal)\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.",
    "summary": "Convert number words eg. three hundred and forty two to numbers (342).",
    "version": "1.1",
    "split_keywords": [
        "numbers",
        " convert",
        " words"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "dcbd07346732407f86f33b0a811b74ff",
                "sha256": "70e27a5d387f67b04c71fbb7621c05930b19bfd26efd6851e6e0f9969dcde7d0"
            },
            "downloads": -1,
            "filename": "word2number-1.1.zip",
            "has_sig": false,
            "md5_digest": "dcbd07346732407f86f33b0a811b74ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9723,
            "upload_time": "2017-06-02T15:45:14",
            "upload_time_iso_8601": "2017-06-02T15:45:14.488024Z",
            "url": "https://files.pythonhosted.org/packages/4a/29/a31940c848521f0725f0df6b25dca8917f13a2025b0e8fcbe5d0457e45e6/word2number-1.1.zip",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2017-06-02 15:45:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "akshaynagpal",
    "github_project": "w2n",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "future",
            "specs": []
        }
    ],
    "lcname": "word2number"
}
        
Elapsed time: 0.01624s