Scanning a file character by character

2009-02-04 Thread Spacebar265
Hi. Does anyone know how to scan a file character by character and
have each character so I can put it into a variable. I am attempting
to make a chatbot and need this to read the saved input to look for
spelling mistakes and further analysis of user input.
Thanks
Spacebar265
--
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file character by character

2009-02-08 Thread Spacebar265
On Feb 7, 2:17 am, Jorgen Grahn  wrote:
> On Wed, 4 Feb 2009 22:48:13 -0800 (PST), Spacebar265  
> wrote:
> > Hi. Does anyone know how to scan a filecharacterbycharacterand
> > have eachcharacterso I can put it into a variable. I am attempting
> > to make a chatbot and need this to read the saved input to look for
> > spelling mistakes and further analysis of user input.
>
> That does not follow. To analyze a text, the worst possible starting
> point is one variable for eachcharacter(what would you call them --
> character_1, character_2, ... character_65802 ?)
>
> /Jorgen
>
> --
>   // Jorgen Grahn  \X/     snipabacken.se>          R'lyeh wgah'nagl fhtagn!

How else would you check for spelling mistakes? Because input would be
very unlikely to be lengthy paragraphs I wouldn't even need very many
variables. If anyone could suggest an alternative method this would be
much appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file character by character

2009-02-09 Thread Spacebar265
On Feb 9, 5:13 pm, Steve Holden  wrote:
> Spacebar265 wrote:
> > On Feb 7, 2:17 am, Jorgen Grahn  wrote:
> >> On Wed, 4 Feb 2009 22:48:13 -0800 (PST), Spacebar265 
> >>  wrote:
> >>> Hi. Does anyone know how to scan a filecharacterbycharacterand
> >>> have eachcharacterso I can put it into a variable. I am attempting
> >>> to make a chatbot and need this to read the saved input to look for
> >>> spelling mistakes and further analysis of user input.
> >> That does not follow. To analyze a text, the worst possible starting
> >> point is one variable for eachcharacter(what would you call them --
> >> character_1, character_2, ... character_65802 ?)
>
> I believe most people would read the input a line at a time and split
> the lines into words. It does depend whether you are attempting
> real-time spelling correction, though. That would be a different case.
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/

Thanks. How would I do separate lines into words without scanning one
character at a time?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Scanning a file character by character

2009-02-12 Thread Spacebar265
On Feb 11, 1:06 am, Duncan Booth  wrote:
> Steven D'Aprano  wrote:
> > On Mon, 09 Feb 2009 19:10:28 -0800, Spacebar265 wrote:
>
> >> How would I do separate lines into words without scanning one character
> >> at a time?
>
> > Scan a line at a time, then split each line into words.
>
> > for line in open('myfile.txt'):
> >     words = line.split()
>
> > should work for a particularly simple-minded idea of words.
>
> Or for a slightly less simple minded splitting you could try re.split:
>
> >>> re.split("(\w+)", "The quick brown fox jumps, and falls over.")[1::2]
>
> ['The', 'quick', 'brown', 'fox', 'jumps', 'and', 'falls', 'over']
>
> --
> Duncan Boothhttp://kupuguy.blogspot.com

Using this code how would it load each word into a temporary variable.
--
http://mail.python.org/mailman/listinfo/python-list