Python + TextBlob: Printing typos only

417
January 05, 2017, at 08:48 AM

I'm trying to write some code that will read some text and print out only misspelled words. I'm using TextBlob and this is how it presents results:

>>> w = Word('yelow')
>>> w.spellcheck()
[('below', 0.6052631578947368), ('yellow', 0.39473684210526316)]

The code I wrote (I'm a beginner, mind you) prints the word only if the numeric part is lower than 1.0. The problem is when more than one spelling suggestion is presented, as there are multiple numeric values, as in the example above.

This is what I have:

spellchars = "[('.', )qwertyuiopasdfghjklzxcvbnm!@#$%^&*()--+={}\|;:]"

def spell():
    for a in corpus:
        typo = Word(a)
        typostr = str(typo.spellcheck())
        for char in spellchars:
            typostr = int(typostr.replace(char,""))
            if typostr < 10:
                print(typostr)

Any simpler, working way to have typos printed out?

Thanks for your help!

READ ALSO
pd.qcut with values that are inf (infinity) ValueError: Bin edges must be unique:

pd.qcut with values that are inf (infinity) ValueError: Bin edges must be unique:

I have a data set that is a ratio of 2 float type numbersSome values have inf for infinity (divide by zero) situation

487
Python / Raspberry Pi script does not show keyboard input after quitting

Python / Raspberry Pi script does not show keyboard input after quitting

I am somewhat new to python / raspberry PiI am creating a little music clip launcher using omxplayer & the readchar library

384
pd.qcut - ValueError: Bin edges must be unique

pd.qcut - ValueError: Bin edges must be unique

My data: http://pastebincom/RxxxXBYB

1014
Simple way to subset multiple data frames with pandas groupby or other function?

Simple way to subset multiple data frames with pandas groupby or other function?

I think this should be a relatively straight forward askI have a DataFrame with two columns that I got with this command result = pd

405