Skip to content

Instantly share code, notes, and snippets.

@neoeno
Created August 1, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neoeno/68a199005ef189d83a19b862682e68eb to your computer and use it in GitHub Desktop.
Save neoeno/68a199005ef189d83a19b862682e68eb to your computer and use it in GitHub Desktop.
Basic PHP strachey love letter algorithm extracted from https://github.com/gingerbeardman/loveletter
$sals1 = array("Beloved", "Darling", "Dear", "Dearest", "Fanciful", "Honey");
$sals2 = array("Chickpea", "Dear", "Duck", "Jewel", "Love", "Moppet", "Sweetheart");
$adjs = array("affectionate", "amorous", "anxious", "avid", "beautiful", "breathless", "burning", "covetous", "craving", "curious", "eager", "fervent", "fondest", "loveable", "lovesick", "loving", "passionate", "precious", "seductive", "sweet", "sympathetic", "tender", "unsatisfied", "winning", "wistful");
$nouns = array("adoration", "affection", "ambition", "appetite", "ardour", "being", "burning", "charm", "craving", "desire", "devotion", "eagerness", "enchantment", "enthusiasm", "fancy", "fellow feeling", "fervour", "fondness", "heart", "hunger", "infatuation", "little liking", "longing", "love", "lust", "passion", "rapture", "sympathy", "thirst", "wish", "yearning");
$advs = array("affectionately", "ardently", "anxiously", "beautifully", "burningly", "covetously", "curiously", "eagerly", "fervently", "fondly", "impatiently", "keenly", "lovingly", "passionately", "seductively", "tenderly", "wistfully");
$verbs = array("adores", "attracts", "clings to", "holds dear", "hopes for", "hungers for", "likes", "longs for", "loves", "lusts after", "pants for", "pines for", "sighs for", "tempts", "thirsts for", "treasures", "yearns for", "woos");
define(SHORT, 1);
define(LONG, 2);
$last = NULL;
$ll = sprintf("%s %s,\n ", rel($sals1), rel($sals2));
for($i=0; $i<5; $i++) {
if (mt_rand(0,9) < 5) {
//LONG
$optadj1 = (mt_rand(0,9) < 5) ? '' : rel($adjs);
$noun1 = rel($nouns);
$optadv = (mt_rand(0,9) < 5) ? '' : rel($advs);
$verb = rel($verbs);
$optadj2 = (mt_rand(0,9) < 5) ? '' : rel($adjs);
$noun2 = rel($nouns);
if ($last != NULL || $last == LONG) {
$concat = ". ";
}
$ll .= sprintf("%s My %s %s %s %s your %s %s", $concat, $optadj1, $noun1, $optadv, $verb, $optadj2, $noun2);
$last = LONG;
} else {
//SHORT
$adj = rel($adjs);
$noun = rel($nouns);
if ($last == SHORT) {
$concat = ", ";
} elseif ($last == LONG) {
$concat = ". You are";
} else {
$concat = "You are ";
}
$ll .= sprintf("%s my %s %s", $concat, $adj, $noun);
$last = SHORT;
}
}
$adv = rel($advs);
$ll .= sprintf(".\n Yours %s,\n M.U.C.\n", $adv);
echo "<em>";
echo str_replace(' ', ' ', $ll);
echo "</em>";
//returns random value from array
function rel($arr) {
return $arr[array_rand($arr)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment