Generate random haikus in the 5, 7, 5 syllables format or find haikus in a text file.
To generate a random haiku, run node haiku.js in the command line. You will be prompted for the number of syllables for each word in each of the three lines of the haiku. Note that the format of the user's input is unimportant, as long as it contains digits adding up to the correct number of syllables. The program only recognizes digit characters, so it will read "2, 3, 2", "2 3 2", "232", and "2, then 3, then another 2" as the same input, all valid.
To find haikus in the 575 format in a text file, run node haiku_finder.js in the command line, followed by the filepath of the text file you wish to analyze. The program will generate a new text file in the current directory containing all the haikus found in the file (minus the last 1000 words, which will likely be licensing information unrelated to the body of the text) named "haiku_found_for_", or will overwrite a file that already has that name. Note that NOTHING WILL BE PRINTED TO THE CONSOLE. You will have to open the new text file to see the haikus. Also note that the program is currently written to only write haikus starting with a word that begins with a capital letter in the original text (meant to start checking at the beginning of a sentence, though it will also catch proper nouns). To search additionally for haikus starting anywhere, including in the middle of a sentence, go to the haiku_finder.js file and comment out the lines marked /OPTIONAL/. Be mindful that this will generate a much larger text file, and that most of the resulting haikus will be nonsensical (hence the decision to check those that begin at the beginning of a sentence).