# numwords_to_nums:
- numwords_to_nums not only handles a wide range of numeric conversions, including large numbers and Indian numbering systems but also ensures that it maintains the integrity of your input string.
- It won't alter punctuation marks like full stops, capitalization of characters, word order in sentences, or sentence arrangement.
- You can trust that it will provide you with your exact input string while making only the necessary conversions.
- <b>Exception</b> : evaluate() method or evaluation mode as they return evaluation of mathematical expression found in your text.
- Large number support till quadrillion and Indian scale support till arab so no need to worry about large numbers.
- I find this useful when I've transcribed audio into text and need to seamlessly transform that textual data into numerical digits, mathematical operators, and ultimately, evaluate complex numerical expressions.
<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#installation">Installation</a>
</li>
<li><a href="#prerequisites">Prerequisites</a></li>
<li>
<a href="#usage">Usage</a>
<ul>
<li><a href="#method-overview">Method overview</a></li>
<ul>
<li><a href="#numerical_words_to_numbers">numerical_words_to_numbers()</a></li>
<li><a href="#evaluate">evaluate()</a></li>
</ul>
</ul>
</li>
<li><a href="#examples">Examples</a>
<ul>
<li><a href="#sentence-without-any-conversion">Sentence without any conversion</a></li>
<li><a href="#convert-digits-from-a-random-sentence">Convert digits from a random sentence</a></li>
<li><a href="#large-numbers">Large numbers</a></li>
<li><a href="#indian-numbering-system">Indian numbering system</a></li>
<li><a href="#convert-ordinals">Convert ordinals</a></li>
<li><a href="#dates-and-years">Dates and Years</a></li>
<li><a href="#operator-conversion">Operator Conversion</a></li>
<li><a href="#operator-not-with-digits">Operator not with digits?</a></li>
<li><a href="#decimal-numbers">Decimal numbers</a></li>
<li><a href="#have-your-own-evaluate-function">Have your own evaluate function?</a></li>
<li><a href="#expression-evaluation">Expression Evaluation</a></li>
<li><a href="#numeric-calculation-in-text">Numeric Calculation in Text</a></li>
<li><a href="#handle-all-patterns-at-same-time">Handle all patterns at same time</a></li>
</ul>
</li>
<li><a href="#improvements-or-issues">Improvements or Issues</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#acknowledgments">Acknowledgments</a></li>
</ol>
</details>
## Installation
```
pip3 install numwords_to_nums
```
## Prerequisites
- Python 3 or later
## Usage
1) Import the NumWordsToNum class
```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
```
2) Initialize the NumWordsToNum object
```
num = NumWordsToNum()
```
3) Select one of the below method based on your requirement
- numerical_words_to_numbers()
- evaluate()
4) Here's a <b>basic example</b>
```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
num = NumWordsToNum()
result = num.numerical_words_to_numbers("twenty ten and twenty one")
print(result) # Output: 2010 and 21
eval_result = num.evaluate('Hey calculate 2+5')
print(eval_result) # Output: 7
```
### Method overview
- #### numerical_words_to_numbers()
```
numerical_words_to_numbers(text, convert_operator=False, calculate_mode=False, evaluate=False)
```
- Converts numerical words in the input text to their corresponding numeric digits. Optionally, it can also handle mathematical operator words and perform calculations.
- <b>Parameters: </b>
- <b>text (str)</b>: The input text containing numerical words to be converted.
- <b>convert_operator (bool, optional)</b>: If True, converts operator words like "plus," "minus," etc., to their corresponding mathematical symbols (+, -, etc.). Use to display operators on UI or for user. Default is False.
- <b>calculate_mode (bool, optional)</b>: If True, activates the calculation mode, allowing mathematical operations to be performed later on if required, using converted numerical words and operators. Default is False
- <b>evaluate (bool, optional)</b>: If True, evaluates the mathematical expression in the text when in calculate_mode. Raises an exception if calculate_mode is not enabled. Default is False.
- <b>Returns: </b>
- <b>str</b>: The input text with numerical words and optionally operators converted to their numeric equivalents. If calculate_mode is enabled and evaluate is True, it returns the result of the mathematical expression.
- <b>Raises:</b>
- <b>Exception</b>: If convert_operator is set to False when calculate_mode is True, as operator conversion is required
for calculation.
- <b>Exception</b>: If evaluate is True but calculate_mode is not enabled, as calculation mode is necessary for evaluation.
- #### evaluate()
```
evaluate()
```
- Evaluates a mathematical expression represented as a string.
- This method takes an input string containing a mathematical expression, cleans it by removing non-numeric and non-mathematical characters,
and then attempts to evaluate the expression.
- If the evaluation is successful, it returns the result as a string.
- If an evaluation error occurs, it returns an error message indicating that the answer is undefined along with the
specific evaluation error.
- <b>Args</b>:
- <b>str</b>: The input string containing a mathematical expression to be evaluated.
- <b>Returns</b>:
- <b>str</b>: The result of the mathematical expression as a string if evaluation is successful. If an error occurs
during evaluation, it returns an error message with details of the error.
- <b>Example</b>:
- Input : '2 + 3 * 4' --> Output: '14'
- Input : '10 / 0' --> Output: ' The answer is undefined. Evaluation error: division by zero'.
## Examples
- #### Sentence without any conversion
<b>What happens if you feed a string which has no digits, ordinals or operators to be converted?</b> Well we don't touch it
- 'This is just a random sentence.' --> 'This is just a random sentence.'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'This is just a random sentence.'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Convert digits from a random sentence
<b>Want to convert just the digits from your sentence?</b> It's possible now. Here are a few <b>examples</b>
- 'I am twenty five years old and my dad is fifty years old. I would like to get my father two cars!' --> 'I am 25 years old and my dad is 50 years old. I would like to get my father 2 cars!'
- 'Joe Biden became the oldest person to assume the presidency at the age of seventy eight.' --> 'Joe Biden became the oldest person to assume the presidency at the age of 78.'
- 'The event was held at the U.S. Capitol in Washington, D.C., and was attended by a limited number of people due to the COVID-nineteen pandemic.' --> 'The event was held at the U.S. Capitol in Washington, D.C., and was attended by a limited number of people due to the COVID-19 pandemic.'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'Joe Biden became the oldest person to assume the presidency at the age of seventy eight.'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Large numbers
<b>Want support for large numbers?</b> Sure, we will support you. <b>We support till quadrillion</b>
- 'three hundred and forty five' --> '345'
- 'five thousand three hundred and forty five' --> '5345'
- 'sixty five thousand and twenty two' --> '65022'
- 'one hundred thousand and sixty --> '100060'
- 'ten million seventy thousand' --> '10070000'
- 'one billion' --> '1000000000'
- 'ten billion' --> '10000000000'
- 'hundred billion' --> '100000000000'
- 'thousand billion' --> '1000000000000'
- 'one trillion' --> '1000000000000'
- 'ten trillion' --> '10000000000000'
- 'hundred trillion' --> '100000000000000'
- 'thousand trillion' --> '1000000000000000'
- 'one quadrillion' --> '1000000000000000'
- 'ten quadrillion' --> '10000000000000000'
- 'hundred quadrillion' --> '100000000000000000'
- 'thousand quadrillion' --> '1000000000000000000'
- 'That will be thousand Rs sir.' --> 'That will be 1000 Rs sir'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'five thousand three hundred and forty five'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Indian numbering system
<b>Want support for large numbers in Indian scale?</b> Sure, you have it. <b>We support till arab</b>
- 'one lakh sixty thousand three hundred and twelve' --> '160312'
- 'ten lakh thirty thousand' --> '1030000'
- 'hundred lakh five thousand' --> '10005000'
- 'thousand lakh' --> '100000000'
- 'one crore two lakh thirty thousand' --> '10230000'
- 'ten crore' --> '100000000'
- 'hundred crore' --> '1000000000'
- 'thousand crore' --> '10000000000'
- 'one arab' --> '1000000000'
- 'ten arab' --> '10000000000'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'one crore two lakh thirty thousand'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Convert ordinals
<b>Looking for a way to convert ordinal numbers?</b> Sure, you have it.
- 'His inauguration took place on January twentieth, which marked the fifty ninth quadrennial presidential inauguration.' --> 'His inauguration took place on January 20th, which marked the 59th quadrennial presidential inauguration.'
- 'Despite the challenges, the fifty ninth presidential inauguration was a historic moment for the country.' --> 'Despite the challenges, the 59th presidential inauguration was a historic moment for the country.'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'Despite the challenges, the fifty ninth presidential inauguration was a historic moment for the country.'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Dates and Years
<b>Looking to manipulate dates and years?</b> You're in the right place!
- 'He was elected in November twenty twenty after defeating other contenders' --> 'He was elected in November 2020 after defeating other contenders'
- 'I was born on first September nineteen ninety five' --> 'I was born on 1st September 1995'
- 'I was born in two thousand and five and I an twenty five years old' --> 'I was born in 2005 and I an 25 years old'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'I was born in two thousand and five and I an twenty five years old'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario)
print(result)
```
- #### Operator Conversion
<b>Interested in converting operators for your programming needs? Want to display them on UI?</b> Let's dive in!
- <b>plus</b>
- 'three plus five' --> '3+5'
- <b>minus</b>
- 'three minus five' --> '3-5'
- <b>multiply</b>
- 'multiply five by six' --> '5*6'
- 'five multiplied by six' --> '5*6'
- <b>divide</b>
- 'five divided by six' --> '5/6'
- 'divide five by six' --> '5/6'
- <b>equals</b>
- 'five is equal to five' --> '5=5'
- 'five equals to five' --> '5=5'
- 'five equal to five' --> '5=5'
- 'five equal five' --> '5=5'
- 'five equals five' --> '5=5'
- <b>not equal</b>
- 'four is not equal to five' --> '4≠5'
- 'four is not equal five' --> '4≠5'
- 'four is not equals five' --> '4≠5'
- 'four not equal to five' --> '4≠5'
- <b>less than</b>
- 'three is less than seven' --> '3<7'
- 'three less than seven' --> '3<7'
- <b>greater than</b>
- 'seven is greater than six' --> '7>6'
- 'seven greater than six' --> '7>6'
- <b>less than equal to</b>
- 'three is less than or equals to three' --> '3≤3'
- 'three is less than or equal to three' --> '3≤3'
- 'three is less than equals to three' --> '3≤3'
- 'three is less than equal to three' --> '3≤3'
- 'three less than equals to three' --> '3≤3'
- 'three less than equal to three' --> '3≤3'
- <b>greater than equal to</b>
- 'three is greater than or equals to three' --> '3≥3'
- 'three is greater than or equal to three' --> '3≥3'
- 'three is greater than equals to three' --> '3≥3'
- 'three is greater than equal to three' --> '3≥3'
- 'three greater than equals to three' --> '3≥3'
- 'three greater than equal to three' --> '3≥3'
- <b>square root of</b>
- 'square root of seven' --> '√7'
- <b>square of</b>
- 'square of seven' --> '7 ²'
- <b>percent</b>
- 'ninety five percent' --> '95%'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'ninety five percent'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario, convert_operator=True)
print(result)
```
- #### Operators not with digits?
<b>Worried what will happen to operators if they are not with digits?</b> Sure, we will take care of your input
- 'Oxygen plus Hydrogen equals water' --> 'Oxygen plus Hydrogen equals water'
- <b>Note:</b> We make sure to convert operators when you have digits with them
- #### Decimal numbers
<b>Want to convert decimal numbers?</b> Sure, why not we support it
- 'two point five equals two point five' --> '2.5=2.5'
- 'two point five' --> '2.5'
- 'The temperature outside is twenty five point five degrees Celsius.' --> 'The temperature outside is 25.5 degrees Celsius.'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'The temperature outside is twenty five point five degrees Celsius.'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario, convert_operator=True)
print(result)
```
- #### Have your own evaluate function?
<b>Want to convert operators so that you can pass it to your own evaluate function?</b> Sure, we support it
- 'four is not equal to five' --> '4!=5'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'four is not equal to five'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True)
print(result)
```
- #### Expression Evaluation
<b>Need to evaluate expressions?</b> We'll show you the way.
- 'one point five plus zero point five' --> '2.0'
- 'fifty percent of thousand' --> '500.0'
- 'twenty-five percent of two hundred equals fifty' --> 'True'
- 'three plus square of five' --> '28'
- 'square root of four multiplied by square root of one plus six is equal to square root of twenty-five multiplied by three' --> 'False'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'three plus square of five'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True, evaluate=True)
print(result)
```
- #### Numeric Calculation in Text
<b>Expressions along with different text?</b> We'll show you the way.
- 'Hey calculate three plus five' --> '8'
- 'Hey calculate 3+5' --> '8'
- <b>How to use? </b>
- ```
from numwords_to_nums.numwords_to_nums import NumWordsToNum
scenario = 'Hey calculate three plus five'
num = NumWordsToNum()
result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True, evaluate=True)
print(result)
```
- #### Handle all patterns at same time
<b>Sure you can do that.</b> Just go through above examples and you will get the idea
## Improvements or Issues
- Complex arithmetic operations.
- Please email us if you find any issues.
## License
- MIT License
## Contact
- Please mail us if you have any issues.
- Make sure to put subject as --> <b>Improvements for python library</b>
## Acknowledgements
I have heavily used code from the SO answers from here: https://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers
and improved upon them
Raw data
{
"_id": null,
"home_page": "",
"name": "numwords-to-nums",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "text2numbers,words2numbers,digits,numbers,ordinal numbers,converter,text to digits,words to numbers",
"author": "Sarthak, Arpit",
"author_email": "Sarthak <sarthak6jan16@gmail.com>, Arpit <joshia296@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/91/8c/c127be8b28baeada602a11b1e3cd17a6046c291f7ca1fb0cfde8feaaccf0/numwords_to_nums-1.2.0.tar.gz",
"platform": null,
"description": "# numwords_to_nums: \n - numwords_to_nums not only handles a wide range of numeric conversions, including large numbers and Indian numbering systems but also ensures that it maintains the integrity of your input string.\n - It won't alter punctuation marks like full stops, capitalization of characters, word order in sentences, or sentence arrangement.\n - You can trust that it will provide you with your exact input string while making only the necessary conversions.\n - <b>Exception</b> : evaluate() method or evaluation mode as they return evaluation of mathematical expression found in your text.\n - Large number support till quadrillion and Indian scale support till arab so no need to worry about large numbers.\n - I find this useful when I've transcribed audio into text and need to seamlessly transform that textual data into numerical digits, mathematical operators, and ultimately, evaluate complex numerical expressions.\n\n<!-- TABLE OF CONTENTS -->\n<details>\n <summary>Table of Contents</summary>\n <ol>\n <li>\n <a href=\"#installation\">Installation</a>\n </li>\n <li><a href=\"#prerequisites\">Prerequisites</a></li>\n <li>\n <a href=\"#usage\">Usage</a>\n <ul>\n <li><a href=\"#method-overview\">Method overview</a></li>\n <ul>\n <li><a href=\"#numerical_words_to_numbers\">numerical_words_to_numbers()</a></li>\n <li><a href=\"#evaluate\">evaluate()</a></li>\n </ul>\n </ul>\n </li>\n <li><a href=\"#examples\">Examples</a>\n <ul>\n <li><a href=\"#sentence-without-any-conversion\">Sentence without any conversion</a></li>\n <li><a href=\"#convert-digits-from-a-random-sentence\">Convert digits from a random sentence</a></li>\n <li><a href=\"#large-numbers\">Large numbers</a></li>\n <li><a href=\"#indian-numbering-system\">Indian numbering system</a></li>\n <li><a href=\"#convert-ordinals\">Convert ordinals</a></li>\n <li><a href=\"#dates-and-years\">Dates and Years</a></li>\n <li><a href=\"#operator-conversion\">Operator Conversion</a></li>\n <li><a href=\"#operator-not-with-digits\">Operator not with digits?</a></li>\n <li><a href=\"#decimal-numbers\">Decimal numbers</a></li>\n <li><a href=\"#have-your-own-evaluate-function\">Have your own evaluate function?</a></li>\n <li><a href=\"#expression-evaluation\">Expression Evaluation</a></li>\n <li><a href=\"#numeric-calculation-in-text\">Numeric Calculation in Text</a></li>\n <li><a href=\"#handle-all-patterns-at-same-time\">Handle all patterns at same time</a></li>\n </ul>\n </li>\n <li><a href=\"#improvements-or-issues\">Improvements or Issues</a></li>\n <li><a href=\"#license\">License</a></li>\n <li><a href=\"#contact\">Contact</a></li>\n <li><a href=\"#acknowledgments\">Acknowledgments</a></li>\n </ol>\n</details>\n\n\n## Installation\n```\npip3 install numwords_to_nums\n```\n\n## Prerequisites\n- Python 3 or later\n\n## Usage\n1) Import the NumWordsToNum class\n ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n ```\n2) Initialize the NumWordsToNum object\n ```\n num = NumWordsToNum()\n ```\n3) Select one of the below method based on your requirement\n - numerical_words_to_numbers()\n - evaluate()\n\n4) Here's a <b>basic example</b>\n ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n num = NumWordsToNum()\n \n result = num.numerical_words_to_numbers(\"twenty ten and twenty one\")\n print(result) # Output: 2010 and 21\n \n eval_result = num.evaluate('Hey calculate 2+5')\n print(eval_result) # Output: 7\n ```\n\n### Method overview\n\n- #### numerical_words_to_numbers()\n\n ```\n numerical_words_to_numbers(text, convert_operator=False, calculate_mode=False, evaluate=False)\n ```\n \n - Converts numerical words in the input text to their corresponding numeric digits. Optionally, it can also handle mathematical operator words and perform calculations.\n\n - <b>Parameters: </b>\n - <b>text (str)</b>: The input text containing numerical words to be converted.\n - <b>convert_operator (bool, optional)</b>: If True, converts operator words like \"plus,\" \"minus,\" etc., to their corresponding mathematical symbols (+, -, etc.). Use to display operators on UI or for user. Default is False.\n - <b>calculate_mode (bool, optional)</b>: If True, activates the calculation mode, allowing mathematical operations to be performed later on if required, using converted numerical words and operators. Default is False\n - <b>evaluate (bool, optional)</b>: If True, evaluates the mathematical expression in the text when in calculate_mode. Raises an exception if calculate_mode is not enabled. Default is False.\n\n - <b>Returns: </b>\n - <b>str</b>: The input text with numerical words and optionally operators converted to their numeric equivalents. If calculate_mode is enabled and evaluate is True, it returns the result of the mathematical expression. \n\n - <b>Raises:</b>\n - <b>Exception</b>: If convert_operator is set to False when calculate_mode is True, as operator conversion is required\n for calculation.\n - <b>Exception</b>: If evaluate is True but calculate_mode is not enabled, as calculation mode is necessary for evaluation.\n\n- #### evaluate()\n\n ```\n evaluate()\n ```\n - Evaluates a mathematical expression represented as a string.\n - This method takes an input string containing a mathematical expression, cleans it by removing non-numeric and non-mathematical characters,\n and then attempts to evaluate the expression.\n - If the evaluation is successful, it returns the result as a string.\n - If an evaluation error occurs, it returns an error message indicating that the answer is undefined along with the\n specific evaluation error.\n\n - <b>Args</b>:\n - <b>str</b>: The input string containing a mathematical expression to be evaluated.\n\n - <b>Returns</b>:\n - <b>str</b>: The result of the mathematical expression as a string if evaluation is successful. If an error occurs\n during evaluation, it returns an error message with details of the error.\n\n - <b>Example</b>:\n - Input : '2 + 3 * 4' --> Output: '14'\n - Input : '10 / 0' --> Output: ' The answer is undefined. Evaluation error: division by zero'.\n\n\n## Examples\n\n- #### Sentence without any conversion\n <b>What happens if you feed a string which has no digits, ordinals or operators to be converted?</b> Well we don't touch it\n - 'This is just a random sentence.' --> 'This is just a random sentence.'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'This is just a random sentence.'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Convert digits from a random sentence\n <b>Want to convert just the digits from your sentence?</b> It's possible now. Here are a few <b>examples</b>\n - 'I am twenty five years old and my dad is fifty years old. I would like to get my father two cars!' --> 'I am 25 years old and my dad is 50 years old. I would like to get my father 2 cars!'\n - 'Joe Biden became the oldest person to assume the presidency at the age of seventy eight.' --> 'Joe Biden became the oldest person to assume the presidency at the age of 78.'\n - 'The event was held at the U.S. Capitol in Washington, D.C., and was attended by a limited number of people due to the COVID-nineteen pandemic.' --> 'The event was held at the U.S. Capitol in Washington, D.C., and was attended by a limited number of people due to the COVID-19 pandemic.'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'Joe Biden became the oldest person to assume the presidency at the age of seventy eight.'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Large numbers\n <b>Want support for large numbers?</b> Sure, we will support you. <b>We support till quadrillion</b>\n - 'three hundred and forty five' --> '345'\n - 'five thousand three hundred and forty five' --> '5345'\n - 'sixty five thousand and twenty two' --> '65022'\n - 'one hundred thousand and sixty --> '100060'\n - 'ten million seventy thousand' --> '10070000'\n - 'one billion' --> '1000000000'\n - 'ten billion' --> '10000000000'\n - 'hundred billion' --> '100000000000'\n - 'thousand billion' --> '1000000000000'\n - 'one trillion' --> '1000000000000'\n - 'ten trillion' --> '10000000000000'\n - 'hundred trillion' --> '100000000000000'\n - 'thousand trillion' --> '1000000000000000'\n - 'one quadrillion' --> '1000000000000000'\n - 'ten quadrillion' --> '10000000000000000'\n - 'hundred quadrillion' --> '100000000000000000'\n - 'thousand quadrillion' --> '1000000000000000000'\n - 'That will be thousand Rs sir.' --> 'That will be 1000 Rs sir'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'five thousand three hundred and forty five'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Indian numbering system\n <b>Want support for large numbers in Indian scale?</b> Sure, you have it. <b>We support till arab</b>\n - 'one lakh sixty thousand three hundred and twelve' --> '160312'\n - 'ten lakh thirty thousand' --> '1030000'\n - 'hundred lakh five thousand' --> '10005000'\n - 'thousand lakh' --> '100000000'\n - 'one crore two lakh thirty thousand' --> '10230000'\n - 'ten crore' --> '100000000'\n - 'hundred crore' --> '1000000000'\n - 'thousand crore' --> '10000000000'\n - 'one arab' --> '1000000000'\n - 'ten arab' --> '10000000000' \n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'one crore two lakh thirty thousand'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Convert ordinals\n <b>Looking for a way to convert ordinal numbers?</b> Sure, you have it.\n - 'His inauguration took place on January twentieth, which marked the fifty ninth quadrennial presidential inauguration.' --> 'His inauguration took place on January 20th, which marked the 59th quadrennial presidential inauguration.'\n - 'Despite the challenges, the fifty ninth presidential inauguration was a historic moment for the country.' --> 'Despite the challenges, the 59th presidential inauguration was a historic moment for the country.'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'Despite the challenges, the fifty ninth presidential inauguration was a historic moment for the country.'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Dates and Years\n <b>Looking to manipulate dates and years?</b> You're in the right place!\n - 'He was elected in November twenty twenty after defeating other contenders' --> 'He was elected in November 2020 after defeating other contenders'\n - 'I was born on first September nineteen ninety five' --> 'I was born on 1st September 1995'\n - 'I was born in two thousand and five and I an twenty five years old' --> 'I was born in 2005 and I an 25 years old'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'I was born in two thousand and five and I an twenty five years old'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario)\n print(result)\n ```\n\n- #### Operator Conversion\n <b>Interested in converting operators for your programming needs? Want to display them on UI?</b> Let's dive in!\n - <b>plus</b>\n - 'three plus five' --> '3+5'\n - <b>minus</b>\n - 'three minus five' --> '3-5'\n - <b>multiply</b>\n - 'multiply five by six' --> '5*6'\n - 'five multiplied by six' --> '5*6'\n - <b>divide</b>\n - 'five divided by six' --> '5/6'\n - 'divide five by six' --> '5/6'\n - <b>equals</b>\n - 'five is equal to five' --> '5=5'\n - 'five equals to five' --> '5=5'\n - 'five equal to five' --> '5=5'\n - 'five equal five' --> '5=5'\n - 'five equals five' --> '5=5'\n - <b>not equal</b>\n - 'four is not equal to five' --> '4\u22605'\n - 'four is not equal five' --> '4\u22605'\n - 'four is not equals five' --> '4\u22605'\n - 'four not equal to five' --> '4\u22605'\n - <b>less than</b>\n - 'three is less than seven' --> '3<7'\n - 'three less than seven' --> '3<7'\n - <b>greater than</b>\n - 'seven is greater than six' --> '7>6'\n - 'seven greater than six' --> '7>6'\n - <b>less than equal to</b>\n - 'three is less than or equals to three' --> '3\u22643'\n - 'three is less than or equal to three' --> '3\u22643'\n - 'three is less than equals to three' --> '3\u22643'\n - 'three is less than equal to three' --> '3\u22643'\n - 'three less than equals to three' --> '3\u22643'\n - 'three less than equal to three' --> '3\u22643'\n - <b>greater than equal to</b>\n - 'three is greater than or equals to three' --> '3\u22653'\n - 'three is greater than or equal to three' --> '3\u22653'\n - 'three is greater than equals to three' --> '3\u22653'\n - 'three is greater than equal to three' --> '3\u22653'\n - 'three greater than equals to three' --> '3\u22653'\n - 'three greater than equal to three' --> '3\u22653'\n - <b>square root of</b>\n - 'square root of seven' --> '\u221a7'\n - <b>square of</b>\n - 'square of seven' --> '7 \u00b2'\n - <b>percent</b>\n - 'ninety five percent' --> '95%'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'ninety five percent'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario, convert_operator=True)\n print(result)\n ```\n\n- #### Operators not with digits?\n <b>Worried what will happen to operators if they are not with digits?</b> Sure, we will take care of your input\n - 'Oxygen plus Hydrogen equals water' --> 'Oxygen plus Hydrogen equals water'\n - <b>Note:</b> We make sure to convert operators when you have digits with them\n\n \n\n- #### Decimal numbers\n <b>Want to convert decimal numbers?</b> Sure, why not we support it\n - 'two point five equals two point five' --> '2.5=2.5'\n - 'two point five' --> '2.5'\n - 'The temperature outside is twenty five point five degrees Celsius.' --> 'The temperature outside is 25.5 degrees Celsius.'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'The temperature outside is twenty five point five degrees Celsius.'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario, convert_operator=True)\n print(result)\n ```\n \n- #### Have your own evaluate function?\n <b>Want to convert operators so that you can pass it to your own evaluate function?</b> Sure, we support it\n - 'four is not equal to five' --> '4!=5'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'four is not equal to five'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True)\n print(result)\n ```\n- #### Expression Evaluation\n <b>Need to evaluate expressions?</b> We'll show you the way.\n - 'one point five plus zero point five' --> '2.0'\n - 'fifty percent of thousand' --> '500.0'\n - 'twenty-five percent of two hundred equals fifty' --> 'True'\n - 'three plus square of five' --> '28'\n - 'square root of four multiplied by square root of one plus six is equal to square root of twenty-five multiplied by three' --> 'False'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'three plus square of five'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True, evaluate=True)\n print(result)\n ```\n\n- #### Numeric Calculation in Text\n <b>Expressions along with different text?</b> We'll show you the way.\n - 'Hey calculate three plus five' --> '8'\n - 'Hey calculate 3+5' --> '8'\n - <b>How to use? </b>\n - ```\n from numwords_to_nums.numwords_to_nums import NumWordsToNum\n scenario = 'Hey calculate three plus five'\n num = NumWordsToNum()\n result = num.numerical_words_to_numbers(scenario, convert_operator=True, calculate_mode=True, evaluate=True)\n print(result)\n ```\n- #### Handle all patterns at same time\n <b>Sure you can do that.</b> Just go through above examples and you will get the idea\n\n\n## Improvements or Issues\n- Complex arithmetic operations.\n- Please email us if you find any issues.\n\n## License\n- MIT License\n\n## Contact\n- Please mail us if you have any issues.\n- Make sure to put subject as --> <b>Improvements for python library</b>\n\n## Acknowledgements\nI have heavily used code from the SO answers from here: https://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers\nand improved upon them\n",
"bugtrack_url": null,
"license": "",
"summary": "Python library for converting numerical words (textual numbers) to numbers",
"version": "1.2.0",
"project_urls": null,
"split_keywords": [
"text2numbers",
"words2numbers",
"digits",
"numbers",
"ordinal numbers",
"converter",
"text to digits",
"words to numbers"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "de35d694e61ea033b36efef3f84edf362b8cbc551c4ef0e7f9806918ce83253d",
"md5": "e08353135bbb87636a35654f331aa1f7",
"sha256": "8245b1dc3c1b8475b4c4c2e3b22681f4e12104cb92ec7bd026423afeb6744c02"
},
"downloads": -1,
"filename": "numwords_to_nums-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e08353135bbb87636a35654f331aa1f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 18030,
"upload_time": "2023-09-23T12:14:39",
"upload_time_iso_8601": "2023-09-23T12:14:39.912989Z",
"url": "https://files.pythonhosted.org/packages/de/35/d694e61ea033b36efef3f84edf362b8cbc551c4ef0e7f9806918ce83253d/numwords_to_nums-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "918cc127be8b28baeada602a11b1e3cd17a6046c291f7ca1fb0cfde8feaaccf0",
"md5": "7bcb78a778790a0f11cc2b9450d9b31c",
"sha256": "dbf2b70fc32c56b856869a9746503e0aff811051fadbcf25b3df488b348ec40d"
},
"downloads": -1,
"filename": "numwords_to_nums-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "7bcb78a778790a0f11cc2b9450d9b31c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20307,
"upload_time": "2023-09-23T12:14:45",
"upload_time_iso_8601": "2023-09-23T12:14:45.397681Z",
"url": "https://files.pythonhosted.org/packages/91/8c/c127be8b28baeada602a11b1e3cd17a6046c291f7ca1fb0cfde8feaaccf0/numwords_to_nums-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-23 12:14:45",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "numwords-to-nums"
}