def readable(filename): desh_freq = sorted(biN(filename).iteritems(), key = operator.itemgetter(1))[-3:] it = 2 for i in range(0,len(desh_freq)): for j in range(0,len(most_use)): if most_use[j] == desh_freq[i][0]: it -= 1 if it <= 0 : return True return False
def readable_neg(filename): less_voc_desh = sorted(biN(filename).iteritems(), key = operator.itemgetter(1))[:10] it = 0 for i in range(0,len(less_voc_desh)): for j in range(0,len(less_voc)): if less_voc[j][0] == less_voc_desh[i][0]: it -= 1 if it <= 0: return True return False
file_in = "" file_out = "" rus_text = "TEXT1" temp = "temp" if len(sys.argv) == 3: file_in = sys.argv[1] file_out = sys.argv[2] #print "file name is %s " % fn else: print "usage script.py <input file name> <output file name>" most_use = [u'ст',u'но',u'то',u'на',u'ен'] m = 31 alphabet = {u'а':0,u'б':1,u'в':2,u'г':3,u'д':4,u'е':5,u'ж':6,u'з':7,u'и':8,u'й':9,u'к':10,u'л':11,u'м':12,u'н':13,u'о':14,u'п':15,u'р':16,u'с':17,u'т':18,u'у':19,u'ф':20,u'х':21,u'ц':22,u'ч':23,u'ш':24,u'щ':25,u'ы':26,u'ь':27,u'э':28,u'ю':29,u'я':30} x = biN(file_in) most_biN_find = sorted(x.iteritems(), key=operator.itemgetter(1))[-9:] less_voc = sorted(biN(rus_text).iteritems(), key = operator.itemgetter(1))[:15] def readable(filename): desh_freq = sorted(biN(filename).iteritems(), key = operator.itemgetter(1))[-3:] it = 2 for i in range(0,len(desh_freq)): for j in range(0,len(most_use)): if most_use[j] == desh_freq[i][0]: it -= 1 if it <= 0 : return True return False def readable_neg(filename): less_voc_desh = sorted(biN(filename).iteritems(), key = operator.itemgetter(1))[:10]