INNER CODE UNIT · Python
process_str
princeton-nlp/WebShop · transfer/app.py:28
def process_str(s):
s = s.lower().replace('"', '').replace("'", "").strip()
s = s.replace('[sep]', '[SEP]')
return s
def process_goal(state):
state = state.lower().replace('"', '').replace("'", "")
state = state.replace('amazon shopping game\ninstruction:', '').replace('webshop\ninstruction:', '')
state = state.replace('\n[button] search [button_]', '').strip()
if ', and price lower than' in state:
state = state.split(', and price lower than')[0]
return state
def data_collator(batch):
state_input_ids, state_attention_mask, action_input_ids, action_attention_mask, sizes, labels, images = [], [], [], [], [], [], []
for sample in batch: