<commit_before>module NucsValidatorHelper
  #
  # Seeds the DB with a GL066 record for validation of +chart_string+
  # [_chart_string_]
  #   A +NucsValidator::NUCS_PATTERN+ matching +String+
  # [_attrs_]
  #   Overrides for the +NucsGl066+ Factory, if any
  def define_gl066(chart_string, attrs={})
    components=chart_string.match(NucsValidator::NUCS_PATTERN)
    attrs.merge!(:fund => components[1]) unless attrs.has_key?(:fund)
    attrs.merge!(:department => components[2]) unless attrs.has_key?(:department)
    attrs.merge!(:project => components[3]) if components[3] and not attrs.has_key?(:project)
    attrs.merge!(:activity => components[4]) if components[4] and not attrs.has_key?(:activity)

    if attrs.has_key?(:expires_at) or attrs.has_key?(:starts_at)
      Factory.create(:nucs_gl066_with_dates, attrs)
    else
      attrs.merge!(:budget_period => Time.zone.today.year) unless attrs.has_key?(:budget_period)
      gl=Factory.create(:nucs_gl066_without_dates, attrs)
    end

    Factory.create(:nucs_chart_field1, :value => components[6]) if components[6]
  end


  #
  # Seeds the DB with GE001 records for validation of +chart_string+
  # [_chart_string_]
  #   A +NucsValidator::NUCS_PATTERN+ matching +String+
  def define_ge001(chart_string)
    components=chart_string.match(NucsValidator::NUCS_PATTERN)
    Factory.create(:nucs_fund, :value => components[1])
    Factory.create(:nucs_department, :value => components[2])

    if components[3]
      project_activity={ :project => components[3] }<commit_msg>update to handle fiscal year overlaps<commit_after>module NucsValidatorHelper
  #
  # Seeds the DB with a GL066 record for validation of +chart_string+
  # [_chart_string_]
  #   A +NucsValidator::NUCS_PATTERN+ matching +String+
  # [_attrs_]
  #   Overrides for the +NucsGl066+ Factory, if any
  def define_gl066(chart_string, attrs={})
    components=chart_string.match(NucsValidator::NUCS_PATTERN)
    attrs.merge!(:fund => components[1]) unless attrs.has_key?(:fund)
    attrs.merge!(:department => components[2]) unless attrs.has_key?(:department)
    attrs.merge!(:project => components[3]) if components[3] and not attrs.has_key?(:project)
    attrs.merge!(:activity => components[4]) if components[4] and not attrs.has_key?(:activity)

    if attrs.has_key?(:expires_at) or attrs.has_key?(:starts_at)
      Factory.create(:nucs_gl066_with_dates, attrs)
    else
      attrs.merge!(:budget_period => (Time.zone.today+1.year).year) unless attrs.has_key?(:budget_period)
      gl=Factory.create(:nucs_gl066_without_dates, attrs)
    end

    Factory.create(:nucs_chart_field1, :value => components[6]) if components[6]
  end


  #
  # Seeds the DB with GE001 records for validation of +chart_string+
  # [_chart_string_]
  #   A +NucsValidator::NUCS_PATTERN+ matching +String+
  def define_ge001(chart_string)
    components=chart_string.match(NucsValidator::NUCS_PATTERN)
    Factory.create(:nucs_fund, :value => components[1])
    Factory.create(:nucs_department, :value => components[2])

    if components[3]
      project_activity={ :project => components[3] }
{'fraction_non_alphanumeric': 0.12745413582233667, 'fraction_numerical': 0.022207917605407145, 'mean_word_length': 5.011605415860735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '7243097', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1066, 'n_words': 207}