Sunday, 1 January 2017

NLP and Language Generation

From time to time I try to write programs that will generate language.  I do this because I often get interesting results.  Those results, however, are not even remotely close to real language.  Still, I try.  Here is my latest pass.

The program reads a book, in this case, Kev, and then analyzes the content and then spits out its version of the book.  I'd go into the details, but it is pretty technical, and technically, my approach is wrong, but, given that I only spent about twenty minutes on this today, it is a good start...

Here is a snippet:

Barrow I found Clives mind What Weve got back in the Are After You Figured Out Experience Sphere on Another possible types of yours Kev said the rem
ains .
This was in back at one person who I will be too .
In that make continue writing books interesting characters of the kitchen counter my time to save the break the blue .
At one point in the park laughing and I guess so he disappeared and even if I felt the bills after dinner B24ME again didnt Ill have known her but f
ound something for some fun .
Wait a rather Changing subjects  anything to the end .
He and kids B24ME I Millions of you If you hotel lobby Kev I said Cube Im The next The Show she A distortion in I gave What I Clive Wonderful I Thos
e wings After The If I Aputi This was The sphere I placed Those in Figured Id Forget The universe Of course Yeah I had over to explain that  About t
hirty-seven days later if I want to recreate the fort until a matter the .
Now wasnt human matter Its an ants I had all went back to Uthio Minor in this girl about something far away from anywhere I had put you going to .
Anyway you know that one to end go to .
Note that with toys All I utter surety you was the cubes a way little yellow .
I am back impaired Great and lumbered away over and were mismatched and me I said Clive Why cant kill me to go get .
If you have to me red cube and stop would try in the same descriptions people Nothing happened realizing I .
I left over and started a strange dream a vague in going the universe would tell me a small park laughing and .
I dont that led me and Jesus when he finds me voice told me I never should press it through challenges for hours said you I said material assistance
 rule I like Youll figure things my .
I raced trying to some at the sound of the planet almost completely unnecessary question truthfully when will figure out of nowhere mowed her hand I
 know each had been on Kev large number of the the picnic table a gun out I together Lovely said annoyed as the I appeared in .
Despite birth So what else is a philosophical discussion of television something didnt remember me .
I set to make any greater satisfaction .
At that I now girl and girls and nightmares is ?
No I a visit and saw way I had made any further probably lose your mind I had a planet is  Now I felt something now Aputi had not I will allow me I
wish I I forgotten sitting .
Now  About Me too small workshop constructed by wishing to wondering what it will create a most powerful containment field generator .
I know I felt became mine that hinted that ever existed Well how .
Much of the table telling know of my desk a strange horned .
At that is a message read it surprised to go back probably hell was hell said Clive said Brok What was going to the hands disintegrating .
Of course fingers a quite helpful I am sick of course it Like where I had forgotten havent been more damage you grabbed .
Everyone Ah is Aputi know how can connect Yeah well I approached finally one with only one .
I could see and B24ME into the way out all of trillions of the Canadians involvement in the girl on this answer for that day I know Lets go My frien
d if you know Kev a .
After a wishing cube to me from me there and understanding of us there but I said Ruby and knew this time making a trick to get both of your own def
inition for some do this boy named Bri from a hundred thirty-seven that I turned .
 I knew I returned to hunt made a different lives an hour and said I just got in time I did in love mixed with a previous book than I had disappeare
d  About thirty-seven quadrillion quadrillionanyway you know anyone to take it twice my dad I scooped a complete lack of hell is rule is I just arri
ved including one I wished cant remember from Uncle Joe flew into song for a part of all you could get my temple and I appeared in a is the who are
not going to end of surprise you for appearances on Earth or at the others might be sucked into days so or at me I knew reading it out for .
Kev Then I ?
Needless to kill me in danger and punched and you and Clive had to kill me I knew I didnt say Hey Max and through all the evidence seems to check on
 Earth that everyone other home to this I pulled out the girl and that nightmare come on and a chair .
Are you tell down on Galthinon I am going to have named after him in awake to say  About a trap me my studies my Look if you might  the unlikely tha
t for Aputi go to find it or the infinite to leave soon  About thirty-seven days later a perfect love to check your large portion of locations in I
was being responsible for the yellow cube so messages about .
I knew up things that you havent you will if you have a room and stopped you to attend  Now you that often given that I said Max wondering if he bac
k Ill come back in Connecticut my days later rules .
 Now I am normal circumstances being there One of all killed me to do to get help but you The response Hey Kev laughed .
Moments later my B24ME and jump out  About three The Show You look saying the boys Clive coming to be thirty-seven billion light-years Doug Aputi wi
ped everything has really got Sorry Turd Fondler Forget I suspected this Clive the Proth B24ME hoping Clive Which one side with a football stadium w
ith the universe Where are you think it said the Lost Hope Hotel Three days Max said the The voice said Clive and then I Kev said ignoring Clive has
 believed that God as you take any sense I thought you will prior universe I said Aputi could wish Nope but I did Why did not need Singularity  Now
I will take That does roof and saw a of anything else had Were never read all of an is a goofy grin on Uncle Joes Clive panting Ruby I woke what con
stituted material world around The sphere exists again and Clive as you can Aputi I survived his head a couple hundred The alien races this a kiss a
nd put it Well Clive and I know that I die many things out B24ME was I So all home into Call me at the rules after the number given me to manipulate
 Doug Great We In that has inside of not remember his face changed into space but were already knew it Return Contestant The Do you a it just that .
I had written this just delivered the building the red dragon it real name she said .
I had no game said Does he wouldnt budge  About Me No The voice telling me this way a little yellow .
You might want to know that Clive did possibly be with my green tea The cities on a deal to the rules .
Show said Clive Bri the lines of yours said annoyed as writing the voice a .
Well I swear  Now ?
 Now why the woman finished and of a knock .


So, some interesting stuff is generated, but for the most part it is jibberish.  Most of this is based on statistics, but there are some other rules governing the behavior, like giving weight to words in the beginnings of sentences based on how often they actually do begin sentences in the source text.  Also, I look at parts of speech and whether or not things are bigrams or are just plain colocated in sentences, although that is not so heavily weighted.  The next phase of this is noun verb agreement, keeping track of actors and giving the text consistency.  The end goal is a program or set of programs that can write something that makes sense, of course, but that is a long long way off.  Translated:  20 minutes will easily turn into weeks or months. 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.