From 29f46629ed2203266539e4247912558092b776c7 Mon Sep 17 00:00:00 2001 From: Mispy <^_^@mispy.me> Date: Fri, 18 Apr 2014 22:51:33 -0700 Subject: [PATCH] Add expanded usage information to commands --- .gitignore | 1 + bin/ebooks | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cf08465..b0436d8 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .*.swp +Gemfile.lock pkg diff --git a/bin/ebooks b/bin/ebooks index e3e726a..7fccb4d 100755 --- a/bin/ebooks +++ b/bin/ebooks @@ -8,7 +8,12 @@ module Ebooks APP_PATH = Dir.pwd # XXX do some recursive thing instead def self.new(reponame) - usage = "Usage: ebooks new " + usage = < + +Creates a new skeleton repository defining a template bot in +the current working directory specified by . +STR if reponame.nil? log usage @@ -33,10 +38,21 @@ module Ebooks end def self.consume(pathes) + usage = < [corpus_path2] [...] + +Processes some number of text files or json tweet corpuses +into usable models. These will be output at model/.model +STR + + if pathes.empty? + log usage + exit + end + pathes.each do |path| filename = File.basename(path) shortname = filename.split('.')[0..-2].join('.') - hash = Digest::MD5.hexdigest(File.read(path)) outpath = File.join(APP_PATH, 'model', "#{shortname}.model") Model.consume(path).save(outpath) @@ -45,6 +61,17 @@ module Ebooks end def self.gen(model_path, input) + usage = < [input] + +Make a test tweet from the processed model at . +Will respond to input if provided. +STR + if model_path.nil? + log usage + exit + end + model = Model.load(model_path) if input && !input.empty? puts "@cmd " + model.make_response(input, 135) @@ -54,11 +81,35 @@ module Ebooks end def self.score(model_path, input) + usage = < + +Scores "interest" in some text input according to how +well unique keywords match the model. +STR + if model_path.nil? || input.nil? + log usage + exit + end + model = Model.load(model_path) model.score_interest(input) end def self.archive(username, outpath) + usage = < + +Downloads a json corpus of the 's tweets to . +Due to API limitations, this can only receive up to ~3000 tweets +into the past. +STR + + if username.nil? || outpath.nil? + log usage + exit + end + Archive.new(username, outpath).sync end @@ -73,6 +124,17 @@ module Ebooks end def self.jsonify(paths) + usage = < [old_corpus_path2] [...] + +Takes an old-style corpus of plain tweet text and converts it to json. +STR + + if paths.empty? + log usage + exit + end + paths.each do |path| name = File.basename(path).split('.')[0] new_path = name + ".json" @@ -102,12 +164,12 @@ module Ebooks def self.command(args) usage = """Usage: ebooks new - ebooks consume [...] + ebooks consume [corpus_path2] [...] ebooks gen [input] ebooks score ebooks archive <@user> ebooks tweet <@bot> - ebooks jsonify [...] + ebooks jsonify [old_corpus_path2] [...] """ if args.length == 0