git @ Cat's Eye Technologies relwrite / 0fceeeb
Implement `--goal` option to assert what final utterance is reached. Chris Pressey 8 months ago
2 changed file(s) with 10 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7070
7171 ### TODO (immediate)
7272
73 * `--goal` to assert that a particular final utterance appears
7473 * Turn `complete` into a strategy that must be explicitly selected.
7574
7675 ### TODO (aspirational)
122122 beam_width=options.beam_width,
123123 )
124124
125 if options.goal:
126 raise NotImplementedError(str(result))
127
128125 if options.output_file:
129126 with open(options.output_file, 'w') as f:
130127 f.write(json.dumps(result, indent=4))
132129 sys.stdout.write(json.dumps(result, indent=4))
133130 sys.stdout.write("\n")
134131
132 if options.goal:
133 if len(result) != 1:
134 raise ValueError("Derivation did not produce a single result")
135 result = result[0]
136 if len(result) != 1:
137 raise ValueError("Derivation result does not consist of single utterance")
138 result = result[0]
139 if options.goal != result:
140 raise ValueError("Derivation result does not match given goal")
141
135142
136143 if __name__ == '__main__':
137144 import sys