MCPcopy Index your code
hub / github.com/pytorch/tutorials / evaluateInput

Function evaluateInput

beginner_source/chatbot_tutorial.py:1202–1219  ·  view source on GitHub ↗
(encoder, decoder, searcher, voc)

Source from the content-addressed store, hash-verified

1200
1201
1202def evaluateInput(encoder, decoder, searcher, voc):
1203 input_sentence = ''
1204 while(1):
1205 try:
1206 # Get input sentence
1207 input_sentence = input('> ')
1208 # Check if it is quit case
1209 if input_sentence == 'q' or input_sentence == 'quit': break
1210 # Normalize sentence
1211 input_sentence = normalizeString(input_sentence)
1212 # Evaluate sentence
1213 output_words = evaluate(encoder, decoder, searcher, voc, input_sentence)
1214 # Format and print response sentence
1215 output_words[:] = [x for x in output_words if not (x == 'EOS' or x == 'PAD')]
1216 print('Bot:', ' '.join(output_words))
1217
1218 except KeyError:
1219 print("Error: Encountered unknown word.")
1220
1221
1222######################################################################

Callers

nothing calls this directly

Calls 2

normalizeStringFunction · 0.70
evaluateFunction · 0.70

Tested by

no test coverage detected