''' Purpose: translate user text to English ''' import url DEFAULT_URL = 'http://www.cs.virginia.edu/~cs1112/words/babel' DEFAULT_DICTIONARY = url.get_dictionary( DEFAULT_URL ) def glot( text, dictionary = DEFAULT_DICTIONARY) : ''' returns a translation of text according to dictionary, where text may have embedded \n's ''' pass def line( string, dictionary = DEFAULT_DICTIONARY ) : ''' returns a translation of string according to dictionary, where string is composed of zero or more words ''' pass def word( string, dictionary = DEFAULT_DICTIONARY) : ''' returns a translation of the string according to dictionary, where string is composed of a single word. if the translation is unknown the function return the word within <> ''' pass if ( __name__ == '__main__' ) : print( word( 'lapiz' ) ) print() print( line( 'como esta eso' ) ) print() print( glot( 'tun vous savez hvor\nmi pencil ist' ) ) print() DIGIT_URL = 'http://www.cs.virginia.edu/~cs1112/words/digits' d = url.get_dictionary( DIGIT_URL ) print( glot( '0 O 1 2 3 4 5', dictionary = d ) )