View Single Post
Old 10-07-2015, 06:13 PM   #91
gipsy
Connoisseur
gipsy began at the beginning.
 
Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
And I test the following...

Code:
############ FIXES Π ###########		
def IsFixP(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
	"""
	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(1)+m.group(2))


############ FIXES έ ###########		
def IsFixE(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
	"""
	FixE=m.group(1)+"έ"+m.group(2)
	FixE2=m.group(1)+"ύ"+m.group(2)
	if spell(FixE2):
		return(m.group(1)+"ύ"+m.group(2))
	elif spell(FixE):
		print("FixE removed from: ", FixE)
		return(m.group(1)+"έ"+m.group(2))
	else:
		return(m.group(1)+"ύ"+m.group(2))

####################

		#Fixes Π in words that are misspelled
		if dictExists == True:
			CorrectText("Π fixes",r"(1\ Ι|1\ Ι|1Ι|1I|ΓΙ|Γΐ|ΙΙ|II|Ι\ Ι|ΓΤ|ΙΊ|Ιί)[ ]?(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", IsFixP)

		#Fixes έ in words that are misspelled
		if dictExists == True:
			CorrectText("έ fixes",r"(\w+)ύ(\w+)(?![^<>]*>)(?!.*<body[^>]*>)", IsFixE)
There is any simple way to sort the changes for those in the plugin runner? Or have the list of changes like the IncorrectWords -> "Changed "+mispelt+" to "+correctSpell or extract the Messages from the plugin runner. To check the fixes.

I was trying to another one. But i can't figure out how to create the CorrectText for the («ρ|(ρ|4&gt;|&lt;ρ|ηι) . The group can be at the start or at the middle of some word.

If i figure how to get the regex... i had another group to make a FixSomething

I attach and a IncorrectWords for greek words.

CalibUser... In FixP seems that it doesn't fix it when we have a lowercase after the (1\ Ι|ΓΙ|Γΐ|ΙΙ|II|Ι\ Ι|ΓΤ|ΙΊ|Ιί). When you have time can you check the code for both?

Thanks!

EDIT: A suggestion for the future and if it's possible... I add about 400-500 words to a user dictionary per epub and I edit the WordDictionary to add the new ones. It's possible to change the plugin to not use the WordDictionary but to get the words from the Sigils dictionary and selected userdictionaries?
Something like how the sigil get the misspelled word in spellcheck.
Attached Files
File Type: txt IncorrectWordsGreek.txt (1.8 KB, 318 views)

Last edited by gipsy; 10-07-2015 at 06:21 PM.
gipsy is offline   Reply With Quote