Last active
April 18, 2021 10:46
-
-
Save tra38/58c177699b12d2550b8032c31afbb0d9 to your computer and use it in GitHub Desktop.
Skynet's ██████ - The MVP
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
require 'zombie_writer' | |
require 'smarter_csv' | |
require 'faker' | |
def boxes | |
faker_lorem = Faker::Lorem.paragraph(3, true, 4) | |
faker_lorem.gsub(/\w/, "█") | |
end | |
def add_censored_text_to_paragraph_start(paragraph) | |
paragraph.prepend("#{boxes} ") | |
end | |
def add_censored_text_to_paragraph_end(paragraph) | |
paragraph.gsub!(/(---.*)/) { |citation| | |
" #{boxes}#{citation}" | |
} | |
end | |
def expand_array(array) | |
array.map! do |article| | |
cleaned_array = article.split(/\r\n|\r|\n|\n\n/).reject(&:empty?) | |
paragraphs = cleaned_array[1..-1] | |
paragraphs.each do |paragraph| | |
add_censored_text_to_paragraph_start(paragraph) | |
add_censored_text_to_paragraph_end(paragraph) | |
end | |
new_article = cleaned_array.join("\n\n") | |
end | |
end | |
def novel_generated?(array) | |
array.join("").split(" ").count >= 50000 | |
end | |
zombie = ZombieWriter::MachineLearning.new | |
array_of_paragraphs = SmarterCSV.process("skynet.csv") | |
array_of_paragraphs.each do |paragraph| | |
zombie.add_string(paragraph) | |
end | |
array = zombie.generate_articles | |
until novel_generated?(array) | |
expand_array(array) | |
end | |
File.open("novel.md", "w+") do |f| | |
array.each { |article| f.puts("#{article}\n\n- - -\n") } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment