You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a Python module to convert number words (eg. veintiuno) to numeric digits (21). It works for positive numbers upto the range of 999,999,999,999 (i.e. billions).
7
+
8
+
++++++++++++
9
+
Installation
10
+
++++++++++++
11
+
Please ensure that you have **updated pip** to the latest version before installing word2number_es.
12
+
13
+
You can install the module using Python Package Index using the below command.
14
+
15
+
.. code-block:: python
16
+
17
+
pip install word2number_es
18
+
19
+
Make sure you install all requirements given in requirements.txt
20
+
21
+
.. code-block:: python
22
+
23
+
pip install -r requirements.txt
24
+
25
+
+++++
26
+
Usage
27
+
+++++
28
+
First you have to import the module using the below code.
29
+
.. code-block:: python
30
+
31
+
from word2number_es import w2n
32
+
33
+
Then you can use the **word_to_num** method to convert a number-word to numeric digits, as shown below.
34
+
35
+
.. code-block:: python
36
+
37
+
>>>print(w2n.word_to_num('dos punto tres'))
38
+
2.3
39
+
40
+
>>>print(w2n.word_to_num('112'))
41
+
112
42
+
43
+
>>>print(w2n.word_to_num('punto cinco'))
44
+
0.5
45
+
46
+
>>>print(w2n.word_to_num('dosmil veintitres'))
47
+
2023
48
+
49
+
>>>print(w2n.word_to_num('millon millon'))
50
+
Error: Redundant number! Please enter a valid number word (eg. two million twenty three thousand and forty nine)
51
+
None
52
+
53
+
>>>print(w2n.word_to_num('blah'))
54
+
Error: No valid number words found! Please enter a valid number word (eg. two million twenty three thousand and forty nine)
55
+
None
56
+
57
+
You can also use the **numwords_in_sentence** to convert all number words in a sentence to numeric digits, as shown below.
58
+
59
+
.. code-block:: python
60
+
61
+
>>>print(w2n.numwords_in_sentence("el reloj me costo diez mil pesos"))
62
+
el reloj me costo 10000 pesos
63
+
64
+
++++++++++++
65
+
Contributors
66
+
++++++++++++
67
+
- Ben Batorsky (`bpben <https://github.com/bpben>`__)
68
+
- Alex (`ledovsky <https://github.com/ledovsky>`__)
69
+
- Tal Yarkoni (`tyarkoni <https://github.com/tyarkoni>`__)
0 commit comments