<commit_before>require_relative 'bel_citation_serialization'
require_relative 'bel_discrete_serialization'
require_relative 'bel_top_down_serialization'
require 'bel'

module BEL::Translator::Plugins

  module BelScript

    class BelYielder

      # Create a {BelYielder} object that serializes {BEL::Model::Evidence} to
      # BEL Script.
      #
      # @param [Enumerator<BEL::Model::Evidence>] data evidence data iterated
      #        using +each+
      # @option options [Boolean] :write_header +true+ to write the BEL Script
      #         document header; +false+ to not write the BEL Script document
      #         header
      # @option options [Symbol,Module] :serialization the serialization
      #         technique to use for evidence; a +Module+ type will be used as
      #         is; a +Symbol+ type will be mapped as
      #         +:discrete+ => {BelDiscreteSerialization},
      #         +:topdown+ => {BelTopDownSerialization},
      #         +:citation+ => {BelCitationSerialization}; otherwise the default
      #         of {BelCitationSerialization} is used
      def initialize(data, options = {})
        @data                   = data
        @write_header           = options.fetch(:write_header, true)

        # augment self with BEL serialization stategy.
        serialization = options[:serialization]
        serialization_module =
          case serialization
          when Module
            serialization
          when String, Symbol
            serialization_refs = {
              :discrete => BelDiscreteSerialization,
              :topdown  => BelTopDownSerialization,
              :citation => BelCitationSerialization,
            }
            serialization_module = serialization_refs[serialization.to_sym]
            unless serialization_module
                raise %Q{No BEL serialization strategy for "#{serialization}"}
            end
            serialization_module
          else
            # Default to citation serialization.
            BelCitationSerialization
          end

        self_eigenclass = (class << self; self; end)
        self_eigenclass.include(serialization_module)
      end

      def each
        if block_given?
          header_flag = true
          @data.each { |evidence|

            # serialize evidence
            bel = to_bel(evidence)

            if @write_header && header_flag<commit_msg>call Class#include using send, supports Ruby 2.0.0<commit_after>require_relative 'bel_citation_serialization'
require_relative 'bel_discrete_serialization'
require_relative 'bel_top_down_serialization'
require 'bel'

module BEL::Translator::Plugins

  module BelScript

    class BelYielder

      # Create a {BelYielder} object that serializes {BEL::Model::Evidence} to
      # BEL Script.
      #
      # @param [Enumerator<BEL::Model::Evidence>] data evidence data iterated
      #        using +each+
      # @option options [Boolean] :write_header +true+ to write the BEL Script
      #         document header; +false+ to not write the BEL Script document
      #         header
      # @option options [Symbol,Module] :serialization the serialization
      #         technique to use for evidence; a +Module+ type will be used as
      #         is; a +Symbol+ type will be mapped as
      #         +:discrete+ => {BelDiscreteSerialization},
      #         +:topdown+ => {BelTopDownSerialization},
      #         +:citation+ => {BelCitationSerialization}; otherwise the default
      #         of {BelCitationSerialization} is used
      def initialize(data, options = {})
        @data                   = data
        @write_header           = options.fetch(:write_header, true)

        # augment self with BEL serialization stategy.
        serialization = options[:serialization]
        serialization_module =
          case serialization
          when Module
            serialization
          when String, Symbol
            serialization_refs = {
              :discrete => BelDiscreteSerialization,
              :topdown  => BelTopDownSerialization,
              :citation => BelCitationSerialization,
            }
            serialization_module = serialization_refs[serialization.to_sym]
            unless serialization_module
                raise %Q{No BEL serialization strategy for "#{serialization}"}
            end
            serialization_module
          else
            # Default to citation serialization.
            BelCitationSerialization
          end

        self_eigenclass = (class << self; self; end)
        self_eigenclass.send(:include, serialization_module)
      end

      def each
        if block_given?
          header_flag = true
          @data.each { |evidence|

            # serialize evidence
            bel = to_bel(evidence)

            if @write_header && header_flag
{'fraction_non_alphanumeric': 0.07237386269644334, 'fraction_numerical': 0.0006203473945409429, 'mean_word_length': 2.116623711340206, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '6434648', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1193, 'n_words': 338}