<commit_before>module NobleNames
  module CoreExt
    module String
      # Capitalizes each Word in a name
      # except for those which are nobility particles
      #   '<NAME>'.to_title      # => '<NAME>'
      #   'jamie of windsor'.to_title # => 'Jamie of Windsor'
      def to_title
        dup.to_title!
      end

      def to_title!
        words = split(/\W+/)
        words.map! do |w|
          noble_capitalize(w)
        end
        replace(words * ' ')
      end

      private

      def noble_capitalize(word)
        in_particle_list?(word) ? word : word.capitalize
      end

      def in_particle_list?(word)
        particles = PARTICLES
                    .select { |lang| NobleNames.configuration.languages.include?(lang.to_sym) }
                    .values.flatten
        particles.include? word
      end
    end
  end
end<commit_msg>Moved noble-methods from string to module.<commit_after>module NobleNames
  module CoreExt
    module String
      # Capitalizes each Word in a name
      # except for those which are nobility particles
      #   '<NAME>'.to_title      # => '<NAME>'
      #   'jamie of windsor'.to_title # => 'Jamie of Windsor'
      def to_title
        dup.to_title!
      end

      def to_title!
        words = split(/\s+/)
        words.map! { |w| NobleNames.noble_capitalize(w) }
        replace(words * ' ')
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09280575539568345, 'fraction_numerical': 0.0, 'mean_word_length': 1.8621399176954732, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '1989369', 'n_tokens_mistral': 434, 'n_tokens_neox': 416, 'n_words': 110}