<commit_before>module ObservationReport
  # base class
  class Base
    attr_accessor :query
    attr_accessor :encoding

    class_attribute :default_encoding
    class_attribute :mime_type
    class_attribute :extension
    class_attribute :header

    def initialize(args)
      self.query    = args[:query]
      self.encoding = args[:encoding] || default_encoding
      raise "ObservationReport initialized without query!"    unless query
      raise "ObservationReport initialized without encoding!" unless encoding
    end

    def filename
      "observations_#{query.id.alphabetize}.#{extension}"
    end

    def body
      case encoding
      when "UTF-8"
        render
      when "ASCII"
        render.to_ascii
      else
        render.iconv(encoding) # This caused problems with  UTF-16 encoding.
      end
    end

    # Stub for subclasses which need to add other columns to table.
    def extend_data!(data); end

    # Stub for subclasses to sort results before formatting data.
    def sort_before(data)
      data
    end

    # Stub for subclasses to sort results after formatting data.
    def sort_after(data)
      data
    end

    def formatted_rows
      rows = all_rows.map { |row| Row.new(row) }
      rows = sort_before(rows)<commit_msg>Removed extra space from comment.<commit_after>module ObservationReport
  # base class
  class Base
    attr_accessor :query
    attr_accessor :encoding

    class_attribute :default_encoding
    class_attribute :mime_type
    class_attribute :extension
    class_attribute :header

    def initialize(args)
      self.query    = args[:query]
      self.encoding = args[:encoding] || default_encoding
      raise "ObservationReport initialized without query!"    unless query
      raise "ObservationReport initialized without encoding!" unless encoding
    end

    def filename
      "observations_#{query.id.alphabetize}.#{extension}"
    end

    def body
      case encoding
      when "UTF-8"
        render
      when "ASCII"
        render.to_ascii
      else
        render.iconv(encoding) # This caused problems with UTF-16 encoding.
      end
    end

    # Stub for subclasses which need to add other columns to table.
    def extend_data!(data); end

    # Stub for subclasses to sort results before formatting data.
    def sort_before(data)
      data
    end

    # Stub for subclasses to sort results after formatting data.
    def sort_after(data)
      data
    end

    def formatted_rows
      rows = all_rows.map { |row| Row.new(row) }
      rows = sort_before(rows)
{'fraction_non_alphanumeric': 0.062182244818146264, 'fraction_numerical': 0.0023464998044583495, 'mean_word_length': 2.6386913229018494, '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': '5092763', 'n_tokens_mistral': 717, 'n_tokens_neox': 689, 'n_words': 227}