예제 #1
0
def read_all(reread=False):
    global words, sent
    for i in dt.get_all_books():
        if dt.no_description(i) or reread:
            words = {}
            sent = {}
            read(i)
            out = sorted(words.items(), key=lambda t: -t[1])
            dt.save_words_as(out, i)
            out = sorted(sent.items(), key=lambda t: t[0])
            dt.save_words_as(out, i, 'sentenses')
예제 #2
0
def read_all(reread=False):
    global words, sent, gramm, letters, unknown, combinations
    global denials, names, multi_text
    for i in dt.get_all_books():
        if dt.no_description(i) or reread:
            words = {}
            sent = {}
            gramm = {}
            particals = {}
            unknown = {}
            combinations = {}
            names = {'Name': 0, 'Surn': 0, 'Patr': 0, 'Fake': 0, 'Geox': 0}
            denials = 0
            letters = dict([(chr(j), 0) for j in range(1072, 1104)])
            letters['ё'] = 0
            multi_text = []
            read(i)
            gramm['denials'] = denials
            save_read(i)

            print(i + ' read.')
예제 #3
0

def sum_norm(x, A, B, C, D, E, F):
       return A*np.e**(B*(x+C)**2)+D*np.e**(E*(x+F)**2)

def alternative(x, A, B, C, D , E, F, G, H):
       return (A*x**5+B*x**4+C*x**3+D*x**2+E*x+F)*np.e**(x*H+G)

def norm(x, A, B, C):
       return A*np.e**(-B*(x+C)**2)

NUMBER = 700

styles=['-','--','-.',':','']

books = dt.get_all_books()
#books = dt.get_books_by("Толстой Лев Николаевич", prop='author')
#books = ["Толстой Лев Николаевич#Война и мир#1",# "Толстой Лев Николаевич#Война и мир#2",
         #"Толстой Лев Николаевич#Война и мир#3", "Толстой Лев Николаевич#Война и мир#4",
         #"Толстой Лев Николаевич#Анна Каренина", "Тургенев Иван Сергеевич#Отцы и дети",
#         "Достоевский Федор Михайлович#Преступление и наказание", "Неизвестный автор#Война и мир"]
all_y = {}
for i in books:
       toConsider = dt.get_words(i,'sentenses')
       all_y = dt.sum_dicts(all_y, dict(toConsider))

       #[:NUMBER]
       #C = sum(list(map(lambda t: t[1], dt.get_words(i))))
      # print(C)
       #y = np.array(list(map(lambda t: t[1], toConsider)))
      # x = np.array(list(map(lambda t: t[0], toConsider)))
예제 #4
0
import sentence_length_comparator
import matplotlib.pyplot as plt
import math_worker as mt
import math

SQUARE_FUNCTION = lambda l1, l2: (l2 - l1)**2
SQUARE_FUNCTION.__name__ = 'SQUARE_FUNCTION'
##ABS_FUNCTION = lambda l1, l2: abs(l2 - l1)
##ABS_FUNCTION.__name__ = 'ABS_FUNCTION'
##POW_FUNCTION = lambda l1, l2: 2**(l2 - l1) - 1
##POW_FUNCTION.__name__ = 'POW_FUNCTION'
##LOG_FUNCTION = lambda l1, l2: abs(math.log(l1+1)-math.log(l2+1))
##LOG_FUNCTION.__name__ = 'LOG_FUNCTION'
##

all_data = dt.get_all_books()

prop_stack = ['letters', 'grammatics', 'combinations', 'sentences', 'unknown']

f_aviable = [SQUARE_FUNCTION]

##for p in range(1,10):
##      for i in range(1,10):
##            f = lambda l1, l2: (abs(l1-l2)**p)
##            f.__name__ = str(p) + '#' + str(i)
##            f_aviable.append(f)

methods = {}
rating = {}
while prop_stack:
    prop_name = prop_stack[-1]
import data_worker as dt

for i in dt.get_all_books():
    f = open(dt.get_file(i), 'r')
    text = f.read()
    f.close()

    while True:
        i1 = text.find('[')
        i2 = text.find(']', i1)
        if i1 == -1 or i2 == -1:
            break
        text = text[:i1] + text[i2 + 1:]

    f = open(dt.get_file(i), 'w')
    f.write(text)
    f.close()