<commit_before>class MarkovChain

	attr_accessor :output_length		# max number of words that will be generated

	# private variables
	attr_accessor :_prefix_length
	attr_accessor :_case_insensitive
	attr_accessor :_last_prefix
	attr_accessor :_last_suffix
	attr_accessor :_chain

	# constants
	LINE_ENDINGS = ['.', '!', '?']

	def initialize(options = {})
		@_prefix_length = options[:prefix_length] || 2
		raise ArgumentError, "Prefix_length must be at least 1" if @_prefix_length < 1
		@_last_prefix = Array.new(@_prefix_length, '')
		@_last_suffix = ''
		@_chain = Hash.new
		@output_length = options[:output_length] || 26
		@_case_insensitive = options[:case_insensitive].nil? ? true : options[:case_insensitive]
	end

	def add(word)
			self.new_line if (LINE_ENDINGS.include? self._last_suffix[-1])
			self._last_prefix = self._next_prefix
			self._last_suffix = word
			if self._chain[self._last_prefix]
				self._chain[self._last_prefix] = self._chain[self._last_prefix] << word
			else
				self._chain[self._last_prefix] = [word]
			end
	end

	def add_line(line)
		self.new_line
		line.split.each do |word|
			self.add word
		end
	end

	# generates the suffix randomly by default
	def suffix(prefix, generator=lambda { |suffixes| suffixes[Random.rand(suffixes.length)] } )
		if self._chain[prefix]<commit_msg>Use setter methods when initializing instead of assigning instance variables directly<commit_after>class MarkovChain

	attr_accessor :output_length		# max number of words that will be generated

	# private variables
	attr_accessor :_prefix_length
	attr_accessor :_case_insensitive
	attr_accessor :_last_prefix
	attr_accessor :_last_suffix
	attr_accessor :_chain

	# constants
	LINE_ENDINGS = ['.', '!', '?']

	def initialize(options = {})
		self._prefix_length = options[:prefix_length] || 2
		raise ArgumentError, "Prefix_length must be at least 1" if self._prefix_length < 1
		self._last_prefix = Array.new(self._prefix_length, '')
		self._last_suffix = ''
		self._chain = Hash.new
		self.output_length = options[:output_length] || 26
		self._case_insensitive = options[:case_insensitive].nil? ? true : options[:case_insensitive]
	end

	def add(word)
			self.new_line if (LINE_ENDINGS.include? self._last_suffix[-1])
			self._last_prefix = self._next_prefix
			self._last_suffix = word
			if self._chain[self._last_prefix]
				self._chain[self._last_prefix] = self._chain[self._last_prefix] << word
			else
				self._chain[self._last_prefix] = [word]
			end
	end

	def add_line(line)
		self.new_line
		line.split.each do |word|
			self.add word
		end
	end

	# generates the suffix randomly by default
	def suffix(prefix, generator=lambda { |suffixes| suffixes[Random.rand(suffixes.length)] } )
		if self._chain[prefix]
{'fraction_non_alphanumeric': 0.10380116959064327, 'fraction_numerical': 0.0043859649122807015, 'mean_word_length': 4.713987473903966, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5068396', 'n_tokens_mistral': 1001, 'n_tokens_neox': 901, 'n_words': 205}