dariusk / NaNoGenMo

National Novel Generation Month. Because.
184 stars 16 forks source link

I'm in! #23

Open poik007 opened 10 years ago

poik007 commented 10 years ago

This is a story about boy meets girl. Boy meets girl girl perfect woman. Boy meets girl girl perfect woman lyrics. Lyrics search. Lyrics search by artist. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia. Artistry by sophia.

poik007 commented 10 years ago
<?php
$novel = "";
$nbWords = 5;
$totalWords = 100;
$string = "This is a story about";
$oldLine = "";
$changeItUp = array("in the first place","not only","but also","as a matter of fact","in like manner","in addition","coupled with","in the same fashion","first","in the light of","not to mention","to say nothing of","equally important","by the same token","again","to","and","also","then","equally","identically","uniquely","like","as","too","moreover","as well as","together with","of course","likewise","comparatively","correspondingly","similarly","furthermore","additionally");
do
{
    $xml = simplexml_load_file("http://google.com/complete/search?output=toolbar&q=" . $string);
    $potentials = array();
    foreach($xml->children() as $sug)
    {
        $potentials[] =(string)$sug[0]->suggestion->attributes()->data[0];
    }
    $chosen = $potentials[array_rand($potentials)];
    $nbWords += str_word_count($chosen);
    $chosen = ucfirst($chosen);
    if($oldLine == $chosen)
    {
        $chosen = ucfirst($changeItUp[array_rand($changeItUp)]);
    }
    $novel .= $chosen . ". ";
    $oldLine = $chosen;
    $newString = str_replace($string . " ","",$chosen);
    $string = $newString;
}
while($nbWords < $totalWords);
print $novel; 
?>
dariusk commented 10 years ago

Nice :)

dariusk commented 10 years ago

Um also I just looked at this again and I had no idea about the autocomplete endpoint! That's amazing.

poik007 commented 10 years ago

V 0.0002

<?php
$novel = "";
$nbWords = 5;
$string = "this is a story about";
$oldLine = "";
$change = array("in the first place","not only","but also","as a matter of fact","in like manner","in addition","coupled with","in the same fashion","first","in the light of","not to mention","to say nothing of","equally important","by the same token","again","to","and","also","then","equally","identically","uniquely","like","as","too","moreover","as well as","together with","of course","likewise","comparatively","correspondingly","similarly","furthermore","additionally","although this may be true","in contrast","different from","of course ..., but","on the other hand","on the contrary","at the same time","in spite of","even so","be that as it may","then again","above all","in reality","after all","but","unlike","or","while","albeit","besides","as much as","even though","although","instead","whereas","despite","conversely","otherwise","however","rather","nevertheless","nonetheless","regardless","notwithstanding","in the event that","granted","asso long as","on condition","for the purpose of","with this intention","with this in mind","in the hope that","to the end that","for fear that","in order to","being that","in view of","If","... then","unless"," ","when","whenever","while","because of","as","since","while","lest","in case","provided that","given that","even if","so that","so as to","owing to","inasmuch as","due to","in other words","to put it differently","for one thing","as an illustration","in this case","for this reason","to put it another way","that is to say","with attention to","by all means","important to realize","another key point","first thing to remember","most compelling evidence","must be remembered","point often overlooked","to point out","on the positive side","with this in mind","notably","including","like","to be sure","namely","chiefly","truly","indeed","certainly","surely","markedly","especially","specifically","expressively","surprisingly","frequently","significantly","in fact","in general","in particular","in detail","for example","for instance","to demonstrate","to emphasize","to repeat","to clarify","to explain","to enumerate","such as","as a result","under those circumstances","in that case","for this reason","in effect","for","thus","because the","then","hence","consequently","therefore","thereupon","forthwith","accordingly","henceforth","as can be seen","generally speaking","in the final analysis","all things considered","as shown above","in the long run","given these points","as has been noted","in a word","for the most part","after all","in fact","in summary","in conclusion","in short","in brief","in essence","to summarize","on balance","altogether","overall","ordinarily","usually","by and large","to sum up","on the whole","in any event","in either case","all in all","Obviously","Ultimately","Definitely","at the present time","from time to time","sooner or later","at the same time","up to the present time","to begin with","in due time","as soon as","as long as","in the meantime","in a moment","without delay","in the first place","all of a sudden","at this instant","first, second","immediately","quickly","finally","after","later","last","until","till","since","then","before","hence","since","when","once","about","next","now","formerly","suddenly","shortly","henceforth","whenever","eventually","meanwhile","further","during","in time","prior to","forthwith","straightaway","by the time","whenever","until now","now that","instantly","presently","occasionally","in the middle","to the left/right","in front of","on this side","in the distance","here and there","in the foreground","in the background","in the center of","adjacent to","opposite to ","here","there","next","where","from","over","near","above","below","down","up","under","further","beyond","nearby","wherever","around","between","before","alongside","amid","among","beneath","beside","behind","across");
set_time_limit(0);
do
{
    if($string != "")
    {
        $page = utf8_encode(file_get_contents("http://google.com/complete/search?output=toolbar&q=" . rawurlencode($string)));
        $xml = simplexml_load_string($page);
        $potentials = array();
        if(is_object($xml))
        {
            foreach($xml->children() as $sug)
            {
                $potentials[] =(string)$sug[0]->suggestion->attributes()->data[0];
            }
            if(count($potentials) == 0)
            {
                $string = $change[array_rand($change)];
            }
            else
            {
                $chosen = $potentials[array_rand($potentials)];
                $chosen = strtolower($chosen);
                if(str_word_count($chosen) <= 3)
                {
                    $chosen = $change[array_rand($change)] . " " . $chosen;
                }
                $nbWords += str_word_count($chosen);

                if($oldLine == $chosen)
                {
                    $chosen = $change[array_rand($change)];
                }

                $r = rand(0,100);
                if($r < 5)
                {
                    $novel .= $chosen . ". <br /><br />";
                }
                else if($r < 50)
                {
                    $novel .= $chosen . ". ";
                }
                else if($r < 90)
                {
                    $novel .= $chosen . ", ";
                }
                else
                {
                    $added = $change[array_rand($change)];
                    $nbWords += str_word_count($added);
                    $novel .= $added . " " . $chosen . " ";
                }

                $oldLine = $chosen;
                $newString = str_replace($string . " ","",$chosen);
                $string = $newString;
            }
        }
        else
        {
            $string = $change[array_rand($change)];
        }
    }
    else
    {
        $string = $change[array_rand($change)];
    }
}
while($nbWords < 1000);
print $novel; 
?>
poik007 commented 10 years ago

finally butternut squash recipes. above all further, to demonstrate above all furthermore. that is to say crossword. at the present time crossword tracker. without delay to point out nextmuni in view of asus. in brief in view of in fact in view of fact. comparatively. equally important comparatively speaking, on the positive side thesaurus, surely thesaurus opportunity. nonetheless last fm, notwithstanding whenever you're ready, unlike dna rna contains. unlike dna rna contains answer, unlike answer ask.fm, in time ask.fm. given these points behindwoods. in general the spectral lines of molecules are.