Created
March 9, 2017 10:57
-
-
Save dimnikolos/a405315ffa23c821a0a41b1ffcf4079f 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
# -*- coding: utf-8 -*- | |
#https://raw.githubusercontent.com/LibreOffice/dictionaries/master/el_GR/el_GR.dic | |
#save as utf-8 | |
import codecs | |
rhString = 'ΠΟΙΘΥΛΚΞΗΜΝΒΌΊΎΉΪ' | |
lhString = 'ΕΡΤΑΣΔΦΓΖΧΨΩΈΆΏ' | |
print(rhString.decode('utf-8')) | |
rhMax = 0 | |
rhCount = 0 | |
lhMax = 0 | |
lhCount = 0 | |
with codecs.open('el_GR.dic','r',encoding = 'utf-8') as grDict: | |
for (num,line) in enumerate(grDict): | |
lineU = line.upper() | |
rhOnly = True | |
for key in lineU[:-1]: | |
if key not in rhString.decode('utf-8'): | |
rhOnly = False | |
break | |
lhOnly = True | |
for key in lineU[:-1]: | |
if key not in lhString.decode('utf-8'): | |
lhOnly = False | |
break | |
if rhOnly: | |
rhCount += 1 | |
if len(line[:-1])>=rhMax: | |
rhMax = len(line[:-1]) | |
print("Only right hand: " + line[:-1] + " (" + str(rhMax) + ")") | |
if lhOnly: | |
lhCount += 1 | |
if len(lineU[:-1])>=lhMax: | |
lhMax = len(lineU[:-1]) | |
print("Only left hand (CAPS): " + lineU[:-1] + " (" + str(lhMax) + ")") | |
print("Num of right hand words: " + str(rhCount)) | |
print("Num of left hand words: " + str(lhCount)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment