#!/usr/bin/env python3 def number(Model): prods = [] number_expand_arg1 = Model.productionstring( name="number_expand_arg1", string=""" =g> isa math_goal op expand arg1 =num ones1 None expand_slot None ?retrieval> state free buffer empty ==> =g> isa math_goal expand_slot arg1 +retrieval> isa number number =num """ ) prods.append(number_expand_arg1) number_expand_arg1_done = Model.productionstring( name="number_expand_arg1_done", reward=100, string=""" =g> isa math_goal op expand expand_slot arg1 arg1 =num =retrieval> isa number number =num ones =one tens =ten hundreds =hun ==> =g> isa math_goal expand_slot arg2 ones1 =one tens1 =ten hundreds1 =hun ~retrieval> """ ) prods.append(number_expand_arg1_done) # number_expand_arg1_fail = Model.productionstring( # name="number_expand_arg1_fail", # # reward=-100, # string=""" # =g> # isa math_goal # op expand # ones1 None # expand_slot arg1 # ?retrieval> # state error # ==> # =g> # isa math_goal # expand_slot None # ~retrieval> # """ # ) # prods.append(number_expand_arg1_fail) number_expand_arg2 = Model.productionstring( name="number_expand_arg2", string=""" =g> isa math_goal op expand arg2 =num ones2 None expand_slot arg2 ?retrieval> state free buffer empty ==> =g> isa math_goal expand_slot arg2 +retrieval> isa number number =num """ ) prods.append(number_expand_arg2) # number_expand_arg2_fail = Model.productionstring( # name="number_expand_arg2_fail", # # reward=-100, # string=""" # =g> # isa math_goal # op expand # ones2 None # expand_slot arg2 # ?retrieval> # state error # ==> # =g> # isa math_goal # expand_slot None # ~retrieval> # """ # ) # prods.append(number_expand_arg2_fail) number_expand_arg2_done = Model.productionstring( name="number_expand_arg2_done", reward=100, string=""" =g> isa math_goal op expand expand_slot arg2 arg2 =num =retrieval> isa number number =num ones =one tens =ten hundreds =hun ==> =g> isa math_goal op done expand_slot None ones2 =one tens2 =ten hundreds2 =hun ~retrieval> """ ) prods.append(number_expand_arg2_done) number_expand_done = Model.productionstring( name="number_expand_done", reward=100, string=""" =g> isa math_goal op expand expand_slot None ones1 ~None tens1 ~None hundreds1 ~None ones2 ~None tens2 ~None hundreds2 ~None ==> =g> isa math_goal op done """ ) number_contract_result = Model.productionstring( name="number_contract_result", string=""" =g> isa math_goal result None ones_ans ~None tens_ans ~None hundreds_ans ~None hundreds_ans ~busy ones_ans =ones tens_ans =tens hundreds_ans =hunds ?retrieval> buffer empty state free ==> =g> isa math_goal expand_slot result +retrieval> isa number ones =ones tens =tens hundreds =hunds """ ) prods.append(number_contract_result) number_contract_result_done = Model.productionstring( name="number_contract_result_done", reward=100, string=""" =g> isa math_goal expand_slot result result None ones_ans =ones tens_ans =tens hundreds_ans =hundreds =retrieval> isa number number =num ones =ones tens =tens hundreds =hundreds ==> =g> isa math_goal result =num expand_slot None ~retrieval> """ ) prods.append(number_contract_result_done) return prods