## READ WRITE GARDEN ##
## READ WRITE GARDEN ## is an erasure poem by J. R. Carpenter carved out of Ruby code and code comments by Caden Lovelace. This text was created for The Ill-Tempered Rubyist, an international anthology of poems involving computer languages, especially the RUBY language, hand-made and edited by Karen Randall in honor of the Millay Colony‘s ruby anniversary.
#### we want to split #### our text into units #### #### punctuation marks allow us #### to treat them as words #### #### consider the ellipsis #### for example #### #### spaces #### on either side of certain def tokenize_texts(texts) return texts.map do |text| text.gsub!(/(\w)([,.:;\/?!]|\.\.\.+)(\W)/i, ‘\1 \2 \3′) text.split(‘ ‘) end end #### words often come #### after other words #### #### we walk through our garden #### counting pairs def generate_frequency_table(tokenized_texts, n) frequency_table = {} tokenized_texts.each do |text| text.each_with_index do |word, i| if i+2 < text.length # is there a word after this one? end end