<commit_before>#!/usr/bin/env ruby

require 'flowcommerce'

token_file = "~/.flow/token"

if !File.exists?(File.expand_path(token_file))
  puts "ERROR: Pls create a file named %s containing your Flow API token" % token_file
  exit(1)
end

token = IO.read(File.expand_path(token_file)).strip

client = FlowCommerce.client(token)

catalog = client.catalogs.get_catalog("demo")
puts "Master catalog: " + catalog.inspect
puts ""

view = client.views.get("demo", :key => "canada").first

if view.nil?
  form = Io::Flow::Catalog::V0::Models::ViewForm.new(
    :key => "canada",
    :countries => ["CA"],
    :currency => "CAD",
    :query => "Jewelry",
    :settings => Io::Flow::Catalog::V0::Models::ViewSettingsForm.new()
  )
  view = client.views.post("demo", form)
end

puts "Canada view: " + view.inspect
puts ""

items = client.view_items.get("demo", "canada", :limit => 10, :offset => 0)
puts "# items in view: %s" % items.size
items.each do |item|
  puts " - item %s"
end
<commit_msg>Remove master catalog from example<commit_after>#!/usr/bin/env ruby

require 'flowcommerce'

token_file = "~/.flow/token"

if !File.exists?(File.expand_path(token_file))
  puts "ERROR: Pls create a file named %s containing your Flow API token" % token_file
  exit(1)
end

token = IO.read(File.expand_path(token_file)).strip

client = FlowCommerce.client(token)

view = client.views.get("demo", :key => "canada").first

if view.nil?
  form = Io::Flow::Catalog::V0::Models::ViewForm.new(
    :key => "canada",
    :countries => ["CA"],
    :currency => "CAD",
    :query => "Jewelry",
    :settings => Io::Flow::Catalog::V0::Models::ViewSettingsForm.new()
  )
  view = client.views.post("demo", form)
end

puts "Canada view: " + view.inspect
puts ""

items = client.view_items.get("demo", "canada", :limit => 10, :offset => 0)
puts "# items in view: %s" % items.size
items.each do |item|
  puts " - item %s"
end

{'fraction_non_alphanumeric': 0.17932489451476794, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 4.389204545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '850888', 'n_tokens_mistral': 697, 'n_tokens_neox': 688, 'n_words': 161}