-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments.py
49 lines (45 loc) · 1.54 KB
/
experiments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from dslparser import parse, printer
from stringdsl import stringdsl
from bustle import bustle, propertySignatureSize
import stringprogs
from stringprops import llProps
from model import Rater, loadModel
import torch
from absl import app
from absl import flags
from absl import logging
WITH_ML = flags.DEFINE_boolean('ml', True, 'use ML')
def main(_):
with_ml = WITH_ML.value
sl = stringdsl
#prog = stringprogs.stringprogs[1]
#prog = 'IF(EXACT(LEFT(var_0, 1), "-"), var_0, CONCATENATE("+", var_0))'
prog = 'CONCATENATE("+", var_0)'
prog = 'IF(EXACT(var_0, "-"), var_0, CONCATENATE("+", var_0))'
prog = 'IF(EXACT(var_0, "-"), "-", "+")'
prog = 'IF(EXACT(var_0, "-"), var_0, CONCATENATE("+", var_0))'
prog = 'IF(EXACT(LEFT(var_0, 1), "-"), var_0, CONCATENATE("+", var_0))'
#prog = 'Concatenate(Left("+", Minus(0, Find("-", var_0))), var_0)'
#prog = 'Concatenate(Replace("+", Find("-", var_0), 1, ""), var_0)'
ast = parse(sl, prog)
#I = [stringprogs.input]
I = [["1", "2.0", "hello", "-1", "-1.0", "-", "hello-you"]]
O = sl.evalIO(ast, I)
str2 = ("str", ("str",))
MsInit = {
(("str",), "str", "str"): Rater(
2 * propertySignatureSize(("str",), "str", llProps)
)
}
MsTrained = loadModel()
if with_ml:
Ms = MsTrained
llp = llProps
else:
Ms = None
llp = None
ast_found = bustle(sl, str2, I, O, llp, Ms, print_stats=True)
prog_found = printer(sl, ast_found)
print(prog_found)
if __name__ == '__main__':
app.run(main)