Implement `--goal` option to assert what final utterance is reached.
Chris Pressey
8 months ago
70 | 70 |
|
71 | 71 |
### TODO (immediate)
|
72 | 72 |
|
73 | |
* `--goal` to assert that a particular final utterance appears
|
74 | 73 |
* Turn `complete` into a strategy that must be explicitly selected.
|
75 | 74 |
|
76 | 75 |
### TODO (aspirational)
|
122 | 122 |
beam_width=options.beam_width,
|
123 | 123 |
)
|
124 | 124 |
|
125 | |
if options.goal:
|
126 | |
raise NotImplementedError(str(result))
|
127 | |
|
128 | 125 |
if options.output_file:
|
129 | 126 |
with open(options.output_file, 'w') as f:
|
130 | 127 |
f.write(json.dumps(result, indent=4))
|
|
132 | 129 |
sys.stdout.write(json.dumps(result, indent=4))
|
133 | 130 |
sys.stdout.write("\n")
|
134 | 131 |
|
|
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 |
|
135 | 142 |
|
136 | 143 |
if __name__ == '__main__':
|
137 | 144 |
import sys
|