From 6e27de247faaf6c8a75b2ba25cc7f664110f70e6 Mon Sep 17 00:00:00 2001 From: Bryan Marcus McCann Date: Wed, 27 Jun 2018 20:51:14 +0000 Subject: [PATCH] rm dangling space in woz --- text/torchtext/datasets/generic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/text/torchtext/datasets/generic.py b/text/torchtext/datasets/generic.py index e749b9df..696fe047 100644 --- a/text/torchtext/datasets/generic.py +++ b/text/torchtext/datasets/generic.py @@ -942,13 +942,16 @@ class WOZ(CQA, data.Dataset): delta_state['request'].append(slot[1]) current_state['request'].append(slot[1]) previous_state = current_state - answer = ', '.join([f'{x[0]}: {x[1]}' for x in delta_state['inform']]) + ';' + answer = '' + if len(delta_state['inform']) > 0: + answer = ', '.join([f'{x[0]}: {x[1]}' for x in delta_state['inform']]) + answer += ';' if len(delta_state['request']) > 0: answer += ' ' answer += ', '.join(delta_state['request']) ex = {'context': ' '.join(context.split()), 'question': ' '.join(question.split()), 'lang': lang, - 'answer': answer if len(answer.strip()) > 1 else 'None', + 'answer': answer if len(answer) > 1 else 'None', 'lang_dialogue_turn': f'{lang}_{di}_{ti}'} split_file.write(json.dumps(ex)+'\n')