<commit_before>require 'api_entity'

class Commodity
  include ApiEntity

  attr_accessor :short_code, :code, :description, :substring, :hier_pos,
                :synonyms, :uk_vat_rate_cache, :third_country_duty_cache,
                :leaf, :parents, :synonyms, :display_short_code

  has_one :section
  has_one :heading
  has_one :chapter
  has_many :commodities, class_name: 'Commodity'
  has_many :ancestors, class_name: 'Commodity'

  def substring=(substring)
    @substring ||= substring.to_i
  end

  def update_attrs(params)
    self.class.put("/commodities/#{to_param}", body: params)
  end

  def leaf?
    # TODO: is this right?
    commodities.length == 0
  end

  def to_param
    code
  end<commit_msg>Should refer to commodity as combination of code and producline suffix<commit_after>require 'api_entity'

class Commodity
  include ApiEntity

  attr_accessor :short_code, :code, :description, :substring, :hier_pos,
                :synonyms, :uk_vat_rate_cache, :third_country_duty_cache,
                :leaf, :parents, :synonyms, :display_short_code, :producline_suffix

  has_one :section
  has_one :heading
  has_one :chapter
  has_many :commodities, class_name: 'Commodity'
  has_many :ancestors, class_name: 'Commodity'

  def substring=(substring)
    @substring ||= substring.to_i
  end

  def update_attrs(params)
    self.class.put("/commodities/#{to_param}", body: params)
  end

  def leaf?
    # TODO: is this right?
    commodities.length == 0
  end

  def to_param
    "#{code}#{producline_suffix}"
  end
{'fraction_non_alphanumeric': 0.0987012987012987, 'fraction_numerical': 0.0012987012987012987, 'mean_word_length': 3.815625, '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': '1966697', 'n_tokens_mistral': 551, 'n_tokens_neox': 524, 'n_words': 124}