fuzzy-dl-owl2 1.0.1__py3-none-any.whl → 1.0.3__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.
- fuzzy_dl_owl2/fuzzydl/concept/approximation_concept.py +35 -10
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/triangular_fuzzy_number.py +2 -1
- fuzzy_dl_owl2/fuzzydl/concept/concrete/trapezoidal_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/implies_concept.py +14 -11
- fuzzy_dl_owl2/fuzzydl/concept/operator_concept.py +10 -6
- fuzzy_dl_owl2/fuzzydl/concept/value_concept.py +1 -1
- fuzzy_dl_owl2/fuzzydl/concrete_feature.py +7 -1
- fuzzy_dl_owl2/fuzzydl/feature_function.py +16 -2
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +1 -1
- fuzzy_dl_owl2/fuzzydl/knowledge_base.py +494 -358
- fuzzy_dl_owl2/fuzzydl/milp/expression.py +4 -2
- fuzzy_dl_owl2/fuzzydl/milp/milp_helper.py +3 -2
- fuzzy_dl_owl2/fuzzydl/milp/variable.py +3 -0
- fuzzy_dl_owl2/fuzzydl/modifier/triangular_modifier.py +1 -1
- fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +1465 -1210
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/mom_defuzzify_query.py +14 -7
- fuzzy_dl_owl2/fuzzydl/query/min/min_subsumes_query.py +2 -2
- fuzzy_dl_owl2/fuzzydl/util/config_reader.py +0 -6
- fuzzy_dl_owl2/fuzzydl/util/constants.py +10 -9
- fuzzy_dl_owl2/fuzzydl/util/utils.py +48 -7
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2.py +1 -1
- {fuzzy_dl_owl2-1.0.1.dist-info → fuzzy_dl_owl2-1.0.3.dist-info}/METADATA +51 -10
- {fuzzy_dl_owl2-1.0.1.dist-info → fuzzy_dl_owl2-1.0.3.dist-info}/RECORD +25 -31
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2_java.py +0 -953
- fuzzy_dl_owl2/fuzzydl/parser/ParserConstants.py +0 -406
- fuzzy_dl_owl2/fuzzydl/parser/ebnf.lark +0 -290
- fuzzy_dl_owl2/fuzzydl/parser/larkx.py +0 -70
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_java.py +0 -1409
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_to_fuzzydl_java.py +0 -956
- {fuzzy_dl_owl2-1.0.1.dist-info → fuzzy_dl_owl2-1.0.3.dist-info}/LICENSE +0 -0
- {fuzzy_dl_owl2-1.0.1.dist-info → fuzzy_dl_owl2-1.0.3.dist-info}/WHEEL +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
from lark import Lark, Transformer, v_args
|
|
2
|
-
|
|
3
|
-
calc_grammar = """
|
|
4
|
-
?start: sum
|
|
5
|
-
| NAME "=" sum -> assign_var
|
|
6
|
-
|
|
7
|
-
?sum: product
|
|
8
|
-
| sum "+" product -> add
|
|
9
|
-
| sum "-" product -> sub
|
|
10
|
-
|
|
11
|
-
?product: atom
|
|
12
|
-
| product "*" atom -> mul
|
|
13
|
-
| product "/" atom -> div
|
|
14
|
-
|
|
15
|
-
?atom: NUMBER -> number
|
|
16
|
-
| "-" atom -> neg
|
|
17
|
-
| NAME -> var
|
|
18
|
-
| "(" sum ")"
|
|
19
|
-
|
|
20
|
-
%import common.CNAME -> NAME
|
|
21
|
-
%import common.NUMBER
|
|
22
|
-
%import common.WS_INLINE
|
|
23
|
-
|
|
24
|
-
%ignore WS_INLINE
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@v_args(inline=True) # Affects the signatures of the methods
|
|
29
|
-
class CalculateTree(Transformer):
|
|
30
|
-
from operator import add, mul, neg, sub
|
|
31
|
-
from operator import truediv as div
|
|
32
|
-
|
|
33
|
-
number = float
|
|
34
|
-
|
|
35
|
-
def __init__(self):
|
|
36
|
-
self.vars = {}
|
|
37
|
-
|
|
38
|
-
def assign_var(self, name, value):
|
|
39
|
-
print(name, value)
|
|
40
|
-
self.vars[name] = value
|
|
41
|
-
return value
|
|
42
|
-
|
|
43
|
-
def var(self, name):
|
|
44
|
-
try:
|
|
45
|
-
return self.vars[name]
|
|
46
|
-
except KeyError:
|
|
47
|
-
raise Exception("Variable not found: %s" % name)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
calc_parser = Lark(calc_grammar, parser="lalr", transformer=CalculateTree())
|
|
51
|
-
calc = calc_parser.parse
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def main():
|
|
55
|
-
while True:
|
|
56
|
-
try:
|
|
57
|
-
s = input("> ")
|
|
58
|
-
except EOFError:
|
|
59
|
-
break
|
|
60
|
-
print(calc(s))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test():
|
|
64
|
-
print(calc("a = 1+2"))
|
|
65
|
-
print(calc("1+a*-3"))
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if __name__ == "__main__":
|
|
69
|
-
# test()
|
|
70
|
-
main()
|