View Single Post
Old 10-05-2015, 01:27 PM   #87
gipsy
Connoisseur
gipsy began at the beginning.
 
Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
I finally get the FixP code to work with!

Code:
def IsFixP(m):
	"""
	This function examines a hyphenated word to see whether the hyphen is required.
	It is called by a regular expression function (re.sub) in FixCommonErrors()
	It returns the original expression if the non-hyphenated word is not in the dictionary,
	otherwise it returns the word without the hyphen
	"""
	FixP="Π"+m.group(2)
	FixP2=m.group(1)+m.group(2)

	if spell(FixP2):
		return(m.group(0))
	elif spell(FixP):
		print("FixP removed from: ", FixP)
		return ('Π'+m.group(2))
	else:
		return(m.group(0))
and
Code:
#Fixes Π in words that are misspelled
		if dictExists == True:
			CorrectText("Π fixes",r"(1\ Ι|ΓΙ|Γΐ|ΙΙ|II|Ι\ Ι|ΓΤ|ΙΊ|Ιί)[ ]?(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", IsFixP)
It bypass the spelling correct words and changes the misspelled.
I think that i have some error in the CorrectText regex.
In the FixP sample that i had in a previously post... It doesn't correct the "Ι Ιήρε" And i have it in the CorrectText as "Ι\ Ι" .

Any thoughts???


EDIT: Found that it doesn't fix if the second part of the word (m.group(2)) is lowercase

Last edited by gipsy; 10-05-2015 at 01:46 PM.
gipsy is offline   Reply With Quote