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