<commit_before># -*- coding: utf-8 -*-
module Kindai::Interface
  def self.download_url(url, config = { })
    book = Kindai::Book.new_from_permalink(url)
    download_book(book, config)
  end

  def self.download_book(book, config = { })
    downloader = Kindai::BookDownloader.new_from_book(book)
    downloader.output_directory = config[:output_directory] if config[:output_directory]
    downloader.retry_count = config[:retry_count] if config[:retry_count]
    Kindai::Util.logger.info "download #{book.title}(#{book.total_page} pages) to #{downloader.book_path}"
    downloader.download
  end

  def self.download_keyword(keyword, config = { })
    searcher = Kindai::Searcher.search(keyword)
    searcher.each_with_index { |book, index|
      begin
        Kindai::Util.logger.info "book #{index+1} / #{searcher.length}"
        download_book book, config
      rescue => error
        p error
      end
    }
  end
end<commit_msg>base_path<commit_after># -*- coding: utf-8 -*-
module Kindai::Interface
  def self.download_url(url, config = { })
    book = Kindai::Book.new_from_permalink(url)
    download_book(book, config)
  end

  def self.download_book(book, config = { })
    downloader = Kindai::BookDownloader.new_from_book(book)
    downloader.base_path = config[:base_path] if config[:base_path]
    downloader.retry_count = config[:retry_count] if config[:retry_count]
    Kindai::Util.logger.info "download #{book.title}(#{book.total_page} pages) to #{downloader.book_path}"
    downloader.download
  end

  def self.download_keyword(keyword, config = { })
    searcher = Kindai::Searcher.search(keyword)
    searcher.each_with_index { |book, index|
      begin
        Kindai::Util.logger.info "book #{index+1} / #{searcher.length}"
        download_book book, config
      rescue => error
        p error
      end
    }
  end
end
{'fraction_non_alphanumeric': 0.12641815235008103, 'fraction_numerical': 0.0021609940572663426, 'mean_word_length': 3.712468193384224, 'pattern_counts': {'":': 0, '<': 3, '<?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': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4857047', 'n_tokens_mistral': 593, 'n_tokens_neox': 606, 'n_words': 113}