-
Notifications
You must be signed in to change notification settings - Fork 0
/
CloneMaker.py
96 lines (87 loc) · 3.87 KB
/
CloneMaker.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
import re
from operator import is_not
from functools import partial
filrdir = "C:\\Users\\Glu\\Desktop\\KangleiIyek\\IyekListOnlyFinalAndJoined.txt"
filrdirwrite = "C:\\Users\\Glu\\Desktop\\KangleiIyek\\IyekListOnlyFinalAndJoinedCloned.txt"
array = ["sh", "s", "f","bh","v","ll","pp","nn","mm","ll","kk","tt","ngng"]
regexsplit = "(sh)|(s)|(f)|(bh)|(v)|(ll)|(pp)|(nn)|(mm)|(ll)|(kk)|(tt)|(ngng)" # dont preced "sh" by "s" and similar
def checkit(param: str):
for line in array:
if (line == param):
return True
return False
def makecobi(myfpart, myarray: array):
cparray = myarray.copy()
del cparray[0]
arrycombi = []
returnablearray = []
for newnum in range(0, len(myarray[0])):
if (len(myarray) > 1):
fpart = myarray[0][newnum]
arrycombi = arrycombi + makecobi(fpart, cparray)
else:
arrycombi = myarray[0]
for line in arrycombi:
returnablearray.append(myfpart + line)
return returnablearray
def getposiblecombination(arrayble: array):
cparray = arrayble.copy()
del cparray[0]
rrycombi = []
for newnum in range(0, len(arrayble[0])):
fpart = arrayble[0][newnum]
rraycombi = rrycombi + makecobi(fpart, cparray)
return rraycombi
counter=0
with open(filrdirwrite, 'a',encoding="UTF-16") as the_file:
with open(filrdir,encoding="UTF-16") as f:
for line in f:
counter=counter+1
if(counter%10000==0):
print(counter)
splitedme = line.replace("\n", "").replace("\r", "").lower().split("-->")
line=splitedme[1]
newline=""
for string in array:
splited = re.split(regexsplit, line)
if len(splited)>1:
splited = list(filter(None.__ne__, splited))
# print(splited)
arrayble = []
for int in range(0, len(splited)):
iswhaiwan = checkit(splited[int])
if iswhaiwan:
if splited[int] == "s" or splited[int] == "sh":
arrayble.append(["s", "sh"])
if splited[int] == "f":
arrayble.append(["ph", "f"])
if splited[int] == "bh" or splited[int] == "v":
arrayble.append(["bh", "v"])
if splited[int] == "ll" :
arrayble.append(["l", "ll"])
if splited[int] == "pp" :
arrayble.append(["pp", "p"])
if splited[int] == "nn" :
arrayble.append(["nn", "n"])
if splited[int] == "mm" :
arrayble.append(["mm", "m"])
if splited[int] == "ll" :
arrayble.append(["l", "ll"])
if splited[int] == "kk" :
arrayble.append(["k", "kk"])
if splited[int] == "tt" :
arrayble.append(["t", "tt"])
if splited[int] == "ngng" :
arrayble.append(["ng", "ngng"])
else:
arrayble.append([splited[int]])
allposibleyunak = getposiblecombination(arrayble)
else:
allposibleyunak=[line]
break
for yumnakname in allposibleyunak:
# print(splitedme[0]+"-->"+yumnakname )
the_file.write(splitedme[0]+"-->"+yumnakname + "\n")
# break
# print(line)
# break