N-gram Text Generators

One of the most parsed and scrutinized bodies of text is the presidential address, so it was the first thing that came to mind to try to replicate with text generation. State of the union addresses use a consistent language that is very intentional, and a vocabulary latent with meaning. Because of the repetition of certain words and phrases it should be perfect for breaking down with N-grams and reassembling. Here is a trigram generated 50 word speech that seems surprisingly interesting (1st attempt), where the generator was only trained from Obama’s inaugural address:

“action , bold and swift , and we will defeat you . For us , they knew that our power grows through its prudent use ; our security emanates from the justness of our hardship, let us mark this day with remembrance , of protecting narrow interests and putting off unpleasant decisions”

I don’t think his meaning was conveyed, but the dramatic nature of his language when scrambled like this, is dangerous. And so funny.

and it was consistent (2nd run):

“again the work of remaking America . For us , they knew that our power grows through its prudent use ; our security emanates from the justness of our liberty and our creed – why men and women can achieve when imagination is joined to common purpose , and we will defeat you”

To make this controlled I used only state of the union and inaugural addresses to train the program, this time for Obama, Bush, and Clinton, where Bush and Clinton had 8 speeches, and Obama only 4, to see if there was a clear distinction:

bigrams:

Obama:

” which the next 5 years old , our deficit down the first step in history ; and their children that will not interested in the next generation of our deficit by the American people . But we know exactly how we are willing to the American people . And that they love of a new era . But we have taken amidst “

“national commitment has come from a new jobs in the world . This is to make permanent extension of the most of Americans . ” We proved more . There are the world , the American . That is why this plan we will be easy process left and we can do . We will work making tough decisions . One man “

Bush:

” unprecedented action is more secure our Nation has a new markets for a unique role in the world to the system of our Nation needs more hopeful society . ” And I will be the depth of our Nation ‘ s most dangerous weapons , to keep America . And we will do everything we must upgrade our military action because you ”

” and directs Federal Government is the world . In the Federal Government toil day , and the Federal Government has not allow it . And we are not a new jobs . A simple chemical agents . We must be used poison gas to defend the fight diseases . We have no longer protected by the American families and women who do ”

” of spending below inflation is a new century , however , to the Federal budget I thank the terrorists . We have a time , the world toward addressing problems of our troops , the terrorists and the United States . Today , which is not a better life . They are working with a new jobs in the American families will”

Clinton:

“joint endeavor . I hope we know , we must continue to the American people have to keep our own people with us in the people with a good for symbolizing our future . Now , a new national standards , a way — [ Applause ] I have to make real credit card records confidential . And we can go to”

“mistakes . I want to help Russia will help communities all of the first , we have to make it . < Gore , we have to pay our children , and our gift we can make sure that has gone down . Every State should also to the United States and every parent isn ‘ s the world . We have
administration .”

“Now I say to the safest big polluters live on welfare rolls , that the baby boom . That ‘ s a good reason — and drugs are in our future . And we must work with the last Congress to take the next century , but because they need to reduce crime is not to work and we will”

trigrams:

Obama:

“exactly how and where their next paycheck will come from . Thirty years ago , we ‘ ll invest in our Constitution : the notion that we can ‘ t afford it . Talk to the Top should be treated no different than anyone else — is spark the creativity and imagination of our people . We may have different opinions , but also our collective failure to make sure that what sets us apart as a nation cannot prosper long when it favors only the pleasures of riches and fame . Rather than fight the same . So , tonight , instead”

Bush:

“and now their Government should open paths of peaceful opposition that will be able to defend the sanctity of marriage . Because one of the United States and our friends and allies . To make our economy . Even worse , over 90 percent of international terrorism . During the 1990s , had several mobile biological weapons . America will lead the world .Our third responsibility to nominate men and women who advocate these values around the world . By passing these reforms would be catastrophic . We must also ensure that America is a seed upon the wind , taking root”

“the cars and trucks of the people and defend the sanctity of marriage . Because one of the American people are using illegal drugs than in the world to fend for itself , we ‘ re providing more funding for abstinence programs , including members of the Iraqi people value their own money ; a family of 4 with an income of $ 40,000 would see their drug bills cut roughly in half . Under the No Child Left Behind Act is opening the door to freedom . Our military has put the wealth of Iraq , and we will finish well ?”

Clinton:

“of over 100 programs we do everything possible to keep our schools open after hours , on slave ships , whether they came yesterday or walked this land even a better tomorrow . Oh , there are still serious differences over the next generation Internet will operate at speeds up to 5 million children . I know it ‘ s double our investments in science and technology will be disrupted . That is why the bipartisan package as your first order of business . Tom Mauser , Tom < ls – thn – eq > and Feingold , Russell D . > and”

No matter how many times I ran the Clinton trigram, it was always primarily about children.

“announce that four former Chairmen of the cold war . All these threats today , we don ‘ t do anything to infringe on the books better . SAT scores are up 16 percent since 1993 , we all know something else too : A check will never substitute for a newborn baby or an ailing relative without risking their jobs and may even lure people back into our elementary schools to teach character education must start at birth and continue throughout a lifetime . Soon researchers will complete their mission in Bosnia and around the world . For years and years to”

4-grams:

Obama:

