Created
September 9, 2012 10:55
-
-
Save ernado/3683780 to your computer and use it in GitHub Desktop.
Tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding:utf8 -*- | |
| import random, sys | |
| def input(t): | |
| return raw_input(t).decode(sys.stdin.encoding) | |
| MAX_MISTAKES = 0.2 | |
| words = { | |
| 'as': [u'как',u'так как' ], | |
| 'as well': [u'так же', ], | |
| 'affect': [u'влиять', ], | |
| 'become': [u'становиться'], | |
| 'consider': [u'считать', u'рассматривать', u'учитывать'], | |
| 'further' : [u'дальнейший',], | |
| 'improve' : [u'улучшать'], | |
| 'mean': [u'значить', u'означать'], | |
| 'means':[u'средство', u'способ'], | |
| 'number':[u'число',u'количество'], | |
| 'a number of':[u'ряд',u'несколько'], | |
| 'prepare':[u'готовить',u'подготавливать'], | |
| 'provide':[u'снабжать',u'обеспечивать'], | |
| 'receive':[u'получать',], | |
| 'remain':[u'оставаться',], | |
| 'quality':[u'качество',], | |
| 'thorough':[u'основательный',u'доскональный',u'тщательный'], | |
| 'usually':[u'обычно',], | |
| 'to play a part':[u'играть роль',], | |
| 'to take into consideration':[u'принимать во внимание',u'принимать в расчет'], | |
| 'at present' : [u'в настоящее время',] | |
| } | |
| t = words | |
| count = len(words) | |
| print 'Test of %s words' % count | |
| def test(words, reverse = False): | |
| count = len(words) | |
| mistakes = 0 | |
| while words: | |
| w = random.choice(words.keys()) | |
| if reverse: | |
| attempt = input('%s - ' % random.choice(words[w])) | |
| translations = [w,] | |
| else: | |
| translations = words[w] | |
| attempt = input('%s - ' % w) | |
| if attempt in translations: | |
| print 'Correct!' | |
| print '%s/%s' % (count-len(words)+1,count) | |
| print w.upper() + ':' | |
| if len(translations) > 1: | |
| for word in translations: | |
| print ' - %s' % word | |
| del words[w] | |
| else: | |
| mistakes += 1 | |
| print 'You are wrong, young bastard!' | |
| if (float(mistakes) / count) > MAX_MISTAKES: | |
| print 'Learn more, retard.' | |
| break | |
| print '\n' | |
| return mistakes | |
| m = test(words, True) | |
| print 'Test complete for now.' | |
| print '%s mistakes' % m | |
| raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment