• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Mar 25th, 2019 70 in 245 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2. import functions as fun
3.
4. def syllables(word,sn):
5.     vowels = 'ΡΠ΅ΡΠ°ΠΎΡΡΠΈΡΡ'
6.     letters = 'ΠΉΡΠ»ΠΌΠ½'
7.     stroka = word.text
8.     lemm = word.lem
9.     if (len([v for v in stroka if v in vowels])>sn) and fun.check_min(lemm, 'B2') and ('-' not in stroka):
10.         #Π±Π΅ΡΠ΅ΠΌ ΡΠ΅, Π² ΠΊΠΎΡΠΎΡΡΡ Π±ΠΎΠ»ΡΡΠ΅ x ΡΠ»ΠΎΠ³ΠΎΠ² ΠΈ Π΅ΡΡΡ Π² ΠΌΠΈΠ½ΠΈΠΌΡΠΌΠ΅
11.         #print(word)
12.         n = 0
13.         sillabs = ''
14.         for i in range(len(stroka[::-1])):
15.             if stroka[i] in vowels:
16.                 sillabs += stroka[n:i]+stroka[i]+'-'
17.                 #print(sillabs)
18.                 n = i+ 1
19.                 vowind = i
20.             else:
21.                 if i == len(stroka)-1:
22.                     sillabs = sillabs[:-1]+stroka[n:]+'-'
23.         #Π²ΡΡΠ°Π²Π½ΠΈΠ²Π°Π½ΠΈΠ΅ ΡΠ»ΠΎΠ³ΠΎΠ΄Π΅Π»Π΅Π½ΠΈΡ Π΄Π»Ρ Π·Π°ΠΊΡΡΡΡΡ ΡΠ»ΠΎΠ³ΠΎΠ² Π² ΡΠ΅ΡΠ΅Π΄ΠΈΠ½Π΅ ΡΠ»ΠΎΠ²Π°
24.         #print(sillabs)
25.         m = 0
26.         newsillabs = ''
27.         for j in range(len(sillabs)):
28.             if ((sillabs[j] in letters) and (sillabs[j-1] == '-') and (sillabs[j+1] not in vowels) and (sillabs[j+1] not in letters) and (sillabs[j+1] != 'Ρ')):
29.                 newsillabs = newsillabs+sillabs[m:j-1]+sillabs[j]+'-'+sillabs[j+1:]
30.                 m = j+1
31.             if (((sillabs[j] == 'Ρ') and (sillabs[j-1] in letters)) and (sillabs[j-2] == '-')):
32.                 newsillabs = newsillabs+sillabs[m:j-2]+sillabs[j-1:j+1]+'-'+sillabs[j+1:]
33.                 m = j+1
34.         if newsillabs == '':
35.             newsillabs = sillabs
36.         #print(newsillabs[:-1])
37.
38.         split_word = newsillabs[:-1].split('-') #Π³ΠΎΡΠΎΠ²ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ ΡΠ»ΠΎΠ³ΠΎΠ²
39.
40.         shuf_w = split_word[:]
41.         random.shuffle(shuf_w)
42.         while shuf_w==split_word: #ΠΌΠ΅ΡΠ°Π΅ΠΌ ΡΠ»ΠΎΠ³ΠΈ ΡΠ°ΠΊ, ΡΡΠΎΠ±Ρ ΡΠΎΡΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»ΡΡ ΠΏΠΎΡΡΠ΄ΠΎΠΊ
43.           random.shuffle(shuf_w)
44.
45.         shuf_w = '['+''.join(shuf_w)+']' #ΡΠ»ΠΎΠ²ΠΎ Π²Π½ΡΡΡΠΈ Π·Π°Π΄Π°Π½ΠΈΡ
46.         key_w = '['+strokat+']' #ΡΠ»ΠΎΠ²ΠΎ Π²Π½ΡΡΡΠΈ ΠΊΠ»ΡΡΠ΅ΠΉ - ΡΠΎΠΆΠ΅ Π² ΡΠΊΠΎΠ±ΠΎΡΠΊΠ°Ρ, Π½ΠΎ Π² Π²Π΅ΡΠ½ΠΎΠΌ ΠΏΠΎΡΡΠ΄ΠΊΠ΅
47.
48.         shuf_w_token = fun.Token(shuf_w)
49.         key_w_token = fun.Token(key_w)
50.
51.         return shuf_w_token, key_w_token
52.     else:
53.         return word, word
54.
55.
56. def make_shuf_sents(old_words):
57.     shuf_words = ['']*len(old_words)
58.     key_words = shuf_words[:]
59.
60.     for i, w in enumerate(old_words):
61.         shuf_words[i], key_words[i] = syllables(w, 2)
62.
63.     return shuf_words,key_words #ΡΠΏΠΈΡΠΊΠΈ ΡΠΎΠΊΠ΅Π½ΠΎΠ² Π² ΠΏΡΠ΅Π΄Π»ΠΎΠΆΠ΅Π½ΠΈΠΈ
64.
65.
67. sentences = fun.sts(text)
68. tokens = fun.tkns(sentences)
69.
70. shuf_sents, key_sents = [], []
71. for sentence in tokens:
72.     shuf_words, key_words = make_shuf_sents(sentence)
73.     shuf_sents.append(shuf_words)
74.     key_sents.append(key_words)
75. print (join_toks(shuf_words))
76. print (join_toks(key_words))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top