eggcalc 1.1.1__py3-none-any.whl
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.
- eggcalc/__init__.py +143 -0
- eggcalc/__main__.py +19 -0
- eggcalc/evaluator.py +2730 -0
- eggcalc/exact/__init__.py +455 -0
- eggcalc/exact/cargo.py +353 -0
- eggcalc/exact/config.py +331 -0
- eggcalc/exact/confusables.py +6588 -0
- eggcalc/exact/diff.py +253 -0
- eggcalc/exact/glob.py +314 -0
- eggcalc/exact/identifier.py +267 -0
- eggcalc/exact/identifier_inspect.py +608 -0
- eggcalc/exact/inspect_prompt.py +540 -0
- eggcalc/exact/markdown.py +403 -0
- eggcalc/exact/measure.py +262 -0
- eggcalc/exact/patch.py +607 -0
- eggcalc/exact/path_tools.py +565 -0
- eggcalc/exact/position.py +496 -0
- eggcalc/exact/primitives.py +702 -0
- eggcalc/exact/shell.py +363 -0
- eggcalc/exact/synthesis.py +1788 -0
- eggcalc/exact/transform.py +689 -0
- eggcalc/exact/unicode_policy.py +812 -0
- eggcalc/exact/unicode_tools.py +303 -0
- eggcalc/exact/validate.py +2793 -0
- eggcalc/exact/version.py +619 -0
- eggcalc/mcp/__init__.py +13 -0
- eggcalc/mcp/schemas.py +3318 -0
- eggcalc/mcp/server.py +1251 -0
- eggcalc/mcp/tools.py +5488 -0
- eggcalc/normalize.py +3062 -0
- eggcalc/units.py +2081 -0
- eggcalc-1.1.1.dist-info/METADATA +903 -0
- eggcalc-1.1.1.dist-info/RECORD +37 -0
- eggcalc-1.1.1.dist-info/WHEEL +5 -0
- eggcalc-1.1.1.dist-info/entry_points.txt +2 -0
- eggcalc-1.1.1.dist-info/licenses/LICENSE +21 -0
- eggcalc-1.1.1.dist-info/top_level.txt +1 -0
eggcalc/__init__.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""
|
|
2
|
+
eggcalc - Natural language math expression calculator.
|
|
3
|
+
|
|
4
|
+
A calculator that accepts natural language expressions and converts them
|
|
5
|
+
to mathematical expressions that can be evaluated.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
python -m eggcalc "five plus two"
|
|
9
|
+
python -m eggcalc "30m + 100ft"
|
|
10
|
+
python -m eggcalc --help
|
|
11
|
+
python -m eggcalc -i # Interactive REPL mode
|
|
12
|
+
|
|
13
|
+
Library usage:
|
|
14
|
+
from eggcalc import evaluate, EvaluationError, UnitValue
|
|
15
|
+
result = evaluate("5 + 3")
|
|
16
|
+
|
|
17
|
+
# For webapps with caching:
|
|
18
|
+
from eggcalc import EggCalcApp
|
|
19
|
+
app = EggCalcApp(cache_size=1024)
|
|
20
|
+
result = app.calculate("five plus two")
|
|
21
|
+
|
|
22
|
+
Note: load_user_config_extended() is not exported as custom number/operator
|
|
23
|
+
words via external config are not officially supported.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from .evaluator import (
|
|
27
|
+
DEFAULT_CACHE_SIZE,
|
|
28
|
+
MAX_EXPONENT,
|
|
29
|
+
MAX_FACTORIAL,
|
|
30
|
+
MAX_NESTING_DEPTH,
|
|
31
|
+
MAX_RESULT_VALUE,
|
|
32
|
+
EvaluationError,
|
|
33
|
+
Memory,
|
|
34
|
+
EggCalcApp,
|
|
35
|
+
TimeoutError,
|
|
36
|
+
clearvars,
|
|
37
|
+
delvar,
|
|
38
|
+
evaluate,
|
|
39
|
+
evaluate_async,
|
|
40
|
+
evaluate_cached,
|
|
41
|
+
evaluate_raw,
|
|
42
|
+
evaluate_with_timeout,
|
|
43
|
+
get_default_evaluator,
|
|
44
|
+
getvar,
|
|
45
|
+
listvars,
|
|
46
|
+
load_user_config,
|
|
47
|
+
memory_add,
|
|
48
|
+
memory_clear,
|
|
49
|
+
memory_list,
|
|
50
|
+
memory_recall,
|
|
51
|
+
memory_store,
|
|
52
|
+
memory_subtract,
|
|
53
|
+
register_constant,
|
|
54
|
+
register_function,
|
|
55
|
+
setvar,
|
|
56
|
+
)
|
|
57
|
+
from .normalize import (
|
|
58
|
+
MAX_INPUT_LENGTH,
|
|
59
|
+
MAX_NESTING_DEPTH,
|
|
60
|
+
NORMALIZE,
|
|
61
|
+
PATTERNS,
|
|
62
|
+
main,
|
|
63
|
+
normalize,
|
|
64
|
+
normalize_expression,
|
|
65
|
+
print_help,
|
|
66
|
+
run,
|
|
67
|
+
)
|
|
68
|
+
from .units import (
|
|
69
|
+
FLOAT_EPSILON,
|
|
70
|
+
UnitValue,
|
|
71
|
+
are_units_compatible,
|
|
72
|
+
get_all_units,
|
|
73
|
+
get_conversion_factor,
|
|
74
|
+
get_unit_category,
|
|
75
|
+
is_unit,
|
|
76
|
+
normalize_unit,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
__version__ = "1.1.1"
|
|
80
|
+
__author__ = "David Bowman"
|
|
81
|
+
|
|
82
|
+
__all__ = [
|
|
83
|
+
# Core evaluation
|
|
84
|
+
"evaluate",
|
|
85
|
+
"evaluate_raw",
|
|
86
|
+
"evaluate_cached",
|
|
87
|
+
"evaluate_async",
|
|
88
|
+
"evaluate_with_timeout",
|
|
89
|
+
# Exceptions
|
|
90
|
+
"EvaluationError",
|
|
91
|
+
"TimeoutError",
|
|
92
|
+
# Types
|
|
93
|
+
"UnitValue",
|
|
94
|
+
"Memory",
|
|
95
|
+
# CLI
|
|
96
|
+
"main",
|
|
97
|
+
"run",
|
|
98
|
+
"normalize",
|
|
99
|
+
"normalize_expression",
|
|
100
|
+
"print_help",
|
|
101
|
+
# Constants
|
|
102
|
+
"NORMALIZE",
|
|
103
|
+
"PATTERNS",
|
|
104
|
+
"MAX_INPUT_LENGTH",
|
|
105
|
+
"MAX_NESTING_DEPTH",
|
|
106
|
+
"MAX_EXPONENT",
|
|
107
|
+
"MAX_FACTORIAL",
|
|
108
|
+
"MAX_RESULT_VALUE",
|
|
109
|
+
"DEFAULT_CACHE_SIZE",
|
|
110
|
+
# Unit utilities
|
|
111
|
+
"normalize_unit",
|
|
112
|
+
"get_conversion_factor",
|
|
113
|
+
"get_all_units",
|
|
114
|
+
"is_unit",
|
|
115
|
+
"get_unit_category",
|
|
116
|
+
"are_units_compatible",
|
|
117
|
+
"FLOAT_EPSILON",
|
|
118
|
+
# Configuration
|
|
119
|
+
"load_user_config",
|
|
120
|
+
"get_default_evaluator",
|
|
121
|
+
"register_constant",
|
|
122
|
+
"register_function",
|
|
123
|
+
# Webapp
|
|
124
|
+
"EggCalcApp",
|
|
125
|
+
# Memory functions
|
|
126
|
+
"memory_store",
|
|
127
|
+
"memory_recall",
|
|
128
|
+
"memory_add",
|
|
129
|
+
"memory_subtract",
|
|
130
|
+
"memory_clear",
|
|
131
|
+
"memory_list",
|
|
132
|
+
# Variable functions
|
|
133
|
+
"setvar",
|
|
134
|
+
"getvar",
|
|
135
|
+
"delvar",
|
|
136
|
+
"listvars",
|
|
137
|
+
"clearvars",
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
import os as _os
|
|
141
|
+
|
|
142
|
+
if not _os.environ.get("EGGCALC_NO_CONFIG", ""):
|
|
143
|
+
load_user_config()
|
eggcalc/__main__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for running eggcalc as a module.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
python -m eggcalc "five plus two"
|
|
6
|
+
python -m eggcalc --help
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
eggcalc_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
14
|
+
if eggcalc_dir not in sys.path:
|
|
15
|
+
sys.path.insert(0, eggcalc_dir)
|
|
16
|
+
|
|
17
|
+
from eggcalc.normalize import main
|
|
18
|
+
|
|
19
|
+
sys.exit(main())
|