“decade , America will once again have the highest proportion of college graduates in the world . We have also taken the fight to al Qaeda , we are responding with the strength of our union . For 220 years , our leaders have fulfilled this duty . They have something to tell us , just as our competitors are . If America sits on the sidelines while other nations sign trade deals , we will work with nearly 50 countries to begin a transition to an Afghan lead , and this July , we will deny al Qaeda the safe – haven that”


“nobody accountable for their reckless decisions . But such an approach won ‘ t take meaningful steps to rein in our deficits , we can deliver on that promise . It begins with energy . We know what it takes to travel by car . For some trips , it will be harder because we will argue about everything — the cost , the details , the letter of every law . Of course , none of these reforms will even happen if we guard against the same recklessness that nearly brought down our entire economy . We need to teach them that success”

Bush:

“no change for those now retired or nearing retirement . And we ‘ re asking them to join us , and lead this world toward freedom . Here at home , including safe , clean nuclear energy . My administration is promoting free and fair elections . We have seen the depth of their hatred is equaled by the madness of the destruction they design . We have seen wedding guests in blood – soaked finery staggering from a hotel in Jordan , Afghans and Iraqis blown up in mosques and markets , and trains in London and Madrid ripped apart by bombs .”

Clinton:

“cleaning the environment up ? I know we can . That should be our commitment . We must fortify African democracy and peace and to oppose those who would tear it apart . Here are the fundamental challenges I believe America must meet to shape the 21st century . Early in this century . Yet perhaps , in the clash of controversy , we don ‘ t have to spend all their time stalled in traffic when they could be home with their parents or in other supervised settings , by requiring them to finish school . But we must do more . Like”

And finally, a speech by generator trained an the state of the union addresses of all three of these presidents:

that don ‘ t think anybody in America wants us to let politics stop at the schoolhouse door . Since then , about 15 million people have taken advantage of it , and neither option is acceptable . This is a regime that has something to hide from the civilized world . All free nations have a stake in preventing sudden and catastrophic attacks . And we must give people , especially young men in our cities , better options than apathy or gangs or jail . Tonight I ask the Congress to pass legislation to prohibit the most egregious abuses of medical research : Human cloning in all its forms ; creating or implanting embryos for experiments ; creating human – animal hybrids ; and buying , selling , patenting , or cloning of human beings . We should give every college in America the opportunity to save millions of lives together , and now exports are at an all – time highs . Now we must act to address rapidly rising health care costs and make sure patients have the doctors and care they need . We will not rest until this enemy has been defeated . We must also confront the larger challenge of mandatory spending , or entitlements . This year , we will not pass along our problems to other Congresses , to other Presidents , and other sports is dangerous , and it is not carried forward by our power alone cannot protect us , nor does it entitle us to do three things . We gather tonight in a world where their talents are matched by their opportunities . I ‘ ve got to have a license . I think we should seek to advance worker and environmental standards around the world — we have to know the┬áhistory of the program . We should do more to help all towns which have been really hurt when businesses close . I hope you in Congress will pass it quickly . It is the inborn hope of our humanity , an ideal we carry but do not own , a trust we bear and pass along . Even after nearly 225 years , we have to continue to reform our intelligence agencies , broken up terror cells across the country . Race to the Top should be the approach we follow this year as we replace No Child Left Behind Act , preserving local control , raising standards , raising expectations , and raising accountability . Thanks to the work of fixing our broken immigration system — to secure our borders — and with your help , my Administration reached agreement with Speaker Pelosi and Republican Leader Boehner on a robust growth package that includes tax relief for individuals and families and incentives for business investment . The temptation will be to load up the bill . That would delay it or derail it , and neither option is acceptable . This is our most solemn duty . We are working with Muslim communities around the world . The American people have turned in an economic performance that is the case , America is feeding the hungry . More than anyone else — is spark the creativity and imagination of our people . In victory , we have to confront the fact that our country was rated as having the world ‘ s primary state sponsor of terror , pursuing nuclear weapons while depriving its people of the gulf coast and New Orleans . There are 57 police officers who gave their lives there . Our forces are on the rise again among “

Besides the obvious Bushisms, Obamaisms, and Clinton child obsessionism, the last mixed generated speech reminded me that there was a lot of similarity in all of their speeches.

Finally, a five gram speech of Obama/Bush/Clinton style:

“to preserving two of the most important guarantees we make to every American , Social Security and Medicare and Medicaid are commitments of conscience , and so it is our duty to keep them permanently sound . Yet we are failing in that duty , and this failure will one day leave our children with three bad options : huge tax increases , huge deficits , or huge and immediate cuts in benefits . Everyone in this Chamber knows this to be true , yet somehow we have not found it in ourselves to act . So let us mark this day with remembrance , of who we are and how far we have traveled . In the year of America ‘ s most creative minds as they explore promising areas such as nanotechnology , supercomputing , and alternative energy sources . Second , I propose to double the Federal commitment to the most critical basic research programs in the physical sciences over the next 10 years , with penalties on the tobacco industry if it keeps marketing to our children . And on that score , we will be cutting our total imports by the equivalent of three – quarters of all the oil we now import from the Middle East to Haiti , from Northern Ireland to Bosnia to the Middle East , and gain the weapons to kill on an even more horrific scale . In the sixth year since our Nation was attacked , I wish I could report to you that the dangers had ended . They have promised to deploy more of their own troops to secure Baghdad , and they must do so . They have pledged that they will confront violent radicals of any faction or political party . And they need to follow through and lift”