<commit_before>module Gisele::Analysis
  class Glts

    def union(other)
      Glts.new(session) do |g|
        init_state = g.add_state(:initial => true)
        add_glts = lambda do |from, to|
          from.dup(to) do |s, t|
            if s.initial?
              t.initial!(false)
              to.connect(init_state, t, :guard => from.c0)
            end
          end
        end
        add_glts[self,  g]
        add_glts[other, g]
      end
    end<commit_msg>Add nary union of glts.<commit_after>module Gisele::Analysis
  class Glts

    class Union

      def initialize(session)
        @session = session
      end
      attr_reader :session

      def call(operands)
        Glts.new(session) do |to|
          init_state = to.add_state(:initial => true)
          operands.each_with_index do |from,index|
            add_glts(from, to, init_state, :"wf#{index}")
          end
        end
      end

    private

      def add_glts(from, to, init_state, origin)
        from.dup(to) do |s, t|
          if s.initial?
            t.initial!(false)
            to.connect(init_state, t, :guard => from.c0)
          end
          t[:origin] = origin
        end
      end

    end

    def union(other)
      Union.new(session).call([self, other])
    end
{'fraction_non_alphanumeric': 0.1031496062992126, 'fraction_numerical': 0.0015748031496062992, 'mean_word_length': 1.6757894736842105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1665752', 'n_tokens_mistral': 415, 'n_tokens_neox': 407, 'n_words': 99}