Two more CalibUser
Code:
############ FIXES ώ ###########
def IsFixO(m):
"""
This function examines a word to see whether is required to fix the (ιό|οί|ιο|οι) characterw that is misspelled.
It is called by a regular expression function (re.sub) in FixCommonErrors()
It returns the original expression if the checked word is not in the dictionary,
otherwise it returns the word without the ώ fixed
"""
FixO=m.group(1)+"ώ"+m.group(3)
FixO2=m.group(1)+m.group(2)+m.group(3)
if spell(FixO2):
return(m.group(1)+m.group(2)+m.group(3))
elif spell(FixO):
print("FixΏ: ",FixO2, " changed to ", FixO)
return(m.group(1)+"ώ"+m.group(3))
else:
return(m.group(1)+m.group(2)+m.group(3))
############ FIXES ω ###########
def IsFixW(m):
"""
This function examines a word to see whether is required to fix the (ιό|οί|ιο|οι) characterς that is misspelled.
It is called by a regular expression function (re.sub) in FixCommonErrors()
It returns the original expression if the checked word is not in the dictionary,
otherwise it returns the word without the ω fixed
"""
FixW=m.group(1)+"ω"+m.group(3)
FixW2=m.group(1)+m.group(2)+m.group(3)
if spell(FixW2):
return(m.group(1)+m.group(2)+m.group(3))
elif spell(FixW):
print("FixΩ: ",FixW2, " changed to ", FixW)
return(m.group(1)+"ω"+m.group(3))
else:
return(m.group(1)+m.group(2)+m.group(3))
--------------------------------------------------------------------
#Fixes ώ in words that are misspelled
if dictExists == True:
CorrectText("ώ fixes",r"(\w+)(ιίι|(ό|ο)|ίό|ο>|ο'ι|ιό|οί|ιο|οι|<ο|οϊ)(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", IsFixO)
#Fixes ω in words that are misspelled
if dictExists == True:
CorrectText("ω fixes",r"(\w+)(ιίι|(ό|ο)|ίό|ο>|ο'ι|ιό|οί|ιο|οι|<ο|οϊ)(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", IsFixW)
EDIT: How can I modify the regex to match and the last and first characters in a word? I noticed that they work only inside the word.
Thanks!