mirror of
https://github.com/thewesker/iron_ebooks.git
synced 2025-12-20 04:11:12 -05:00
Tweaking sentence splitting and generation
This commit is contained in:
16
ebook.rb
16
ebook.rb
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user