<commit_before>require 'bundler/setup'
require 'bagit'
require 'csv'
require 'find'
require 'nokogiri'
require 'time'

class BagAnalyzer
  def initialize options
    @node = options[:node]
    @mets = File.join(@node, 'data', 'mets.xml')
    @xml = Nokogiri::XML IO.read(@mets)
  end

  def repository
    begin
      @xml.xpath('//mets:agent[@TYPE="REPOSITORY"]/mets:name', 'mets' => 'http://www.loc.gov/METS/').first.content
    rescue
      'no repository'
    end
  end

  def total_size
    size = 0
    Find.find(@node) do |path|
      if File.file? path
        size += File.size(path)
      end
    end
    size
  end

  # This method of distinguishing AIPs from DIPs does NOT
  # generalize to arbitrarily-named nodes, but it works 
  # for the naming scheme used for nodes in the KUDL system.
  #
  # --mps 2014-01-14
  def type
    if @node.include? 'aips'
      'aip'
    else
      'dip'
    end
  end
end

module Lomatia
  module Worker
    module GatherRespositoryStatistics
      class Bag
        @queue = :lomatia
  <commit_msg>correct name of class<commit_after>require 'bundler/setup'
require 'bagit'
require 'csv'
require 'find'
require 'nokogiri'
require 'time'

class BagAnalyzer
  def initialize options
    @node = options[:node]
    @mets = File.join(@node, 'data', 'mets.xml')
    @xml = Nokogiri::XML IO.read(@mets)
  end

  def repository
    begin
      @xml.xpath('//mets:agent[@TYPE="REPOSITORY"]/mets:name', 'mets' => 'http://www.loc.gov/METS/').first.content
    rescue
      'no repository'
    end
  end

  def total_size
    size = 0
    Find.find(@node) do |path|
      if File.file? path
        size += File.size(path)
      end
    end
    size
  end

  # This method of distinguishing AIPs from DIPs does NOT
  # generalize to arbitrarily-named nodes, but it works 
  # for the naming scheme used for nodes in the KUDL system.
  #
  # --mps 2014-01-14
  def type
    if @node.include? 'aips'
      'aip'
    else
      'dip'
    end
  end
end

module Lomatia
  module Worker
    module GatherRepositoryStatistics
      class Bag
        @queue = :lomatia
  
{'fraction_non_alphanumeric': 0.1095759885659838, 'fraction_numerical': 0.00857551214864221, 'mean_word_length': 2.5714285714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '2137789', 'n_tokens_mistral': 761, 'n_tokens_neox': 727, 'n_words': 211}