-
Notifications
You must be signed in to change notification settings - Fork 0
/
grm.py
242 lines (186 loc) · 8.33 KB
/
grm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import code_3rd
grammar_10_uni = []
grammar_11_uni = []
grammar_12_uni = []
grammar_12_uni1 = []
grammar_12_uni2 = []
grammar_12_uni3 = []
grammar_18_uni = []
def grammar_10(a):
for i in range(code_3rd.count):
grammar_10_uni.append(((code_3rd.uni_data[i] - 44032) % 588) % 28)
# 제 10항 모음 + '예' 50696 모음
if grammar_10_uni[a] == 0:
if 50726 >= code_3rd.uni_data[a+1] >= 50696:
code_3rd.all_list[3][0] = 0
else:
code_3rd.all_list[3][0] = -1
def grammar_11(a):
# 제 11항 모음(ㅑ,ㅘ,ㅜ,ㅝ) + '애' 50528 모음
for i in range(code_3rd.count):
grammar_11_uni.append(((code_3rd.uni_data[i] - 44032) % 588) % 28)
if grammar_11_uni[a] == 0:
for i in range(24):
if code_3rd.uni_data[a] == (44088 + (588 * i)) or code_3rd.uni_data[a] == (44284 + (588 * i)) or \
code_3rd.uni_data[a] == (44396 + (588 * i)) or code_3rd.uni_data[a] == (44424 + (588 * i)):
if 50555 >= code_3rd.uni_data[a+1] >= 50528: # 애 ~ 앻
code_3rd.all_list[3][0] = 0
else:
code_3rd.all_list[3][0] = -1
a += 1
def grammar_12(a):
# for i in range(code_3rd.count):
# grammar_12_uni[i] = 0
# grammar_12_uni1[i] = 0
# grammar_12_uni2[i] = 0
# grammar_12_uni3[i] = 0
for i in range(code_3rd.count):
grammar_12_uni.append(code_3rd.uni_data[i])
grammar_12_uni1.append((code_3rd.uni_data[i] - 44032) // 588) # 초성
grammar_12_uni2.append(((code_3rd.uni_data[i] - 44032) % 588) // 28) # 중성
grammar_12_uni3.append(((code_3rd.uni_data[i] - 44032) % 588) % 28) # 종성
#print(grammar_12_uni[a]) ###
#print(grammar_12_uni1[a])
#print(grammar_12_uni2[a])
#print(grammar_12_uni3[a])
# all_list[3][0]: {0~11}={이음줄,가,나,다,마,바,사,자,카,타,파,하}
if 44032 <= grammar_12_uni[a] <= 44059:
code_3rd.all_list[3][0] = 1
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 45208 <= grammar_12_uni[a] <= 45235:
code_3rd.all_list[3][0] = 2
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 45796 <= grammar_12_uni[a] <= 45823:
code_3rd.all_list[3][0] = 3
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 47560 <= grammar_12_uni[a] <= 47587:
code_3rd.all_list[3][0] = 4
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 48148 <= grammar_12_uni[a] <= 48175:
code_3rd.all_list[3][0] = 5
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 49324 <= grammar_12_uni[a] <= 49351:
code_3rd.all_list[3][0] = 6
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 51088 <= grammar_12_uni[a] <= 51115:
code_3rd.all_list[3][0] = 7
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 52852 <= grammar_12_uni[a] <= 52879:
code_3rd.all_list[3][0] = 8
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 53440 <= grammar_12_uni[a] <= 53467:
code_3rd.all_list[3][0] = 9
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 54028 <= grammar_12_uni[a] <= 54055:
code_3rd.all_list[3][0] = 10
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif 54616 <= grammar_12_uni[a] <= 54643:
code_3rd.all_list[3][0] = 11
code_3rd.all_list[1][3] = grammar_12_uni3[a]
if grammar_12_uni2[a] == 4:
if grammar_12_uni3[a] == 1:
code_3rd.all_list[3][0] = 12 # 억
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 13 # 언
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 8:
code_3rd.all_list[3][0] = 14 # 얼
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni2[a] == 6:
if grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 15 # 연
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 8:
code_3rd.all_list[3][0] = 16 # 열
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 21:
code_3rd.all_list[3][0] = 17 # 영
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni2[a] == 8:
if grammar_12_uni3[a] == 1:
code_3rd.all_list[3][0] = 18 # 옥
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 19 # 온
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 21:
code_3rd.all_list[3][0] = 20 # 옹
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni2[a] == 13:
if grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 21 # 운
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 8:
code_3rd.all_list[3][0] = 22 # 울
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni2[a] == 18:
if grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 23 # 은
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni3[a] == 8:
code_3rd.all_list[3][0] = 24 # 을
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
elif grammar_12_uni2[a] == 20:
if grammar_12_uni3[a] == 4:
code_3rd.all_list[3][0] = 25 # 인
code_3rd.all_list[0][0] = grammar_12_uni1[a]
code_3rd.all_list[1][3] = grammar_12_uni3[a]
if grammar_12_uni1[a] == 0:
if grammar_12_uni2[a] == 4:
if grammar_12_uni3[a] == 19:
code_3rd.all_list[3][0] = 26 # 것
# all_list[3][0]={12~26}{억,언,얼,언,열,영,옥,온,옹,운,울,은,을,인,것}
""" 시작 글자 -> 그 """ # 앞자리 비었을때로 예외처리, all_list로 순서 정하기
def grammar_18(a):
for j in range(code_3rd.count):
grammar_18_uni.append(code_3rd.uni_data[j])
if a == 0 or grammar_18_uni[a-1] == 32: # 처음시작(빈공간 당연히 x)
if grammar_18_uni[a] == 44536: # "그"
if grammar_18_uni[a+1] == 47000: # "래"
if grammar_18_uni[a+2] == 49436: # 그래서
code_3rd.all_list[3][1] = 0
elif grammar_18_uni[a+1] == 47084: # "러"
if grammar_18_uni[a+2] == 45208: # 그러나
code_3rd.all_list[3][1] = 1
elif grammar_18_uni[a+2] == 47732: # 그러면
code_3rd.all_list[3][1] = 2
elif grammar_18_uni[a+2] == 48064: # "므"
if grammar_18_uni[a+3] == 47196: # 그러므로
code_3rd.all_list[3][1] = 3
elif grammar_18_uni[a+1] == 47088: # "런"
if grammar_18_uni[a+2] == 45936: # 그런데
code_3rd.all_list[3][1] = 4
elif grammar_18_uni[a+1] == 47532: # "리"
if grammar_18_uni[a+2] == 44256: # 그리고
code_3rd.all_list[3][1] = 5
elif grammar_18_uni[a+2] == 54616: # "하"
if grammar_18_uni[a+3] == 50668: # 그리하여
code_3rd.all_list[3][1] = 6
"""
if code_3rd.data[a] == 0:
print(0)
"""
"""grammar_11(i)
if code_3rd.all_list[3][0] == 0:
print(i)
elif code_3rd.all_list[3][0] == -1:
print("X")
grammar_12(i)
if code_3rd.all_list[3][0] == 0:
print(i)
elif code_3rd.all_list[3][0] == -1:
print("X")"""