bin/ebooks in twitter_ebooks-2.0.3 vs bin/ebooks in twitter_ebooks-2.0.4
- old
+ new
@@ -42,32 +42,45 @@
log "Corpus consumed"
end
end
def self.gen(model_path, input)
- require 'benchmark'
- model = nil;
- puts Benchmark.measure {
- model = Model.load(model_path)
- }
+ model = Model.load(model_path)
if input && !input.empty?
puts "@cmd " + model.markov_response(input, 135)
else
puts model.markov_statement
end
end
+ def self.score(model_path, input)
+ model = Model.load(model_path)
+ model.score_interest(input)
+ end
+
def self.archive(username, outpath)
Archiver.new(username, outpath).fetch_tweets
end
+ def self.tweet(modelpath, username)
+ load File.join(APP_PATH, 'bots.rb')
+ model = Model.load(modelpath)
+ statement = model.markov_statement
+ log "@#{username}: #{statement}"
+ bot = Bot.get(username)
+ bot.configure
+ bot.tweet(statement)
+ end
+
def self.command(args)
usage = """Usage:
ebooks new <reponame>
ebooks consume <corpus_path> [...]
- ebooks gen <model> [input]
+ ebooks gen <model_path> [input]
+ ebooks score <model_path> <input>
ebooks archive <@user> <outpath>
+ ebooks tweet <model_path> <@bot>
"""
if args.length == 0
log usage
exit
@@ -75,10 +88,12 @@
case args[0]
when "new" then new(args[1])
when "consume" then consume(args[1..-1])
when "gen" then gen(args[1], args[2..-1].join(' '))
+ when "score" then score(args[1], args[2..-1].join(' '))
when "archive" then archive(args[1], args[2])
+ when "tweet" then tweet(args[1], args[2])
end
end
end
Ebooks.command(ARGV)