Created
July 21, 2016 00:29
-
-
Save baileylo/54b4df4f5b310e8be25ca92270b4400b to your computer and use it in GitHub Desktop.
A speech writer designed to prevent plagiarism
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($argc < 2) { | |
echo "Please enter a number of words for the speech\n"; | |
exit(1); | |
} | |
$dictionary = explode(PHP_EOL, `cat /usr/share/dict/words`); | |
$speech = []; | |
$max_words = (int)$argv[1]; | |
for($word_count = 1; $word_count <= $max_words; $word_count++) { | |
$word = $dictionary[random_int(0, count($dictionary))]; | |
// Try to make sentences around 6 words long | |
$speech[] = $word . (random_int(0, 5) < 1 ? '.' : ''); | |
} | |
echo implode(' ', $speech) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment