';
+ }
+
+ //add new lines for the sake of clean code
+ return implode("\n", $paragraphStr);
+ }
+
+ private function paragraphToString($paragraph, $htmlCleanCode = false)
+ {
+ $paragraphStr = '';
+ foreach($paragraph as $sentence)
+ {
+ foreach($sentence as $word)
+ $paragraphStr .= $word . ' ';
+
+ if($htmlCleanCode)
+ $paragraphStr .= "\n";
+ }
+ return $paragraphStr;
+ }
+
+ /*
+ * Inserts commas and periods in the given
+ * word array.
+ */
+ private function punctuate(& $sentence)
+ {
+ $count = count($sentence);
+ $sentence[$count - 1] = $sentence[$count - 1] . '.';
+ $sentence[0] = ucfirst($sentence[0]);
+
+ if($count < 4)
+ return $sentence;
+
+ $commas = $this->numberOfCommas($count);
+
+ for($i = 1; $i <= $commas; $i++)
+ {
+ $index = (int) round($i * $count / ($commas + 1));
+
+ if($index < ($count - 1) && $index > 0)
+ {
+ $sentence[$index] = $sentence[$index] . ',';
+ }
+ }
+ }
+
+ /*
+ * Determines the number of commas for a
+ * sentence of the given length. Average and
+ * standard deviation are determined superficially
+ */
+ private function numberOfCommas($len)
+ {
+ $avg = (float) log($len, 6);
+ $stdDev = (float) $avg / 6.000;
+
+ return (int) round($this->gauss_ms($avg, $stdDev));
+ }
+
+ /*
+ * Returns a number on a gaussian distribution
+ * based on the average word length of an english
+ * sentence.
+ * Statistics Source:
+ * http://hearle.nahoo.net/Academic/Maths/Sentence.html
+ * Average: 24.46
+ * Standard Deviation: 5.08
+ */
+ private function gaussianSentence()
+ {
+ $avg = (float) 24.460;
+ $stdDev = (float) 5.080;
+
+ return (int) round($this->gauss_ms($avg, $stdDev));
+ }
+
+ /*
+ * The following three functions are used to
+ * compute numbers with a guassian distrobution
+ * Source:
+ * http://us.php.net/manual/en/function.rand.php#53784
+ */
+ private function gauss()
+ { // N(0,1)
+ // returns random number with normal distribution:
+ // mean=0
+ // std dev=1
+
+ // auxilary vars
+ $x=$this->random_0_1();
+ $y=$this->random_0_1();
+
+ // two independent variables with normal distribution N(0,1)
+ $u=sqrt(-2*log($x))*cos(2*pi()*$y);
+ $v=sqrt(-2*log($x))*sin(2*pi()*$y);
+
+ // i will return only one, couse only one needed
+ return $u;
+ }
+
+ private function gauss_ms($m=0.0,$s=1.0)
+ {
+ return $this->gauss()*$s+$m;
+ }
+
+ private function random_0_1()
+ {
+ return (float)rand()/(float)getrandmax();
+ }
+} // class
+?>
+
+
+
+
+
diff --git a/README.md b/README.md
index eaf8ed1..39079fc 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,15 @@
# Cthuvian-Ipsum-Generator
Cthuvian Ipsum Generator
+A lorem ipsun generator based on [H.P. Lovecraft's](https://www.hplovecraft.com/) [Cthulhu Mythos](https://en.wikipedia.org/wiki/Cthulhu_Mythos)
+
+## History
+Way back in 2010, I wanted to try out this PHP thing, and ended up doing a [page](https://ephemer.kapsi.fi/FhtagnGenerator.php) for generating lorem ipsum placeholder text in Cthuvian (also called R'lyehian), the fictional language from H.P. Lovecraft's writings.
+
+I used some resources which seem to no longer exist on the internet:
++ PHP Lorem Ipsum generator by Mathew Tinsley, originally found at [http://tinsology.net/scripts/php-lorem-ipsum-generator/](http://tinsology.net/scripts/php-lorem-ipsum-generator/)
++ Improved wordlist (with prefixes and suffixes) from Cthuvian / English dictionary, originally found at [http://www.yog-sothoth.com/threads/8683-The-Complete-CTHUVIAN-ENGLISH-DICTIONARY](http://www.yog-sothoth.com/threads/8683-The-Complete-CTHUVIAN-ENGLISH-DICTIONARY)
+
+The code is put here "as was" for historical accuracy and is outdated and horrible in many ways, but hey, it still works, as seen on the [original page](https://ephemer.kapsi.fi/FhtagnGenerator.php). Maybe I'll make a modern version of it. Probably I won't.
+
+## License
+[MIT](https://choosealicense.com/licenses/mit/)
\ No newline at end of file
diff --git a/images/cthicon.ico b/images/cthicon.ico
new file mode 100644
index 0000000..f36a0de
Binary files /dev/null and b/images/cthicon.ico differ
diff --git a/images/cthulhu.png b/images/cthulhu.png
new file mode 100644
index 0000000..b070e3b
Binary files /dev/null and b/images/cthulhu.png differ