| import numpy as np |
|
|
|
|
| def stringify(story, exist_answer=False, order=0): |
|
|
| lines = [] |
|
|
| i = 0 |
| j = 0 |
| count_order = 0 |
|
|
| while True: |
|
|
| |
| if isinstance(story[i], str): |
| line = story[i] |
| else: |
| line = story[i].render() |
| |
| line = line[0].upper() + line[1:] |
|
|
| |
| if line.split()[0] != 'Question:' and line.split()[0] != 'Choices:': |
| line = '%d %s' % (i + 1, line) |
| else: |
| if line.split()[0] == 'Choices:': |
| lines.append(line) |
| break |
| else: |
| if count_order == order: |
| lines.append(line) |
| count_order += 1 |
| i += 1 |
| continue |
| lines.append(line) |
| |
| i += 1 |
|
|
| |
| |
| |
| |
| |
| if i >= len(story): |
| break |
|
|
| return lines |
|
|