<commit_before>require 'net/ftp'
require 'fileutils'
include FileUtils

class FtpAdapter
  def initialize(host, user, password, remote_dir, params = {})
    # set up folders
    @download_dir, @upload_dir = params[:download_dir], params[:upload_dir]
    
    # set up the ftp connection
    @host, @user, @password, @remote_dir = host, user, password, remote_dir
    @ftp = Net::FTP.new(@host, @user, @password)
    @ftp.chdir @remote_dir if @remote_dir    
  end
  
  def download_file(basename)
    raise "no download directory specified in FTP adaptor" unless @download_dir
    check_connection
    whole_name = File.join(@download_dir, "#{basename}.bmp")
    part_name  = whole_name + ".part"<commit_msg>Set passive mode in FtpAdaptor initializer.<commit_after>require 'net/ftp'
require 'fileutils'
include FileUtils

class FtpAdapter
  def initialize(host, user, password, remote_dir, params = {})
    # set up folders
    @download_dir, @upload_dir = params[:download_dir], params[:upload_dir]
    
    # set up the ftp connection
    @host, @user, @password, @remote_dir = host, user, password, remote_dir
    @ftp = Net::FTP.new(@host, @user, @password)
    @ftp.chdir @remote_dir if @remote_dir
    @ftp.passive = true
  end
  
  def download_file(basename)
    raise "no download directory specified in FTP adaptor" unless @download_dir
    check_connection
    whole_name = File.join(@download_dir, "#{basename}.bmp")
    part_name  = whole_name + ".part"
{'fraction_non_alphanumeric': 0.11050477489768076, 'fraction_numerical': 0.0, 'mean_word_length': 4.147368421052631, 'pattern_counts': {'":': 0, '<': 3, '<?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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321358', 'n_tokens_mistral': 480, 'n_tokens_neox': 472, 'n_words': 130}