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.0.tar.gz
.
File metadata
- Download URL: words2number-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 808ac07e484cce0f720248c9b1c7b1fcbc727363fce2cdf350fcdff25a147adc |
|
MD5 | cf092d4fb14a4fc860cff390fd7d859c |
|
BLAKE2b-256 | c6621406046a673801ede7f2ba157911c4acec3a425c35b1160d0ad94565fee6 |
File details
Details for the file words2number-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: words2number-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.6 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 | d65b8c5113e92e9b860e08567997c88672bfdcf99dd710898df835fc95e07755 |
|
MD5 | b244574c0220ee215c4678813cea5c4c |
|
BLAKE2b-256 | 3c183f152e12e72f39e67452607ee14ae23cbc4cc5ec7f1dab31f672384a3c98 |