<commit_before># frozen_string_literal: true

require 'English'
require 'open3'
require 'shellwords'
require 'thwait'
require 'yle_tf/error'
require 'yle_tf/logger'
require 'yle_tf/system/io_handlers'

class YleTf
  # Helpers to execute system commands with error handling
  class System
    ExecuteError = Class.new(YleTf::Error)

    DEFAULT_ERROR_HANDLER = ->(_exit_code, error) { raise error }.freeze

    DEFAULT_IO_HANDLERS = {
      stdin:  :dev_null,
      stdout: :info,
      stderr: :error
    }.freeze

    def self.console_cmd(*args, **opts)
      env = opts[:env] || {}

      YleTf::Logger.debug { "Calling #{cmd_string(args, env)}" }

      system(env, *args)
      verify_exit_status($CHILD_STATUS, opts[:error_handler], cmd_string(args))
    end
<commit_msg>Add missing `require`<commit_after># frozen_string_literal: true

require 'English'
require 'open3'
require 'shellwords'
require 'stringio'
require 'thwait'
require 'yle_tf/error'
require 'yle_tf/logger'
require 'yle_tf/system/io_handlers'

class YleTf
  # Helpers to execute system commands with error handling
  class System
    ExecuteError = Class.new(YleTf::Error)

    DEFAULT_ERROR_HANDLER = ->(_exit_code, error) { raise error }.freeze

    DEFAULT_IO_HANDLERS = {
      stdin:  :dev_null,
      stdout: :info,
      stderr: :error
    }.freeze

    def self.console_cmd(*args, **opts)
      env = opts[:env] || {}

      YleTf::Logger.debug { "Calling #{cmd_string(args, env)}" }

      system(env, *args)
      verify_exit_status($CHILD_STATUS, opts[:error_handler], cmd_string(args))
    end

{'fraction_non_alphanumeric': 0.12032932235592148, 'fraction_numerical': 0.001266624445851805, 'mean_word_length': 3.891640866873065, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5070040', 'n_tokens_mistral': 555, 'n_tokens_neox': 536, 'n_words': 124}