<commit_before>require "las_reader/version"
require "las_reader/curve_info"
require "las_reader/curve"
require "las_reader/mnemonic"
require "las_reader/well_info"

module LasReader

  attr_reader :version
  attr_reader :wrap
  attr_reader :curves
  attr_reader :parameters
  attr_reader :well_info

  def set_version(info)
    version = info.match(/(VERS\s*\.).+([1-3]\.[0-9]).*:\s*(.*)/)
    if version.nil?
      wrap_mode = info.match(/(WRAP\s*\.).+(YES|NO).*:\s*(.*)/)
      if not wrap_mode.nil?
          @wrap =  (wrap_mode[2] == "YES") ? true : false
      end
    else
      @version = version[2]
      raise "LAS version not supported" if @version.to_f > 2.0
    end
  end

  def set_curve_info(info)
    mnemonic = info.match(/(\w+)\s*\.(\S*)\s+(.*):\s*(.*)$/)
    unless mnemonic.nil?
      @curves["#{mnemonic[1]}"] = Curve.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
      @acurves << mnemonic[1]
    end
  end

  def set_parameters(info)
    mnemonic = info.match(/(\w+)\s*\.(\S+)\s+(.*):\s*(.*)$/)
    unless mnemonic.nil?
      @parameters["#{mnemonic[1]}"] = Mnemonic.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
    end
  end

  def set_well_info(info)
    strt = info.match(/(STRT)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
    unless strt.nil?
      @well_info.start_depth = strt[3].to_f
      @well_info.depth_unit = strt[2]
      return
    end

    stop = info.match(/(STOP)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
    unless stop.nil?
      @well_info.stop_depth = stop[3].to_f
      return
    end

    step = info.match(/(STEP)\s*\.(\w).+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
    unless step.nil?
      @well_info.step = step[3].to_f
      return
    end

    null = info.match(/(NULL)\s*\..+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
    unless null.nil?
      @well_info.null_value = null[2].to_f
      return
    end

    comp = info.match(/(COMP\s*\..+COMPANY:\s*(.*))|(COMP\s*\.\s*(.*)\s*:\s*COMPANY)/)
    unless comp.nil?
      @well_info.company_name = (comp[2] or comp[4]).strip
      return
    end

    well = info.match(/(WELL\s*\..+WELL:\s*(.*))|(WELL\s*\.\s*(.*)\s*:\s*WELL)/)
    unless well.nil?
      @well_info.well_name = (well[2] or well[4]).strip
      return
    end

    fld = info.match(/(FLD\s*\..+FIELD:\s*(.*))|(FLD\s*\.\s*(.*)\s*:\s*FIELD)/)
    unless fld.nil?
      @well_info.field_name = (fld[2] or fld[4]).strip
      return
    end

    loc = info.match(/(LOC\s*\..+LOCATION:\s*(.*))|(LOC\s*\.\s*(.*)\s*:\s*LOCATION)/)
    unless loc.nil?
      @well_info.location = (loc[2] or loc[4]).strip
      return
    end

    prov = info.match(/(PROV\s*\..+PROVINCE:\s*(.*))|(PROV\s*\.\s*(.*)\s+:\s*PROVINCE)/)
    unless prov.nil?
      @well_info.province = (prov[2] or prov[4]).strip
      return
    end

    cnty = info.match(/(CNTY\s*\..+COUNTY:\s*(.*))|(CNTY\s*\.\s*(.*)\s+:\s*COUNTY)/)
    unless cnty.nil?
      @well_info.county = (cnty[2] or cnty[4]).strip
      return
    end

    stat = info.match(/(STAT\s*\..+STATE:\s*(.*))|(STAT\s*\.\s*(.*)\s*:\s*STATE)/)
    unless stat.nil?
      @well_info.state = (stat[2] or stat[4]).strip
      return
    end

    ctry  = info.match(/(CTRY\s*\..+COUNTRY:\s*(.*))|(CTRY\s*\.\s*(.*)\s+:\s*COUNTRY)/)
    unless ctry.nil?
      @well_info.country = (ctry[2] or ctry[4]).strip
      return
    end

    srvc = info.match(/(SRVC\s*\..+SERVICE COMPANY:\s*(.*))|(SRVC\s*\.\s*(.*)\s+:\s*SERVICE COMPANY)/)
    unless srvc.nil?
      @well_info.service_company = (srvc[2] or srvc[4]).strip
      return
    end

    data = info.match(/(DATE\s*\..+LOG DATE:\s*(.*))|(DATE\s*\.\s*(.*)\s+:\s*LOG DATE)/)
    unless data.nil?
      @well_info.date_logged = (data[2] or data[4]).strip
      return
    end

    uwi = info.match(/(UWI\s*\..+UNIQUE WELL ID:\s*(.*))|(UWI\s*\.\s*(.*)\s+:\s*UNIQUE WELL ID)/)
    unless uwi.nil?
      @well_info.uwi = (uwi[2] or uwi[4]).strip
      return
    end

  end

  def set_other_info(info)
  end<commit_msg>Converted all remaining regex to allow for no space convention (prov, cnty,ctry,srvc,data,uwi)<commit_after>require "las_reader/version"
require "las_reader/curve_info"
require "las_reader/curve"
require "las_reader/mnemonic"
require "las_reader/well_info"

module LasReader

  attr_reader :version
  attr_reader :wrap
  attr_reader :curves
  attr_reader :parameters
  attr_reader :well_info

  def set_version(info)
    version = info.match(/(VERS\s*\.).+([1-3]\.[0-9]).*:\s*(.*)/)
    if version.nil?
      wrap_mode = info.match(/(WRAP\s*\.).+(YES|NO).*:\s*(.*)/)
      if not wrap_mode.nil?
          @wrap =  (wrap_mode[2] == "YES") ? true : false
      end
    else
      @version = version[2]
      raise "LAS version not supported" if @version.to_f > 2.0
    end
  end

  def set_curve_info(info)
    mnemonic = info.match(/(\w+)\s*\.(\S*)\s+(.*):\s*(.*)$/)
    unless mnemonic.nil?
      @curves["#{mnemonic[1]}"] = Curve.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
      @acurves << mnemonic[1]
    end
  end

  def set_parameters(info)
    mnemonic = info.match(/(\w+)\s*\.(\S+)\s+(.*):\s*(.*)$/)
    unless mnemonic.nil?
      @parameters["#{mnemonic[1]}"] = Mnemonic.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
    end
  end

  def set_well_info(info)
    strt = info.match(/(STRT)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
    unless strt.nil?
      @well_info.start_depth = strt[3].to_f
      @well_info.depth_unit = strt[2]
      return
    end

    stop = info.match(/(STOP)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
    unless stop.nil?
      @well_info.stop_depth = stop[3].to_f
      return
    end

    step = info.match(/(STEP)\s*\.(\w).+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
    unless step.nil?
      @well_info.step = step[3].to_f
      return
    end

    null = info.match(/(NULL)\s*\..+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
    unless null.nil?
      @well_info.null_value = null[2].to_f
      return
    end

    comp = info.match(/(COMP\s*\..+COMPANY:\s*(.*))|(COMP\s*\.\s*(.*)\s*:\s*COMPANY)/)
    unless comp.nil?
      @well_info.company_name = (comp[2] or comp[4]).strip
      return
    end

    well = info.match(/(WELL\s*\..+WELL:\s*(.*))|(WELL\s*\.\s*(.*)\s*:\s*WELL)/)
    unless well.nil?
      @well_info.well_name = (well[2] or well[4]).strip
      return
    end

    fld = info.match(/(FLD\s*\..+FIELD:\s*(.*))|(FLD\s*\.\s*(.*)\s*:\s*FIELD)/)
    unless fld.nil?
      @well_info.field_name = (fld[2] or fld[4]).strip
      return
    end

    loc = info.match(/(LOC\s*\..+LOCATION:\s*(.*))|(LOC\s*\.\s*(.*)\s*:\s*LOCATION)/)
    unless loc.nil?
      @well_info.location = (loc[2] or loc[4]).strip
      return
    end

    prov = info.match(/(PROV\s*\..+PROVINCE:\s*(.*))|(PROV\s*\.\s*(.*)\s*:\s*PROVINCE)/)
    unless prov.nil?
      @well_info.province = (prov[2] or prov[4]).strip
      return
    end

    cnty = info.match(/(CNTY\s*\..+COUNTY:\s*(.*))|(CNTY\s*\.\s*(.*)\s*:\s*COUNTY)/)
    unless cnty.nil?
      @well_info.county = (cnty[2] or cnty[4]).strip
      return
    end

    stat = info.match(/(STAT\s*\..+STATE:\s*(.*))|(STAT\s*\.\s*(.*)\s*:\s*STATE)/)
    unless stat.nil?
      @well_info.state = (stat[2] or stat[4]).strip
      return
    end

    ctry  = info.match(/(CTRY\s*\..+COUNTRY:\s*(.*))|(CTRY\s*\.\s*(.*)\s*:\s*COUNTRY)/)
    unless ctry.nil?
      @well_info.country = (ctry[2] or ctry[4]).strip
      return
    end

    srvc = info.match(/(SRVC\s*\..+SERVICE COMPANY:\s*(.*))|(SRVC\s*\.\s*(.*)\s*:\s*SERVICE COMPANY)/)
    unless srvc.nil?
      @well_info.service_company = (srvc[2] or srvc[4]).strip
      return
    end

    data = info.match(/(DATE\s*\..+LOG DATE:\s*(.*))|(DATE\s*\.\s*(.*)\s*:\s*LOG DATE)/)
    unless data.nil?
      @well_info.date_logged = (data[2] or data[4]).strip
      return
    end

    uwi = info.match(/(UWI\s*\..+UNIQUE WELL ID:\s*(.*))|(UWI\s*\.\s*(.*)\s*:\s*UNIQUE WELL ID)/)
    unless uwi.nil?
      @well_info.uwi = (uwi[2] or uwi[4]).strip
      return
    end

  end

  def set_other_info(info)
  end
{'fraction_non_alphanumeric': 0.2507211839959865, 'fraction_numerical': 0.01555248965257745, 'mean_word_length': 2.4760244115082823, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4777989', 'n_tokens_mistral': 3484, 'n_tokens_neox': 3377, 'n_words': 474}