<commit_before>class TranslationTable

	def self.[](key=nil)
		short(key) || value(key) || nil
	end

#	DO NOT MEMORIZE HERE.  IT ENDS UP IN ALL SUBCLASSES
#	Doesn't really seem necessary.  It isn't that complicated.

	#	[1,2,999]
	def self.valid_values
#		@@valid_values ||= table.collect{ |x| x[:value] }
		table.collect{ |x| x[:value] }
	end

	#	[['Yes',1],['No',2],["Don't Know",999]]
	def self.selector_options
#		@@selector_options ||= table.collect{|x| [x[:long],x[:value]] }
		table.collect{|x| [x[:long],x[:value]] }
	end

protected

	def self.short(key)
		index = table.find_index{|x| x[:short] == key.to_s }
		( index.nil? ) ? nil : table[index][:value]
	end

	def self.value(key)
		index = table.find_index{|x| x[:value] == key.to_i }
		( index.nil? ) ? nil : table[index][:long] 
	end

	def self.table
		[]
	end
end


class YNDK < TranslationTable
	#	unique translation table
	def self.table
		@@table ||= [
			{ :value => 1,   :short => 'yes', :long => "Yes" },
			{ :value => 2,   :short => 'no',  :long => "No" },
			{ :value => 999, :short => 'dk',  :long => "Don't Know" }
		]
	end
end
#
#	YNDK[1]     => 'Yes'
#	YNDK['1']   => 'Yes'
#	YNDK['yes'] => 1
#	YNDK[:yes]  => 1
#	YNDK[:asdf] => nil
#
class YNODK < TranslationTable
	def self.table
		@@table ||= [
			{ :value => 1,   :short => 'yes',   :long => "Yes" },
			{ :value => 2,   :short => 'no',    :long => "No" },
			{ :value => 3,   :short => 'other', :long => "Other" },
			{ :value => 999, :short => 'dk',    :long => "Don't Know" }
		]
	end
end
class YNRDK < TranslationTable
	def self.table
		@@table ||= [<commit_msg>Manual handling of tests using :nil as a key.<commit_after>class TranslationTable

	def self.[](key=nil)
		short(key) || value(key) || nil
	end

#	DO NOT MEMORIZE HERE.  IT ENDS UP IN ALL SUBCLASSES
#	Doesn't really seem necessary.  It isn't that complicated.

	#	[1,2,999]
	def self.valid_values
#		@@valid_values ||= table.collect{ |x| x[:value] }
		table.collect{ |x| x[:value] }
	end

	#	[['Yes',1],['No',2],["Don't Know",999]]
	def self.selector_options
#		@@selector_options ||= table.collect{|x| [x[:long],x[:value]] }
		table.collect{|x| [x[:long],x[:value]] }
	end

protected

	def self.short(key)
		index = table.find_index{|x| x[:short] == key.to_s }
		( index.nil? ) ? nil : table[index][:value]
	end

	def self.value(key)
#	used in testing and breaks in ruby 1.9.3 so next line is NEEDED!
return nil if key == :nil
		index = table.find_index{|x| x[:value] == key.to_i }
		( index.nil? ) ? nil : table[index][:long] 
	end

	def self.table
		[]
	end
end


class YNDK < TranslationTable
	#	unique translation table
	def self.table
		@@table ||= [
			{ :value => 1,   :short => 'yes', :long => "Yes" },
			{ :value => 2,   :short => 'no',  :long => "No" },
			{ :value => 999, :short => 'dk',  :long => "Don't Know" }
		]
	end
end
#
#	YNDK[1]     => 'Yes'
#	YNDK['1']   => 'Yes'
#	YNDK['yes'] => 1
#	YNDK[:yes]  => 1
#	YNDK[:asdf] => nil
#
#
#	YNDK[:nil] => ????	# worked in ruby 1.8.7, errors in 1.9.3
#		:nil.to_i => NoMethodError: undefined method `to_i' for :nil:Symbol
#		what did it do?  was that correct?
#
#	in jruby 
#	jruby-1.5.1 :003 > :nil.to_i
#	 => 610 
#	which, in hind site, makes some sort of sense, but is NOT what is wanted
#	same in ruby 1.8.7 (basically object id)
#
class YNODK < TranslationTable
	def self.table
		@@table ||= [
			{ :value => 1,   :short => 'yes',   :long => "Yes" },
			{ :value => 2,   :short => 'no',    :long => "No" },
			{ :value => 3,   :short => 'other', :long => "Other" },
			{ :value => 999, :short => 'dk',    :long => "Don't Know" }
		]
	end
end
class YNRDK < TranslationTable
	def self.table
		@@table ||= [
{'fraction_non_alphanumeric': 0.20943550586310336, 'fraction_numerical': 0.019361876193073356, 'mean_word_length': 3.2950819672131146, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 59, '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': '2752384', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1485, 'n_words': 378}