<commit_before>class Ca10
  include Expect

  def accept_host
    'www.ca10.uscourts.gov'
  end
  
  def accept?(download)
    download.request_uri == OPINIONS_URL
  end

  def request
    DownloadRequest.new(OPINIONS_URL)
  end

  def parse(download, receiver)
    parse_page(download.response_body_as("US-ASCII"), receiver)
  end

  private
  
  BASE_URL = 'http://www.ca10.uscourts.gov'
  OPINIONS_URL = BASE_URL + '/clerk/opinions.php'

  def parse_page(html, receiver)
    doc = Hpricot(html)
    td = doc.search('td').find {|e| e.inner_html =~ /^<span class="headline">Today/}
    published, unpublished = td.to_html.split("Unpublished")
    parse_section(published, receiver, true)
    parse_section(unpublished, receiver, false)
  end

  def parse_section(html, receiver, precedential)
    if html
      doc = Hpricot(html)
      doc.search("a").each do |a|
        title = a.attributes['title']
        if title != nil
          entry = Document.new
          entry.court = self.court
          entry.precedential = precedential
          entry.date = Date.today
          entry.docket = a.inner_html.gsub(/<\/?[^>]*>/, "").gsub(/&nbsp;/,"")
          entry.add_link('application/pdf', BASE_URL + a.attributes["href"])
          entry.name = title
          receiver << entry
        end
      end
    end
  end
<commit_msg>ca10.rb: fix handling of docket & court<commit_after>class Ca10
  include Expect

  def accept_host
    'www.ca10.uscourts.gov'
  end

  def accept?(download)
    download.request_uri == OPINIONS_URL
  end

  def request
    DownloadRequest.new(OPINIONS_URL)
  end

  def parse(download, receiver)
    parse_page(download.response_body_as("US-ASCII"), receiver)
  end

  private

  BASE_URL = 'http://www.ca10.uscourts.gov'
  OPINIONS_URL = BASE_URL + '/clerk/opinions.php'

  def parse_page(html, receiver)
    doc = Hpricot(html)
    td = doc.search('td').find {|e| e.inner_html =~ /^<span class="headline">Today/}
    published, unpublished = td.to_html.split("Unpublished")
    parse_section(published, receiver, true)
    parse_section(unpublished, receiver, false)
  end

  def parse_section(html, receiver, precedential)
    if html
      doc = Hpricot(html)
      doc.search("a").each do |a|
        title = a.attributes['title']
        if title != nil
          entry = Document.new
          entry.court = 'http://id.altlaw.org/courts/us/fed/app/10'
          entry.precedential = precedential
          entry.date = Date.today
          entry.dockets << a.inner_html.gsub(/<\/?[^>]*>/, "").gsub(/&nbsp;/,"")
          entry.add_link('application/pdf', BASE_URL + a.attributes["href"])
          entry.name = title
          receiver << entry
        end
      end
    end
  end

{'fraction_non_alphanumeric': 0.1303709144326111, 'fraction_numerical': 0.0058758721997796545, 'mean_word_length': 2.7010869565217392, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2541111', 'n_tokens_mistral': 945, 'n_tokens_neox': 898, 'n_words': 181}