Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit accf019

Browse files
Import readline in decoding.py
1 parent 3931b84 commit accf019

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tensor2tensor/utils/decoding.py

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,19 @@ def _interactive_input_fn(hparams):
248248
vocabulary = p_hparams.vocabulary["inputs" if has_input else "targets"]
249249
# This should be longer than the longest input.
250250
const_array_size = 10000
251+
# Import readline if available for command line editing and recall
252+
try:
253+
import readline
254+
except ImportError:
255+
pass
251256
while True:
252257
prompt = ("INTERACTIVE MODE num_samples=%d decode_length=%d \n"
253258
" it=<input_type> ('text' or 'image' or 'label')\n"
254259
" pr=<problem_num> (set the problem number)\n"
255260
" in=<input_problem> (set the input problem number)\n"
256261
" ou=<output_problem> (set the output problem number)\n"
257262
" ns=<num_samples> (changes number of samples)\n"
258-
" dl=<decode_length> (changes decode legnth)\n"
263+
" dl=<decode_length> (changes decode length)\n"
259264
" <%s> (decode)\n"
260265
" q (quit)\n"
261266
">" % (num_samples, decode_length, "source_string"

0 commit comments

Comments
 (0)