lib/enter_rockstar/cli.rb in enter-rockstar-0.1 vs lib/enter_rockstar/cli.rb in enter-rockstar-0.2

- old
+ new

@@ -9,17 +9,17 @@ package_name "Enter-Rockstar v#{EnterRockstar::VERSION}" desc 'scrape_category CATEGORY_NAME URL', 'scrape lyrics wikia category page for bands and albums' def scrape_category(category_name, url) scraper = EnterRockstar::Scraper::Wikia.new(category_name: category_name, url: url) - scraper.parse_category(test_limit: true) + scraper.parse_category scraper.save_category say end desc 'scrape_lyrics CATEGORY_NAME START_INDEX', 'scrape actual lyrics from the lyrics wikia using the generated json file' - def scrape_lyrics(category_name, start_index=0) + def scrape_lyrics(category_name, start_index = 0) scraper = EnterRockstar::Scraper::Wikia.new(category_name: category_name) scraper.load_saved_json scraper.parse_all_pages(start_index: start_index) end @@ -28,20 +28,26 @@ scraper = EnterRockstar::Scraper::Wikia.new(category_name: category_name) scraper.load_saved_json scraper.print_indexed_tree end - desc 'tokenize DATA_DIR', 'take the downloaded lyrics text files and tokenize them' - def tokenize(data_dir) - tokenizer = EnterRockstar::Corpus::Tokenizer.new(data_dir: data_dir) + desc 'tokenize NAME DATA_DIR', 'take the downloaded lyrics text files and tokenize them' + def tokenize(name, data_dir) + tokenizer = EnterRockstar::Corpus::Tokenizer.new(data_dir: data_dir, name: name) tokenizer.tokenize + tokenizer.save_all end - desc 'poetic NUMBER', 'generate a poetic representation of a number from the word base' - def poetic(number) - generator = EnterRockstar::Generator::Poetic.new - results = generator.number(123) + desc 'poetic NUMBER SOURCE_JSON', 'generate a poetic representation of a number from the word base' + option :amount, desc: 'how many number representations should be generated' + option :strategy, desc: 'generating strategy. One of: [random weighted]' + def poetic(number, source_json) + amount = options[:amount] || 5 + strategy = options[:strategy] || 'random' - say results + generator = EnterRockstar::Generator::Poetic.new(data_file: source_json, amount: amount, strategy: strategy) + results = generator.number(number) + + say results.join("\n") end end end