Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
jsonfile retains original fields (#5033)
Browse files Browse the repository at this point in the history
* jsonfile retains original fields

* jsonfile retains original fields

* simplified
  • Loading branch information
jaseweston authored May 16, 2023
1 parent 4f4caa9 commit 14ba31b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions parlai/core/teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,12 @@ def _get_ep_from_turns(self, xturns, yturns):
eps = []
for xturn, yturn in zip(xturns, yturns):
turn = {}
turn['text'] = xturn.get('text').strip()
turn['labels'] = [yturn.get('text').strip()]
turn['text'] = xturn.get('text')
turn['labels'] = [yturn.get('text')]

turn['x_turn'] = xturn
turn['y_turn'] = yturn

eps.append(turn)
return eps

Expand Down
5 changes: 4 additions & 1 deletion parlai/scripts/display_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def simple_display(opt, world, turn):
text = act.get('text', '[no text field]')
print(colorize(text.encode('utf-16', 'surrogatepass').decode('utf-16'), 'text'))
labels = act.get('labels', act.get('eval_labels', ['[no labels field]']))
labels = '|'.join(labels)
if len(labels) == 1 and labels[0] is None:
labels = str(labels)
else:
labels = '|'.join(labels)
print(' ' + colorize(labels, 'labels'))


Expand Down

0 comments on commit 14ba31b

Please sign in to comment.