<commit_before>require 'rake'
require 'mongo'
require_relative '../../lib/gotasku'

namespace :problems do
  desc "Populate the problems collection"
	task :populate do
		client = Mongo::MongoClient.new
		db = client.db('sgf')
		collection = db.collection('problems')

		(0..Gotasku::Problem.last_problem_id).each do |id|
			if collection.find(id: id).first
				print '_'
				next
			end

			prob = Gotasku::Problem.new(id: id)

			begin 
				if prob.blank? == false 
					collection.insert(prob.data) 
					print '.'
				else
					print '*'
				end
			rescue
				print 'E'
			end
		end
	end

	desc "Structure the problems collection"
	task :structure do
		collection = Mongo::MongoClient.new.db('sgf').collection('problems')
	end
end<commit_msg>finished rake task for populating and structuring problems collection<commit_after>require 'rake'
require 'mongo'
require_relative '../../lib/gotasku'

namespace :problems do
  desc "Populate the problems collection"
	task :populate do
		client = Mongo::MongoClient.new
		db = client.db('sgf')
		collection = db.collection('problems')

		(0..Gotasku::Problem.last_problem_id).each do |id|
			if collection.find(id: id).first
				print '_'
				next
			end

			prob = Gotasku::Problem.new(id: id)

			begin 
				if prob.blank? == false 
					collection.insert(prob.data) 
					print '.'
				else
					print '*'
				end
			rescue
				print 'E'
			end
		end
	end

	desc "Structure the problems collection"
	task :structure do
		collection = Mongo::MongoClient.new.db('sgf').collection('problems')
		collection.ensure_index( 
														{id: Mongo::ASCENDING}, 
														{unique: true, dropDups: true})
		collection.create_index(diff_num: Mongo::DESCENDING)
		collection.create_index(rating: Mongo::DESCENDING)
		collection.create_index("type")
	end

	desc "Populate and structure problems collection"
  task default: [:populate, :structure]	
end
{'fraction_non_alphanumeric': 0.1187961985216473, 'fraction_numerical': 0.0010559662090813093, 'mean_word_length': 3.366359447004608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3686298', 'n_tokens_mistral': 771, 'n_tokens_neox': 616, 'n_words': 153}