<commit_before>require "ceifpar/version"

module Ceifpar
  # Your code goes here...
end<commit_msg>Move methods from raw script "ceifpar.rb"<commit_after>require "ceifpar/version"
require 'rmagick'

module Ceifpar
  class << self
    def write_image(image, dst_path)
      image.write(dst_path)
    end

    def resize_image(image, ratio)
      image.resize(ratio)
    end

    def resize_image_with_path(path, ratio)
      return false unless self.is_jpeg?(path)

      image = Magick::ImageList.new(path)
      image.resize(ratio)
    end

    def remove_exif!(image)
      image.strip!
    end

    def remove_exif_with_path(path)
      return false unless self.is_jpeg?(path)

      image = Magick::ImageList.new(path)
      image.strip!
    end

    def is_jpeg?(path)
      if File.extname(path).downcase =~ /jpe?g/
        return true
      else
        return false
      end
    end

    def normalize_ratio(str)
      #fraction
      if str.include?("/") then
        rat = str.partition("/")
        ratio = Rational(rat[0].to_f , rat[2].to_f).to_f
      #percent
      elsif str.include?("%") then
        ratio = str.to_f / 100
      #decimal
      else
        ratio = str.to_f
      end
      return ratio
    end
  end
end
{'fraction_non_alphanumeric': 0.10016155088852989, 'fraction_numerical': 0.004038772213247173, 'mean_word_length': 2.286472148541114, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2587644', 'n_tokens_mistral': 428, 'n_tokens_neox': 412, 'n_words': 96}