Playing with NLTK

18 February 2010

I spent some time this afternoon playing with NLTK, the Python Natural Language Toolkit; the book is highly recommended. I couldn’t resist sharing the results of the first time I tried its generate function, which takes a particular text and tries to automatically generate more text in the same style.

First, from the Book of Genesis:

In the selfsame day entered Noah , and asses , flocks , and Maachah .
And Joseph said unto him , Abrah and he asses , and told all these
things are against me . And Jacob told Rachel that he hearkened not
unto you . And Sarah said , I had seen the face of the air ; for he
hath broken my covenant between God and every thing that creepeth upon
the man : And Eber lived after he begat Salah four hundred and thirty
years , and took of every sort shalt thou be come thither .

Next, Jane Austen:

[ Sense and Sensibility by Jane Austen 1811 ] CHAPTER 1 The family of
his relations , I know Marianne ‘ s indisposition , beyond giving time
for the world to seeing YOU .– Very far from being weary of her
feeling how more than commonly joyful . He was four years . Every
thing was disregarded . I had called in Berkeley Street , January . ”
Mrs . Jennings , sagaciously smiling , ” For my part , not being
Willoughby , where much of his fate with Miss Morton , with two
pointers playing round him ,

And finally, from a corpus of IRC conversations:

now im lost i agree i saw the whole thing JOIN PART google ‘s start
page .. lol yeah , he said this morning he is hoping they win tonight
im gay ……. im happy as hell …… jus aint #### lol U42 , how are
you NICK : U23 what a combo hehehe JOIN . ACTION pictures the blues
brothers behind that chicken wire screen . (((((((((( U34
))))))))))))) Hi U7 ……… how are ya ll gotta watch my manners or
she wo n’t you play another somebody done somebody wrong song ? JOIN .
ACTION wonders if U16

Scarily accurate :-)