Need Help

Piet van Oostrum piet at
Sun May 24 18:16:19 EDT 2009

>>>>> abosalim <mohammed.abosalim at> (a) a écrit:

>a> #Gui
>a> import re, collections
>a> from Tkinter import *
>a> from nltk_lite import tokenize

>a> def words(text): return re.findall('[a-z]+', text.lower())
>a> def train(features):
>a>     model = collections.defaultdict(lambda: 1)
>a>     for f in features:
>a>         model[f] += 1
>a>         return model

The return statement should be shifted left 4 spaces. Now it is inside
the loop instead of after the loop.

By the way, it is better to add python code as attachment instead of
inline text because some news software might fold the lines like in your
posting, making it difficult to reconstruct the code.

>a>     def new(self):
>a>         self.string = self.contents.get()
>a> #pass contents of textfield to words()method above
>a>         self.res=  words(self.string)
>a>         self.frame2 = Frame()
>a>         self.frame2.pack()
>a>         self.words = Label(self.frame2, text=self.res, fg="blue", font=
>a> ("Arial", 16))
>a>         self.words.pack()

>a> It print text without correction.I think it didn't enter the method or
>a> any method above the gui.
>a> Please if you have any information,inform me

You don't call correct() or textcorrect() anywhere in your GUI code.
I think instead of self.res=  words(self.string) you should call one of

Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list