''' Purpose: translate user text to English ''' # get access to url support import url # CS 1112 translation dictionary -- entries are of form: word,translation BABEL_FISH_URL = 'http://www.cs.virginia.edu/~cs1112/words/babelfish' # get contents of babel fish url dataset = url.get_dataset( BABEL_FISH_URL ) # convert csv-based word mappings into dictionary format word_mappings = {} ... # get the user text to be translated reply = input( 'Enter phrase to be translated: ' ) # convert reply into a list of words to_be_translated = reply.split() # process the list word by word -- that is, build up the output phrase # word by word ... for word in to_be_translated : # translate word ... # print translation ...