26 | 26 |
argparser.add_argument('input_files', nargs='+', metavar='FILENAME', type=str,
|
27 | 27 |
help='Source files containing the scenario descriptions'
|
28 | 28 |
)
|
29 | |
argparser.add_argument("--debug",
|
30 | |
action="store_true",
|
31 | |
help="Show state before and after each move")
|
|
29 |
argparser.add_argument("--debug", action="store_true",
|
|
30 |
help="Show state before and after each move"
|
|
31 |
)
|
32 | 32 |
argparser.add_argument("--dump-ast",
|
33 | 33 |
action="store_true",
|
34 | 34 |
help="Just show the AST and stop")
|
35 | 35 |
argparser.add_argument("--length",
|
36 | 36 |
type=int, default=0,
|
37 | 37 |
help="If given, generate this many events for each situation")
|
38 | |
argparser.add_argument("--line-per-sentence",
|
39 | |
action="store_true")
|
|
38 |
argparser.add_argument("--output-type",
|
|
39 |
choices=['naive-text', 'events-json', 'scenarios-json'],
|
|
40 |
default='naive-text',
|
|
41 |
help="Specify what to output and in what format")
|
40 | 42 |
argparser.add_argument("--seed",
|
41 | 43 |
type=int, default=None,
|
42 | 44 |
help="Set random seed (to select moves deterministically)")
|
|
74 | 76 |
sys.exit(0)
|
75 | 77 |
if options.seed is not None:
|
76 | 78 |
random.seed(options.seed)
|
|
79 |
event_buckets = []
|
77 | 80 |
for scenario in ast.scenarios:
|
78 | 81 |
if scenario.goal is None:
|
79 | 82 |
continue
|
|
82 | 85 |
events = g.generate_events(options.length)
|
83 | 86 |
elif options.words > 0:
|
84 | 87 |
events = g.generate_words(options.words)
|
85 | |
for e in events:
|
86 | |
if options.line_per_sentence:
|
|
88 |
event_buckets.append(events)
|
|
89 |
|
|
90 |
if options.output_type == 'naive-text':
|
|
91 |
for b in event_buckets:
|
|
92 |
for e in events:
|
87 | 93 |
sys.stdout.write("%s\n" % e)
|
88 | |
else:
|
89 | |
sys.stdout.write("%s " % e)
|
90 | |
sys.stdout.write("\n")
|
|
94 |
sys.stdout.write("\n")
|
|
95 |
elif options.output_type == 'events-json':
|
|
96 |
sys.stdout.write(json.dumps(event_buckets, indent=4, sort_keys=True))
|
|
97 |
elif options.output_type == 'scenarios-json':
|
|
98 |
raise NotImplementedError
|
|
99 |
else:
|
|
100 |
raise NotImplementedError
|
91 | 101 |
|
92 | 102 |
|
93 | 103 |
if __name__ == '__main__':
|