

'''simple docstring'''

import unittest

from cer import CER


lowerCAmelCase_     =      CER()







class lowerCamelCase   (    unittest.TestCase				):

				def 					_lowerCamelCase    (       self )    ->							Any:
					snake_case							=					['''White House''']
					snake_case							=					['''white house''']
					# S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.1_818_181_818 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							Optional[Any]:
					snake_case							=					['''were wolf''']
					snake_case							=					['''werewolf''']
					# S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.1_111_111 ) < 1E-6 )

					snake_case							=					['''werewolf''']
					snake_case							=					['''weae     wolf''']
					# S = 1, D = 1, I = 0, N = 8, CER = 0.25
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.25 ) < 1E-6 )

					# consecutive whitespaces case 1
					snake_case							=					['''were wolf''']
					snake_case							=					['''were               wolf''']
					# S = 0, D = 0, I = 0, N = 9, CER = 0
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.0 ) < 1E-6 )

					# consecutive whitespaces case 2
					snake_case							=					['''were   wolf''']
					snake_case							=					['''were               wolf''']
					# S = 0, D = 0, I = 0, N = 9, CER = 0
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.0 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							Dict:
					snake_case							=					['''werewolf''']
					snake_case							=					['''weaewolf''']
					# S = 1, D = 0, I = 0, N = 8, CER = 0.125
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.125 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							Optional[Any]:
					snake_case							=					['''werewolf''']
					snake_case							=					['''wereawolf''']
					# S = 0, D = 1, I = 0, N = 8, CER = 0.125
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.125 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							str:
					snake_case							=					['''werewolf''']
					snake_case							=					['''wereolf''']
					# S = 0, D = 0, I = 1, N = 8, CER = 0.125
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.125 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							List[str]:
					snake_case							=					['''werewolf''']
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertEqual(lowerCamelCase_,						0.0 )

				def 					_lowerCamelCase    (       self )    ->							Any:
					snake_case							=					['''werewolf''', '''I am your father''']
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertEqual(lowerCamelCase_,						0.0 )

					snake_case							=					['''werewolf''', '''I am your father''', '''doge''']
					snake_case							=					['''werxwolf''', '''I       am your father''', '''doge''']
					# S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.03_571_428 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							Optional[Any]:
					snake_case							=					['''My hovercraft''', '''is full of eels''']
					snake_case							=					['''My hovercraft is full''', ''' of eels''']
					# S = 0, D = 0, I = 2, N = 28, CER = 2 / 28
					# whitespace at the front of " of eels" will be strip during preporcessing
					# so need to insert 2 whitespaces
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_,						concatenate_texts=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.071_428 ) < 1E-6 )

				def 					_lowerCamelCase    (       self )    ->							str:
					snake_case							=					['''我能吞下玻璃而不伤身体''']
					snake_case							=					[''' 能吞虾玻璃而 不霜身体啦''']
					# S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.4_545_454_545 ) < 1E-6 )

					snake_case							=					['''我能吞下玻璃''', '''而不伤身体''']
					snake_case							=					['''我    能 吞 下 玻 璃''', '''而不伤身体''']
					# S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertTrue(abs(char_error_rate - 0.454_545_454_545 ) < 1E-6 )

					snake_case							=					['''我能吞下玻璃而不伤身体''']
					snake_case							=					cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )
					self.assertFalse(lowerCamelCase_,						0.0 )






				def 					_lowerCamelCase    (       self )    ->							Union[str, Any]:
					snake_case							=					['''''']
					snake_case							=					['''Hypothesis''']
					with self.assertRaises(lowerCamelCase_ ):
						cer.compute(predictions=lowerCamelCase_,						references=lowerCamelCase_ )


if __name__ == "__main__":
						unittest.main()











def 		lowercase__ (		__A:						int					):





					'''simple docstring'''






					if not isinstance(__A				,__A					):
										__magic_name__				:						Dict     				=				F'''Input value of [number={number}] must be an integer'''
										raise TypeError(__A					)
					if number < 0 or number % 2 == 1:
										return False
					__magic_name__				:						Any     				=				int(number**0.5					)
					return number == number_sqrt * (number_sqrt + 1)


if __name__ == "__main__":
	import doctest

	doctest.testmod()



