Attachment 'ray_anna.py'

Download

   1 #coding: utf
   2 f=open('anna.txt')
   3 from time import sleep
   4 R=u'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
   5 r=u'абвгдежзийклмнопрстуфхцчшщъыьэюя'
   6 e=u'abcdefghijklmnopqrstuvwxyz'
   7 slova,num,slovo=[],[],u''
   8 j,per=0,0
   9 print('Идёт сканирование файла:')
  10 sleep(1)
  11 for line in f:
  12 	if round(j/2769.2)>per:
  13 		print ' ',int(round(j/2769.2))*10,'%'
  14 	per=round(j/2769.2)
  15 	j+=1
  16 	line=line.decode('utf8')
  17 	line.lower()
  18 	line.replace(u'ё',u'е')
  19 	for bukva in line:
  20 		if R.count(bukva):
  21 			bukva=r[R.index(bukva)]
  22 			slovo+=bukva
  23 		elif (r+e).count(bukva):
  24 			slovo+=bukva
  25 		else:
  26 			if len(slovo)==4:
  27 				if slova.count(slovo):
  28 					num[slova.index(slovo)]+=1
  29 				else:
  30 					slova+=[slovo]
  31 					num+=[1]
  32 			slovo=''
  33 res=[(not i%2 and slova.pop(num.index(max(num)))) or num.pop(num.index(max(num))) for i in xrange(30)]
  34 t=1
  35 while t:
  36 	t=0
  37 	for i in xrange(14):
  38 		if res[i*2+1]==res[i*2+3]:
  39 			for k in xrange(4):
  40 				if (r+e).index(res[i*2][k])>(r+e).index(res[i*2+2][k]):
  41 					res[i*2],res[i*2+2]=res[i*2+2],res[i*2]
  42 					t=1
  43 					break
  44 				elif (r+e).index(res[i*2][k])<(r+e).index(res[i*2+2][k]):
  45 					break
  46 print '\nРезультат:'
  47 for i in xrange(10):
  48 	print '{0:>2}.'.format(i+1),res[i*2],'-',res[i*2+1]

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.