<commit_before>require 'docx'
require 'forwardable'

class Disposition
  extend Forwardable

  def initialize(filename)
    @doc = Docx::Document.open(filename)
  end

  def_delegator :doc, :tables

  private
  attr_reader :doc
end<commit_msg>Correctly locate and parse bylaws from word document.<commit_after>require 'docx'
require 'forwardable'

class Disposition
  extend Forwardable

  def initialize(filename)
    @doc = Docx::Document.open(filename)
  end

  def bylaws
    bylaw_data
  end

  def_delegator :doc, :tables

  private
  attr_reader :doc

  def bylaw_table
    tables.select do |t| 
      t.rows[0].cells[0].text == 'BY-LAWS PASSED (RECEIVED THIRD READING)'
    end.first
  end

  def bylaw_table_rows
    bylaw_table.rows[2..-1] # The first two rows are headers
  end

  def bylaw_data
    bylaw_table_rows.map do |bylaw_row|
      { number:      bylaw_row.cells[0].text,
        subject:     bylaw_row.cells[1].text,
        disposition: bylaw_row.cells[2].text == 'PASSED' }
    end
  end
end
{'fraction_non_alphanumeric': 0.09064039408866995, 'fraction_numerical': 0.006896551724137931, 'mean_word_length': 3.305084745762712, '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': '2214172', 'n_tokens_mistral': 369, 'n_tokens_neox': 356, 'n_words': 87}