<commit_before><commit_msg>import from torch7-library<commit_after>-- Clement's old gabor function


require 'image'
require 'lab'
require 'xlua'

-- For the similar Gabor code go to 
-- http://www.mathworks.com/matlabcentral/fileexchange/23253-gabor-filter/content/Gabor%20Filter/gabor_fn.m


-- Size should be odd number 
-- angle (in rad)
-- elipse_ratio = aspect ratio(0.5)

function gabor(size, sigma, angle, period, ellipse_ratio)
      -- init matrix
      local data = lab.zeros(size,size)

      -- image -> pixel
      period = period * size
      sigma = sigma * size

      -- set params
      local halfsize = math.floor(size/2)
      local sigma_x = sigma
      local sigma_y = sigma/ellipse_ratio

      for y=-halfsize,halfsize do
         for x=-halfsize,halfsize do
				
            x_angle = x*math.cos(angle) + y*math.sin(angle)
            y_angle = -x*math.sin(angle) + y*math.cos(angle)
            data[x+halfsize+1][y+halfsize+1] 
               = math.exp(-0.5*(x_angle^2/sigma_x^2 + y_angle^2/sigma_y^2))
                 * math.cos(2*math.pi*x_angle/period)
         end
      end
      
      -- return new tensor
      return data
   end
{'fraction_non_alphanumeric': 0.11910882604970009, 'fraction_numerical': 0.01713796058269066, 'mean_word_length': 2.2625698324022347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '5765768', 'n_tokens_mistral': 416, 'n_tokens_neox': 389, 'n_words': 86}