<commit_before>module CommoditiesHelper
  def leaf_position(commodity)
    if commodity.last_child?
      " last-child"
    else
      ""
    end
  end

  def commodity_level(commodity)
    "level-#{commodity.number_indents}"
  end

  def commodity_tree(main_commodity, commodities)
    if commodities.any?
      content_tag(:ul, class: 'commodities') do
        content_tag(:li, commodities.first.to_s.html_safe + tree_node(main_commodity, commodities, commodities.first.number_indents))
      end
    else
      content_tag(:ul, class: 'commodities') do
        content_tag(:li, commodity_heading(main_commodity))
      end
    end
  end

  def format_commodity_code(commodity)
    code = commodity.display_short_code.to_s
    "#{code[0..1]}&nbsp;#{code[2..3]}&nbsp;#{code[4..-1]}".html_safe
  end

  def format_full_code(commodity)
    code = commodity.code.to_s
    "#{chapter_and_heading_codes(code)}
    <div class='commodity-code'>
      <div class='code-text'>#{code[4..5]}</div>
      <div class='code-text'>#{code[6..7]}</div>
      <div class='code-text'>#{code[8..9]}</div>
    </div>".html_safe
  end

  def format_commodity_code_based_on_level(commodity)
    code = commodity.code.to_s
    display_full_code = commodity.producline_suffix == '80'

    if commodity.number_indents > 1 || display_full_code
      # remove trailing pairs of zeros
      code = code.gsub(/[0]{2}+$/, '')

      "#{chapter_and_heading_codes(code)}
      <div class='commodity-code'>
        <div class='code-text pull-left'>#{code[4..5]}</div>
        #{code_text(code[6..7])}
        #{code_text(code[8..9])}
      </div>".html_safe
    end
  end

  private<commit_msg>fixed 10 digits for declarable commodities.<commit_after>module CommoditiesHelper
  def leaf_position(commodity)
    if commodity.last_child?
      " last-child"
    else
      ""
    end
  end

  def commodity_level(commodity)
    "level-#{commodity.number_indents}"
  end

  def commodity_tree(main_commodity, commodities)
    if commodities.any?
      content_tag(:ul, class: 'commodities') do
        content_tag(:li, commodities.first.to_s.html_safe + tree_node(main_commodity, commodities, commodities.first.number_indents))
      end
    else
      content_tag(:ul, class: 'commodities') do
        content_tag(:li, commodity_heading(main_commodity))
      end
    end
  end

  def format_commodity_code(commodity)
    code = commodity.display_short_code.to_s
    "#{code[0..1]}&nbsp;#{code[2..3]}&nbsp;#{code[4..-1]}".html_safe
  end

  def format_full_code(commodity)
    code = commodity.code.to_s
    "#{chapter_and_heading_codes(code)}
    <div class='commodity-code'>
      <div class='code-text'>#{code[4..5]}</div>
      <div class='code-text'>#{code[6..7]}</div>
      <div class='code-text'>#{code[8..9]}</div>
    </div>".html_safe
  end

  def format_commodity_code_based_on_level(commodity)
    code = commodity.code.to_s
    display_full_code = commodity.producline_suffix == '80'

    if commodity.number_indents > 1 || display_full_code
      # remove trailing pairs of zeros for non declarable
      code = code.gsub(/[0]{2}+$/, '') if commodity.has_children?

      "#{chapter_and_heading_codes(code)}
      <div class='commodity-code'>
        <div class='code-text pull-left'>#{code[4..5]}</div>
        #{code_text(code[6..7])}
        #{code_text(code[8..9])}
      </div>".html_safe
    end
  end

  private
{'fraction_non_alphanumeric': 0.14626250735726898, 'fraction_numerical': 0.014125956444967627, 'mean_word_length': 3.352112676056338, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '5608062', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1211, 'n_words': 189}