Tweaking sentence splitting and generation

This commit is contained in:
Jacob Harris
2013-08-10 14:59:40 -04:00
parent 3e8bdfba47
commit 8170abf9ff

View File

@@ -60,11 +60,17 @@ else
source_tweets.each do |twt|
text = twt
if text !~ /[\.\"\'\?\!]/
text += "."
end
sentences = text.split(/[\.\"\'\?\!]/)
markov.add_text(text)
sentences.each do |sentence|
next if sentence =~ /@/
if sentence !~ /[\.\"\'\?\!]$/
sentence += "."
end
markov.add_text(sentence)
end
end
tweet = nil
@@ -77,7 +83,7 @@ else
tweet.gsub(/\s\w+.$/, '') # randomly losing the last word sometimes like horse_ebooks
end
if tweet.length < 40 && rand(5) == 0
if tweet.length < 40 && rand(10) == 0
puts "Short tweet. Adding another sentence randomly"
tweet += " #{markov.generate_sentence}"
end