Convert sentences containing numbers written in words into numeric values.
Project description
WORDS TO NUMBER CONVERTER
This package allows you to convert sentences containing numbers written in words in multiple languages (French, English, Spanish) into numeric values (integers or floats).
Supported Languages
- English
- French
- Spanish
Feel free to contribute and add more languages.
Installation
To use this package, make sure you have Python installed on your machine. No external dependencies are required for this package.
Usage
The main function of this package is convert(sentence, decimal_part=False)
.
Arguments
- sentence (str): A string containing numbers written in words.
- decimal_part (bool): Optional. Allows a recursive call of the function for the decimal part; do not change this value.
Return
- Returns an integer or a float corresponding to the provided phrase.
Examples
>>> convert("one")
1
>>> convert("ten thousand two hundred forty-seven")
10247
>>> convert("four point five")
4.5
Notes
- The function supports numbers in words up to several billion and handles decimal values with words like "point", "virgule", or "punto" depending on the language.
- Make sure the provided string is well-formed to avoid conversion errors.
Authors
This package was developed by Benjamin Bonneton. For any questions or contributions, feel free to reach out!
License
This project is licensed under the GPLv3 License. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file words2number-1.0.1.tar.gz
.
File metadata
- Download URL: words2number-1.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0fc266395f5e373a8448d55757883b9840454f4f7eb508078bc2ca42ce279ac |
|
MD5 | 8b8eb201e1b8a7168e70daef425c9fbd |
|
BLAKE2b-256 | 6129dc6012a815f388e795fef8dba941f79ef4074ad0ff330e162df864c1241e |
File details
Details for the file words2number-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: words2number-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7801df6c85add63fd14f9ab33ed24c2fb1f1a99d7257f408003fee74387c3e7 |
|
MD5 | af803915d4b8a467aa7085f4c8215b69 |
|
BLAKE2b-256 | 33073e3bd5a607b17c65d7da2ccf9a23ba0ab364b1b5d781cc33dc66e414edfc |