<commit_before>
congressional_feins = %w()

congressional_employers = Employer.where(:fein => {"$in" => congressional_feins}).map(&:id)

plans_2017 = Plan.where(year: 2017).map(&:id)

congressional_policies_2017 = Policy.where(:employer_id => {"$in" => congressional_employers},
                                           :plan_id => {"$in" => plans_2017},
                                           :enrollees => {"$elemMatch" => {
                                              :rel_code => "self",
                                              :coverage_start => {"$gt" => Date.new(2016,12,31)}
                                            }})

def renewal_or_initial(policy)
  if policy.transaction_set_enrollments.any?{|tse| tse.transaction_kind == "initial_enrollment"}
    return "initial"
  else
    return "renewal"
  end
end

renewal_enrollments = []

initial_enrollments = []

congressional_policies_2017.each do |pol|
  result = renewal_or_initial(pol)
  if result == "initial"
    initial_enrollments << pol
  elsif result == "renewal"
    renewal_enrollments << pol
  end
end

initial_en = File.new("congressional_initial_enrollments.txt","w")

initial_enrollments.each do |ie|
  initial_en.puts(ie.eg_id)
end

renewal_en = File.new("congressional_renewals.txt","w")

renewal_enrollments.each do |re|
  renewal_en.puts(re.eg_id)
end<commit_msg>Update congressional renewal finder script to only be employer independent<commit_after># Finds 2017 employments for an employer by fein and date.Takes a fein and a date as arguments
feins = %w()

effective_date = Date.new(2017,1,1)

employers = Employer.where(:fein => {"$in" => congressional_feins}).map(&:id)

plans_2017 = Plan.where(year: 2017).map(&:id)

policies_2017 = Policy.where(:employer_id => {"$in" => congressional_employers},
                                           :plan_id => {"$in" => plans_2017},
                                           :enrollees => {"$elemMatch" => {
                                              :rel_code => "self",
                                              :coverage_start => {"$gte" => effective_date}
                                            }})

def renewal_or_initial(policy)
  if policy.transaction_set_enrollments.any?{|tse| tse.transaction_kind == "initial_enrollment"}
    return "initial"
  else
    return "renewal"
  end
end

renewal_enrollments = []

initial_enrollments = []

policies_2017.each do |pol|
  result = renewal_or_initial(pol)
  if result == "initial"
    initial_enrollments << pol
  elsif result == "renewal"
    renewal_enrollments << pol
  end
end

initial_en = File.new("initial_enrollments.txt","w")

initial_enrollments.each do |ie|
  initial_en.puts(ie.eg_id)
end

renewal_en = File.new("renewal_enrollments.txt","w")

renewal_enrollments.each do |re|
  renewal_en.puts(re.eg_id)
end
{'fraction_non_alphanumeric': 0.12208067940552017, 'fraction_numerical': 0.020523708421797595, 'mean_word_length': 2.524937655860349, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3511702', 'n_tokens_mistral': 953, 'n_tokens_neox': 875, 'n_words': 167}