<commit_before>#!/usr/bin/env ruby
#encoding: UTF-8
Encoding.default_external="UTF-8"
Encoding.default_internal="UTF-8"

require 'rest_client'
require 'xml'

class DocSequencerPMC
  attr_reader :source_url, :xml, :divs

  def initialize (id)
    raise ArgumentError, "id is nil." if id.nil?

    id = id.strip
    raise ArgumentError, "'#{id}' is not a valid ID of PMC" unless id.match(/^(PMC)?[:-]?([1-9][0-9]*)$/)

    id = id.sub(/^PMC[:-]?/, '')

    RestClient.get "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id=#{id}" do |response, request, result|
      case response.code
      when 200
        @xml = response
        raise ArgumentError, "#{id} not found in PMC." if @xml.index("PMC#{id} not found")

        parser = XML::Parser.string(@xml, :encoding => XML::Encoding::UTF_8)
        @doc = parser.parse
        @source_url = 'http://www.ncbi.nlm.nih.gov/pmc/' + id
        @divs = get_divs
      else
        raise "PMC unreachable."
      end
    end
  end
<commit_msg>error message interpretation updated.<commit_after>#!/usr/bin/env ruby
#encoding: UTF-8
Encoding.default_external="UTF-8"
Encoding.default_internal="UTF-8"

require 'rest_client'
require 'xml'

class DocSequencerPMC
  attr_reader :source_url, :xml, :divs

  def initialize (id)
    raise ArgumentError, "id is nil." if id.nil?

    id = id.strip
    raise ArgumentError, "'#{id}' is not a valid ID of PMC" unless id.match(/^(PMC)?[:-]?([1-9][0-9]*)$/)

    id = id.sub(/^PMC[:-]?/, '')

    RestClient.get "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id=#{id}" do |response, request, result|
      case response.code
      when 200
        @xml = response
        raise ArgumentError, "#{id} not found in PMC." if @xml.index("PMC#{id} not found")
        raise ArgumentError, "#{id} not found in PMC." if @xml.index("PMCID is not available")

        parser = XML::Parser.string(@xml, :encoding => XML::Encoding::UTF_8)
        @doc = parser.parse
        @source_url = 'http://www.ncbi.nlm.nih.gov/pmc/' + id
        @divs = get_divs
      else
        raise "PMC unreachable."
      end
    end
  end

{'fraction_non_alphanumeric': 0.16457461645746166, 'fraction_numerical': 0.010227801022780102, 'mean_word_length': 2.9925788497217067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 13}, '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': '4977197', 'n_tokens_mistral': 793, 'n_tokens_neox': 760, 'n_words': 181}