i have set of simple strings, represents dsl:
my_str = ['("word 1" + "word 2") * "word 3"', '("word 1" + "word 2") * ("word 3" + "word 4")', '(("word 1" + "word 2") * ("word 3" + "word 4")) * "word 5"', ]
i trying (and failing badly) change these more straight forward form such
a = foo(my_str) a= [ '("word 1" * "word 3") + ("word 2" * "word 3")', '("word 1" * "word 3") + ("word 1" * "word 4") + ("word 2" * "word 3") + ("word 2" * "word 4")', '("word 1" * "word 3" * "word 5") + ("word 1" * "word 4" * "word 5") + ("word 2" * "word 3" * "word 5") + ("word 2" * "word 4" * "word 5")', ]
may simple can't seem head around logic.
ok in end used combination of sympy , pyparsing. used pyparsing understand relationships , hierarchies between variables, , sympy create , expand expression.
some 1 interested in bit over-done code can have @ gist here.
Comments
Post a Comment