Calculator App understands a set of natural language phrases so you don’t have to remember operator syntax for common operations. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Seaus-tech/Calculator-App/llms.txt
Use this file to discover all available pages before exploring further.
parse_natural_language() function in parser.py processes input before it reaches the evaluator, converting phrases into standard Python-compatible expressions.
How It Works
Before any evaluation takes place, the raw input string is:- Converted to lowercase.
- Scanned by a series of regex substitutions that replace recognised phrases with their mathematical equivalents.
- Passed on to the rest of the pipeline (fraction parser, variable substitution,
eval).
Supported Patterns
- squared
- cubed
- sqrt of / square root of
- sqrt {N}
Pattern:
Regex:
{N} squaredRegex:
(\d+(?:\.\d+)?)\s*squared → (\1)**2All Patterns at a Glance
| Phrase | Converts to | Example input | Result |
|---|---|---|---|
{N} squared | ({N})**2 | 9 squared | 81 |
{N} cubed | ({N})**3 | 5 cubed | 125 |
sqrt of {N} | sqrt({N}) | sqrt of 16 | 4.0 |
square root of {N} | sqrt({N}) | square root of 25 | 5.0 |
sqrt {N} | sqrt({N}) | sqrt 16 | 4.0 |
Source Code
Combining with Other Expressions
Natural language phrases are converted before evaluation, so they compose freely with other operators and expressions. For example,
sqrt of 9 + 9 squared is parsed to sqrt(9) + (9)**2 and evaluates to 84.0.