Last active
February 13, 2018 07:56
-
-
Save dimnikolos/16e84397e4402096659025adb9d90599 to your computer and use it in GitHub Desktop.
Ομόηχα
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Συναισθήματα χαράς και λείπεις | |
#Μου λύπης! | |
#@dnikolos | |
removeProblems = { | |
"ου":"ΟΥ", | |
"ού":"ΟΎ", | |
"αυ":"ΑΥ", | |
"αύ":"ΑΎ", | |
"ευ":"ΕΥ", | |
"εύ":"ΕΎ" | |
} | |
difths = { | |
"αι":"ε", | |
"αί":"ε", | |
"ει":"ι", | |
"εί":"ι", | |
"οι":"ι", | |
"οί":"ι", | |
"η":"ι", | |
"ή":"ι", | |
"υ":"ι", | |
"ύ":"ι", | |
"ώ":"ο", | |
"ω":"ο", | |
"ι":"ι", | |
"ί":"ι", | |
"ό":"ο", | |
"ο":"ο", | |
"λλ":"λ", | |
"μμ":"μ"} | |
def removeAccents(word): | |
accs = {"ά":"α","έ":"ε","ή":"η","ί":"ι","ό":"ο","ύ":"υ","ώ":"ω"} | |
for acc in accs: | |
return(word.replace(acc,accs[acc])) | |
lexeisMeDifth = {} | |
with open('el_GR.dic','r',encoding = 'iso-8859-7') as lexiko: | |
lexeis=lexiko.read().replace('r','').split() | |
for miaLexi in lexeis: | |
for prob in removeProblems: | |
miaLexi = miaLexi.replace(prob,removeProblems[prob]) | |
miaLexi = removeAccents(miaLexi) | |
antik = miaLexi | |
for difth in difths: | |
if difth in antik: | |
antik = antik.replace(difth,difths[difth]) | |
try: | |
if miaLexi not in lexeisMeDifth[antik]: | |
lexeisMeDifth[antik].append(miaLexi) | |
except KeyError: | |
lexeisMeDifth[antik] = [miaLexi] | |
pinakasLexewn = [] | |
for lexi in lexeisMeDifth: | |
if len(lexeisMeDifth[lexi])>3: | |
pinakasLexewn.append(lexeisMeDifth[lexi]) | |
with open("lexeis.txt","w",encoding = "utf-8") as outtxt: | |
for grammi in pinakasLexewn: | |
outtxt.write(",".join([x.lower() for x in grammi])) | |
outtxt.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment