numbr 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numbr-1.0.0/PKG-INFO +110 -0
- numbr-1.0.0/README.md +87 -0
- numbr-1.0.0/numbr/__init__.py +37 -0
- numbr-1.0.0/numbr/engine.py +1180 -0
- numbr-1.0.0/numbr.egg-info/PKG-INFO +110 -0
- numbr-1.0.0/numbr.egg-info/SOURCES.txt +8 -0
- numbr-1.0.0/numbr.egg-info/dependency_links.txt +1 -0
- numbr-1.0.0/numbr.egg-info/top_level.txt +1 -0
- numbr-1.0.0/setup.cfg +4 -0
- numbr-1.0.0/setup.py +47 -0
numbr-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: numbr
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A comprehensive Python library for parsing and converting numbers between numeric, word, and ordinal formats.
|
|
5
|
+
Home-page: https://github.com/cedricmoorejr/numbr/tree/v1.0.0
|
|
6
|
+
Author: Cedric Moore Jr.
|
|
7
|
+
Author-email: cedricmoorejunior5@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Requires-Python: >=3.6
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# numbr
|
|
25
|
+
|
|
26
|
+
**numbr** is a Python library designed for parsing and converting numbers written in English. It simplifies working with numbers by converting between spelled-out forms, ordinal forms, and numeric representations.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Key Features
|
|
31
|
+
|
|
32
|
+
- Convert spelled-out cardinal numbers into integers (e.g., `"one hundred twenty-three"` → `123`).
|
|
33
|
+
- Convert integers into their spelled-out English words (e.g., `123` → `"one hundred twenty-three"`).
|
|
34
|
+
- Convert ordinal words to numeric ordinals (e.g., `"twenty-first"` → `"21st"` or `21`).
|
|
35
|
+
- Extract numeric values from text strings.
|
|
36
|
+
- Handle negative numbers, hyphenated numbers, and large numbers (up to quintillions).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install `numbr` using `pip`:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install numbr
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
### Convert Words to Integer
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import numbr
|
|
56
|
+
|
|
57
|
+
print(numbr.wordsToInt("one thousand two hundred thirty-four"))
|
|
58
|
+
# Output: 1234
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Convert Integer to Words
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
print(numbr.intToWords(5678))
|
|
65
|
+
# Output: "five thousand six hundred seventy-eight"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Convert Ordinal Words to Numeric Form
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
print(numbr.ordinalWordsToInt("forty-second"))
|
|
72
|
+
# Output: "42nd"
|
|
73
|
+
|
|
74
|
+
print(numbr.ordinalWordsToInt("forty-second", to_num=True))
|
|
75
|
+
# Output: 42
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Extract Numeric Values from Strings
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
print(numbr.extractNumericValue("I have twenty apples and 13 oranges."))
|
|
82
|
+
# Output: 20
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Terminology
|
|
88
|
+
|
|
89
|
+
- **Cardinal Numbers**: Represent quantity (e.g., "one", "twenty-five", "1,234").
|
|
90
|
+
- **Ordinal Numbers**: Represent position or order (e.g., "first", "twenty-first", "3rd").
|
|
91
|
+
- **Ordinal Suffix**: Letters added to numbers indicating position ("st", "nd", "rd", "th").
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve `numbr`.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Contact
|
|
108
|
+
|
|
109
|
+
For questions or feedback, please open an issue on the project's GitHub repository.
|
|
110
|
+
|
numbr-1.0.0/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# numbr
|
|
2
|
+
|
|
3
|
+
**numbr** is a Python library designed for parsing and converting numbers written in English. It simplifies working with numbers by converting between spelled-out forms, ordinal forms, and numeric representations.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- Convert spelled-out cardinal numbers into integers (e.g., `"one hundred twenty-three"` → `123`).
|
|
10
|
+
- Convert integers into their spelled-out English words (e.g., `123` → `"one hundred twenty-three"`).
|
|
11
|
+
- Convert ordinal words to numeric ordinals (e.g., `"twenty-first"` → `"21st"` or `21`).
|
|
12
|
+
- Extract numeric values from text strings.
|
|
13
|
+
- Handle negative numbers, hyphenated numbers, and large numbers (up to quintillions).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install `numbr` using `pip`:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install numbr
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Usage Examples
|
|
28
|
+
|
|
29
|
+
### Convert Words to Integer
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import numbr
|
|
33
|
+
|
|
34
|
+
print(numbr.wordsToInt("one thousand two hundred thirty-four"))
|
|
35
|
+
# Output: 1234
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Convert Integer to Words
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
print(numbr.intToWords(5678))
|
|
42
|
+
# Output: "five thousand six hundred seventy-eight"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Convert Ordinal Words to Numeric Form
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
print(numbr.ordinalWordsToInt("forty-second"))
|
|
49
|
+
# Output: "42nd"
|
|
50
|
+
|
|
51
|
+
print(numbr.ordinalWordsToInt("forty-second", to_num=True))
|
|
52
|
+
# Output: 42
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Extract Numeric Values from Strings
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
print(numbr.extractNumericValue("I have twenty apples and 13 oranges."))
|
|
59
|
+
# Output: 20
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Terminology
|
|
65
|
+
|
|
66
|
+
- **Cardinal Numbers**: Represent quantity (e.g., "one", "twenty-five", "1,234").
|
|
67
|
+
- **Ordinal Numbers**: Represent position or order (e.g., "first", "twenty-first", "3rd").
|
|
68
|
+
- **Ordinal Suffix**: Letters added to numbers indicating position ("st", "nd", "rd", "th").
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Contributing
|
|
79
|
+
|
|
80
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve `numbr`.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Contact
|
|
85
|
+
|
|
86
|
+
For questions or feedback, please open an issue on the project's GitHub repository.
|
|
87
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from . import engine as __engine
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
# "replaceNumericValue",
|
|
8
|
+
"wordsToInt",
|
|
9
|
+
"ordinalSuffix",
|
|
10
|
+
"intToWords",
|
|
11
|
+
"intToOrdinalWords",
|
|
12
|
+
"stripOrdinalSuffix",
|
|
13
|
+
"ordinalWordsToInt",
|
|
14
|
+
"stringToInt",
|
|
15
|
+
"extractNumericValue",
|
|
16
|
+
"romanToWords",
|
|
17
|
+
"romanToInt",
|
|
18
|
+
"formatDecimal",
|
|
19
|
+
"insertSep",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
# Reference functions using __engine alias
|
|
23
|
+
# replaceNumericValue = __engine.replaceNumericValue
|
|
24
|
+
wordsToInt = __engine.wordsToInt
|
|
25
|
+
ordinalSuffix = __engine.ordinalSuffix
|
|
26
|
+
intToWords = __engine.intToWords
|
|
27
|
+
intToOrdinalWords = __engine.intToOrdinalWords
|
|
28
|
+
stripOrdinalSuffix = __engine.stripOrdinalSuffix
|
|
29
|
+
ordinalWordsToInt = __engine.ordinalWordsToInt
|
|
30
|
+
stringToInt = __engine.stringToInt
|
|
31
|
+
extractNumericValue = __engine.extractNumericValue
|
|
32
|
+
romanToWords = __engine.romanToWords
|
|
33
|
+
romanToInt = __engine.romanToInt
|
|
34
|
+
formatDecimal = __engine.formatDecimal
|
|
35
|
+
insertSep = __engine.insertSep
|
|
36
|
+
|
|
37
|
+
del engine
|