<commit_before># This file contains functionality to extract information from a
# DAITSS DIP for use in constructing a TIPR DIP

require 'nokogiri'
require 'time'

class DIP
  
  attr_reader :rel_path, :ieid, :package_id, :create_date, :original_representation, :current_representation, :migration_map
  
  NS = {
    'mets' => 'http://www.loc.gov/METS/',
    'daitss' => 'http://www.fcla.edu/dls/md/daitss/',
    'xlink' => 'http://www.w3.org/1999/xlink'
  }

  def initialize(path)
    @path = path.chomp('/')     # Strip any trailing /es
    @doc = load_descriptor
    @rel_path = load_rel_path
    @ieid = load_ieid
    @package_id = load_package_id
    @create_date = load_create_date
    @dfid_map = load_dfid_map
    @migration_map = load_migration_map
    @original_representation = load_original_representation
    @current_representation = load_current_representation
  end
  
  def events_by_oid(oid)        # Given an OID, retrieve events
    @doc.xpath('//daitss:EVENT', NS).select do |event|
      event.xpath('./daitss:OID', NS).first.content == oid
    end
  end
  
  def events(fid)               # Given a file id, retrieve events
    events_by_oid(@dfid_map.index(fid).to_s)
  end
  
  protected<commit_msg>adding attribute reader for dfid map<commit_after># This file contains functionality to extract information from a
# DAITSS DIP for use in constructing a TIPR DIP

require 'nokogiri'
require 'time'

class DIP
  
  attr_reader :rel_path, :ieid, :package_id, :create_date, :original_representation, :current_representation, :migration_map, :dfid_map
  
  NS = {
    'mets' => 'http://www.loc.gov/METS/',
    'daitss' => 'http://www.fcla.edu/dls/md/daitss/',
    'xlink' => 'http://www.w3.org/1999/xlink'
  }

  def initialize(path)
    @path = path.chomp('/')     # Strip any trailing /es
    @doc = load_descriptor
    @rel_path = load_rel_path
    @ieid = load_ieid
    @package_id = load_package_id
    @create_date = load_create_date
    @dfid_map = load_dfid_map
    @migration_map = load_migration_map
    @original_representation = load_original_representation
    @current_representation = load_current_representation
  end
  
  def events_by_oid(oid)        # Given an OID, retrieve events
    @doc.xpath('//daitss:EVENT', NS).select do |event|
      event.xpath('./daitss:OID', NS).first.content == oid
    end
  end
  
  def events(fid)               # Given a file id, retrieve events
    events_by_oid(@dfid_map.index(fid).to_s)
  end
  
  protected
{'fraction_non_alphanumeric': 0.11263073209975864, 'fraction_numerical': 0.004022526146419952, 'mean_word_length': 3.3708260105448153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '301555', 'n_tokens_mistral': 899, 'n_tokens_neox': 868, 'n_words': 193}