<commit_before>
# set("hi")
require_relative 'context'
require_relative 'scopes/text'
require_relative 'scopes/base'
require_relative 'scopes/node'
require_relative 'scopes/attribute'

module Tritium
  module Engines
    class Standard < Base
      class Run
        attr :export_vars
        include Tritium::Parser::Instructions
        include BaseFunctions
        include TextFunctions
        include NodeFunctions
        include AttributeFunctions

        def initialize(logger, options = {})
          @logger = logger
          @env = options["env"] || options[:env] || {}
          @matchers = []
          @export_vars = []
          @stack = []
        end
        
        def process(ins, ctx)
          @stack.push ctx
          if ins.is_a?(Tritium::Parser::Instructions::Invocation)
            # Collect and evaluate the pos_args
            pos_args, kwd_args = process_args(ins, ctx)
            #puts ctx.type.inspect
            if ins.base?
              base_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Text"
              text_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Node" || ctx.type == "XMLNode"
              node_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Attribute"
              attribute_invocation(ins, ctx, pos_args, kwd_args)
            end
          elsif ins.is_a?(Tritium::Parser::Instructions::InlineBlock)
            run_children(ins, ctx)
          elsif ins.is_a?(Tritium::Parser::Instructions::Literal)
            ins.value
          elsif ins.is_a?(Tritium::Parser::Instructions::Reference)
            @env[ins.name.to_s]
          end
        ensure
          @stack.pop
        end
        
        def process_args(ins, ctx)
          pos_args = ins.pos_args.collect do |arg|
            if arg.is_a?(Instruction)
              process(arg, ctx)
            else
              arg
            end
          end
          
          kwd_args = {}
          ins.kwd_args.each do |key, value|
            if value.is_a?(Instruction)
              value = process(value, ctx)
            end
            kwd_args[key] = value
          end
          [pos_args, kwd_args]
        end
        <commit_msg>Fixing the else() issue!<commit_after>
# set("hi")
require_relative 'context'
require_relative 'scopes/text'
require_relative 'scopes/base'
require_relative 'scopes/node'
require_relative 'scopes/attribute'

module Tritium
  module Engines
    class Standard < Base
      class Run
        attr :export_vars
        include Tritium::Parser::Instructions
        include BaseFunctions
        include TextFunctions
        include NodeFunctions
        include AttributeFunctions

        def initialize(logger, options = {})
          @logger = logger
          @env = options["env"] || options[:env] || {}
          @matchers = []
          @export_vars = []
          @stack = []
        end
        
        def process(ins, ctx)
          @stack.push ctx
          if ins.is_a?(Tritium::Parser::Instructions::Invocation)
            # Collect and evaluate the pos_args
            pos_args, kwd_args = process_args(ins, ctx)
            #puts ctx.type.inspect
            if ins.base?
              base_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Text"
              text_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Node" || ctx.type == "XMLNode"
              node_invocation(ins, ctx, pos_args, kwd_args)
            elsif ctx.type == "Attribute"
              attribute_invocation(ins, ctx, pos_args, kwd_args)
            end
          elsif ins.is_a?(Tritium::Parser::Instructions::InlineBlock)
            run_children(ins, ctx)
          elsif ins.is_a?(Tritium::Parser::Instructions::Literal)
            ins.value || ""
          elsif ins.is_a?(Tritium::Parser::Instructions::Reference)
            @env[ins.name.to_s] || ""
          end
        ensure
          @stack.pop
        end
        
        def process_args(ins, ctx)
          pos_args = ins.pos_args.collect do |arg|
            if arg.is_a?(Instruction)
              process(arg, ctx)
            else
              arg
            end
          end
          
          kwd_args = {}
          ins.kwd_args.each do |key, value|
            if value.is_a?(Instruction)
              value = process(value, ctx)
            end
            kwd_args[key] = value
          end
          [pos_args, kwd_args]
        end
        
{'fraction_non_alphanumeric': 0.09522752497225305, 'fraction_numerical': 0.0, 'mean_word_length': 1.7046818727490995, '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': '1539861', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1302, 'n_words': 281}