import enchant
import wx
from enchant.checker import SpellChecker
from enchant.checker.wxSpellCheckerDialog import wxSpellCheckerDialog
from enchant.checker.CmdLineChecker import CmdLineChecker
a = "Ceci est un text avec beuacuop d'ereurs et pas snychro"
chkr = enchant.checker.SpellChecker("fr_FR")
chkr.set_text(a)
cmdln = CmdLineChecker()
cmdln.set_checker(chkr)
b = cmdln.run()
c = chkr.get_text() # returns corrected text
print c
How do I get c
to return the corrected text without using 0
manually from cmdlinechecker
?
The program should run through the string containing the uncorrected text, correct it, and save it in a variable to export into a MySQL DB.
Click File > Options > Proofing, clear the Check spelling as you type box, and click OK. To turn spell check back on, repeat the process and select the Check spelling as you type box. To check spelling manually, click Review > Spelling & Grammar. But do remember to run spell check.
Checking of spelling is a basic requirement in any text processing or analysis. The python package pyspellchecker provides us this feature to find the words that may have been mis-spelled and also suggest the possible corrections.
PyEnchant is a spellchecking library for Python, based on the excellent Enchant library. PyEnchant combines all the functionality of the underlying Enchant library with the flexibility of Python and a nice “Pythonic” object-oriented interface.
a = "Ceci est un text avec beuacuop d'ereurs et pas snychro"
chkr = enchant.checker.SpellChecker("fr_FR")
chkr.set_text(a)
for err in chkr:
print err.word
sug = err.suggest()[0]
err.replace(sug)
c = chkr.get_text()#returns corrected text
print c
Works exactly as I was intending to have it work. Add Filters and corrects all small text automatically enabling you to perform keyword searches etc...
Took me 13hrs to figure out ;(
Actually I am not familiar with python and the libraries you describe but the general approach to correct text is using a dictionary approach. This means in other words, that you check if a word is included in a French dictionary (or a list of French words) and if it is the case, the word is correct, otherwise use the word from the dictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With