For background, see my previous post on this project.
After scraping about 5000 articles from tvtropes.org to retrieve descriptions for characters and settings, Sam Lavigne suggested I scrape erowid.org to dig up some exposition material. I proceeded to scrape 18,324 drug trip reports from the site, and integrated that material into the generator.
While this project remains unfinished—I’m considering adding more material from many other websites, which is why I’m calling it a “collective consciousness fiction generator”—it is now generating full-length “novels” (300+ pages, 8.5×11, 12pt font). I polled my fellow ITP students to insert themselves into novels, and they responded with over 50 suggestions for novel titles. The generated PDFs are available for viewing/download on Google Drive.
I decided to create covers for 3 of my favorite novels the software has generated. Click on the covers below to see those PDFs:
Here is the current state of the code that’s generating these novels:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
latex_special_char_1 = ['&', '%', '$', '#', '_', '{', '}'] latex_special_char_2 = ['~', '^', '\\'] outputFile = open("output/"+outputFileName+".tex", 'w') openingTexLines = ["\\documentclass[12pt]{book}", "\\usepackage{ucs}", "\\usepackage[utf8x]{inputenc}", "\\usepackage{hyperref}", "\\title{"+outputFileName+"}", "\\author{collective consciousness fiction generator\\\\http://rossgoodwin.com/ficgen}", "\\date{\\today}", "\\begin{document}", "\\maketitle"] closingTexLine = "\\end{document}" for line in openingTexLines: outputFile.write(line+"\n\r") outputFile.write("\n\r\n\r") intros = char_match() for x, y in intros.iteritems(): outputFile.write("\\chapter{"+x+"}\n\r") chapter_type = random.randint(0, 4) bonus_drug_trip = random.randint(0, 1) trip_count = random.randint(1,4) # BLOCK ONE if chapter_type in [0, 3]: for char in y[0]: if char == "`": outputFile.seek(-1, 1) elif char in latex_special_char_1: outputFile.write("\\"+char) elif char in latex_special_char_2: if char == '~': outputFile.write("") elif char == '^': outputFile.write("") elif char == '\\': outputFile.write("-") else: pass else: outputFile.write(char) elif chapter_type in [1, 4]: for char in y[2]: if char == "`": outputFile.seek(-1, 1) elif char in latex_special_char_1: outputFile.write("\\"+char) elif char in latex_special_char_2: if char == '~': outputFile.write("") elif char == '^': outputFile.write("") elif char == '\\': outputFile.write("-") else: pass else: outputFile.write(char) elif chapter_type == 2: for char in y[1][0]: if char == "`": outputFile.seek(-1, 1) else: outputFile.write(char) outputFile.write("\n\r\n\r\n\r") # BLOCK TWO if chapter_type == 0: for char in y[2]: if char == "`": outputFile.seek(-1, 1) elif char in latex_special_char_1: outputFile.write("\\"+char) elif char in latex_special_char_2: if char == '~': outputFile.write("") elif char == '^': outputFile.write("") elif char == '\\': outputFile.write("-") else: pass else: outputFile.write(char) elif chapter_type == 1: for char in y[0]: if char == "`": outputFile.seek(-1, 1) elif char in latex_special_char_1: outputFile.write("\\"+char) elif char in latex_special_char_2: if char == '~': outputFile.write("") elif char == '^': outputFile.write("") elif char == '\\': outputFile.write("-") else: pass else: outputFile.write(char) elif chapter_type in [3, 4]: for char in y[1][0]: if char == "`": outputFile.seek(-1, 1) else: outputFile.write(char) elif chapter_type == 2 and bonus_drug_trip: for tripIndex in range(trip_count): for char in y[1][tripIndex+1]: if char == "`": outputFile.seek(-1, 1) else: outputFile.write(char) else: pass outputFile.write("\n\r\n\r\n\r") # BLOCK THREE if chapter_type in [0, 1, 3, 4] and bonus_drug_trip: for tripIndex in range(trip_count): for char in y[1][tripIndex+1]: if char == "`": outputFile.seek(-1, 1) else: outputFile.write(char) outputFile.write("\n\r\n\r\n\r") else: pass outputFile.write("\n\r\n\r") outputFile.write(closingTexLine) outputFile.close() print '\"output/'+outputFileName+'.tex\"' |
UPDATE: Part III