<commit_before>#
# $Id: book.rb 4315 2009-09-02 04:15:24Z kmuto $
#
# Copyright (c) 2002-2008 <NAME>
#               2009 <NAME>, <NAME>
#
# This program is free software.
# You can distribute or modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
require 'review/configure'
require 'review/catalog'

module ReVIEW
  module Book
    class Base

      attr_writer :config

      def self.load_default
        basedir = "."
        if File.file?("#{basedir}/CHAPS") ||
            File.file?("#{basedir}/catalog.yml")
          book = load(basedir)
          book
        else
          new(basedir)
        end
      end

      def self.load(dir)
        update_rubyenv dir
        new(dir)
      end

      @basedir_seen = {}

      def self.update_rubyenv(dir)
        return if @basedir_seen.key?(dir)
        if File.file?("#{dir}/review-ext.rb")
          if ENV["REVIEW_SAFE_MODE"].to_i & 2 > 0
            warn "review-ext.rb is prohibited in safe mode. ignored."
          else
            Kernel.load File.expand_path("#{dir}/review-ext.rb")
          end
        end
        @basedir_seen[dir] = true
      end

      def initialize(basedir)
        @basedir = basedir
        @parts = nil
        @chapter_index = nil
      end

      def bib_file
        config["bib_file"]
      end

      def reject_file
        config["reject_file"]
      end

      def ext
        config["ext"]<commit_msg>add default value for @config<commit_after>#
# $Id: book.rb 4315 2009-09-02 04:15:24Z kmuto $
#
# Copyright (c) 2002-2008 <NAME>
#               2009 <NAME>, <NAME>
#
# This program is free software.
# You can distribute or modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
require 'review/configure'
require 'review/catalog'

module ReVIEW
  module Book
    class Base

      attr_writer :config

      def self.load_default
        basedir = "."
        if File.file?("#{basedir}/CHAPS") ||
            File.file?("#{basedir}/catalog.yml")
          book = load(basedir)
          book
        else
          new(basedir)
        end
      end

      def self.load(dir)
        update_rubyenv dir
        new(dir)
      end

      @basedir_seen = {}

      def self.update_rubyenv(dir)
        return if @basedir_seen.key?(dir)
        if File.file?("#{dir}/review-ext.rb")
          if ENV["REVIEW_SAFE_MODE"].to_i & 2 > 0
            warn "review-ext.rb is prohibited in safe mode. ignored."
          else
            Kernel.load File.expand_path("#{dir}/review-ext.rb")
          end
        end
        @basedir_seen[dir] = true
      end

      def initialize(basedir)
        @basedir = basedir
        @parts = nil
        @chapter_index = nil
        @config = ReVIEW::Configure.values
      end

      def bib_file
        config["bib_file"]
      end

      def reject_file
        config["reject_file"]
      end

      def ext
        config["ext"]
{'fraction_non_alphanumeric': 0.10464738381540462, 'fraction_numerical': 0.022099447513812154, 'mean_word_length': 1.8685927306616963, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4590345', 'n_tokens_mistral': 1030, 'n_tokens_neox': 937, 'n_words': 261}