<commit_before>require 'digest'
require 'time'

class Catalog
  def initialize(dir='.')
    @dir = dir
  end
  
  def entries
    dirs = []
    files = []
    if File.expand_path(@dir).starts_with File.expand_path('.')
      Dir["#{@dir}*"].each do |entry|
        if File.directory?(entry)
          dir = entry#.sub(%r{^.+/},'')
          dirs << Catalog.new(dir)
        elsif entry =~ /\.epub$/
          epub = Epub.new(entry)
          files << epub unless epub.bad?
        end
      end
    end
    dirs + files
  end
  
  def path<commit_msg>handle root directory properly for catalog<commit_after>require 'digest'
require 'time'

class Catalog
  def initialize(dir='.')
    @dir = dir
  end
  
  def entries
    dirs = []
    files = []
    if File.expand_path(@dir).starts_with File.expand_path('.')
      Dir["#{@dir}/*"].each do |entry|
        if File.directory?(entry)
          dir = entry#.sub(%r{^.+/},'')
          dirs << Catalog.new(dir)
        elsif entry =~ /\.epub$/
          epub = Epub.new(entry)
          files << epub unless epub.bad?
        end
      end
    end
    dirs + files
  end
  
  def path
{'fraction_non_alphanumeric': 0.14929328621908128, 'fraction_numerical': 0.0, 'mean_word_length': 1.95822454308094, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '1946427', 'n_tokens_mistral': 398, 'n_tokens_neox': 387, 'n_words': 92}