





'''simple docstring'''






import unittest

from cer import CER


snake_case_     			=						CER()


class 	_lowercase    (				unittest.TestCase					):


   def        snake_case					(			self       ):
       A							:							Optional[Any]				=    ["""White House"""]
       A							:							Tuple				=    ["""white house"""]
       # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
       A							:							Any				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.1818181818       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							Optional[int]				=    ["""were wolf"""]
       A							:							Tuple				=    ["""werewolf"""]
       # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
       A							:							Any				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.1111111       ) < 1E-6       )

       A							:							str				=    ["""werewolf"""]
       A							:							List[Any]				=    ["""weae     wolf"""]
       # S = 1, D = 1, I = 0, N = 8, CER = 0.25
       A							:							Tuple				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.25       ) < 1E-6       )

       # consecutive whitespaces case 1
       A							:							int				=    ["""were wolf"""]
       A							:							Dict				=    ["""were               wolf"""]
       # S = 0, D = 0, I = 0, N = 9, CER = 0
       A							:							str				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.0       ) < 1E-6       )

       # consecutive whitespaces case 2
       A							:							List[str]				=    ["""were   wolf"""]
       A							:							Optional[int]				=    ["""were               wolf"""]
       # S = 0, D = 0, I = 0, N = 9, CER = 0
       A							:							Optional[Any]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.0       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							Dict				=    ["""werewolf"""]
       A							:							str				=    ["""weaewolf"""]
       # S = 1, D = 0, I = 0, N = 8, CER = 0.125
       A							:							Optional[int]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.125       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							List[str]				=    ["""werewolf"""]
       A							:							Tuple				=    ["""wereawolf"""]
       # S = 0, D = 1, I = 0, N = 8, CER = 0.125
       A							:							Optional[Any]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.125       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							List[str]				=    ["""werewolf"""]
       A							:							Optional[Any]				=    ["""wereolf"""]
       # S = 0, D = 0, I = 1, N = 8, CER = 0.125
       A							:							int				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.125       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							Dict				=    ["""werewolf"""]
       A							:							Tuple				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertEqual(__UpperCamelCase     , 0.0       )


   def        snake_case					(			self       ):
       A							:							List[str]				=    ["""werewolf""", """I am your father"""]
       A							:							int				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertEqual(__UpperCamelCase     , 0.0       )

       A							:							Dict				=    ["""werewolf""", """I am your father""", """doge"""]
       A							:							Optional[Any]				=    ["""werxwolf""", """I       am your father""", """doge"""]
       # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
       A							:							Union[str, Any]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.03571428       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							List[str]				=    ["""My hovercraft""", """is full of eels"""]
       A							:							Union[str, Any]				=    ["""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
       A							:							str				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase     , concatenate_texts=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.071428       ) < 1E-6       )


   def        snake_case					(			self       ):
       A							:							int				=    ["""我能吞下玻璃而不伤身体"""]
       A							:							Optional[Any]				=    [""" 能吞虾玻璃而 不霜身体啦"""]
       # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
       A							:							List[Any]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.4545454545       ) < 1E-6       )

       A							:							Union[str, Any]				=    ["""我能吞下玻璃""", """而不伤身体"""]
       A							:							Optional[Any]				=    ["""我    能 吞 下 玻 璃""", """而不伤身体"""]
       # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
       A							:							List[str]				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertTrue(abs(char_error_rate - 0.454545454545       ) < 1E-6       )

       A							:							Union[str, Any]				=    ["""我能吞下玻璃而不伤身体"""]
       A							:							Dict				=    cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )
       self.assertFalse(__UpperCamelCase     , 0.0       )


   def        snake_case					(			self       ):
       A							:							List[Any]				=    [""""""]
       A							:							Dict				=    ["""Hypothesis"""]
       with self.assertRaises(__UpperCamelCase       ):
           cer.compute(predictions=__UpperCamelCase     , references=__UpperCamelCase       )


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


'''simple docstring'''







import unittest

from cer import CER


__SCREAMING_SNAKE_CASE		:  List[str]        =      CER()
class  SCREAMING_SNAKE_CASE__       (  unittest.TestCase   ):
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	["""White House"""]
					__a       :     Tuple								=	["""white house"""]
					# S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
					__a       :     Any								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.1_8_1_8_1_8_1_8_1_8			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Optional[int]								=	["""were wolf"""]
					__a       :     Tuple								=	["""werewolf"""]
					# S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
					__a       :     Any								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.1_1_1_1_1_1_1			) < 1E-6			)

					__a       :     str								=	["""werewolf"""]
					__a       :     List[Any]								=	["""weae     wolf"""]
					# S = 1, D = 1, I = 0, N = 8, CER = 0.25
					__a       :     Tuple								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.2_5			) < 1E-6			)

					# consecutive whitespaces case 1
					__a       :     int								=	["""were wolf"""]
					__a       :     Dict								=	["""were               wolf"""]
					# S = 0, D = 0, I = 0, N = 9, CER = 0
					__a       :     str								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.0			) < 1E-6			)

					# consecutive whitespaces case 2
					__a       :     List[str]								=	["""were   wolf"""]
					__a       :     Optional[int]								=	["""were               wolf"""]
					# S = 0, D = 0, I = 0, N = 9, CER = 0
					__a       :     Optional[Any]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.0			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	["""werewolf"""]
					__a       :     str								=	["""weaewolf"""]
					# S = 1, D = 0, I = 0, N = 8, CER = 0.125
					__a       :     Optional[int]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.1_2_5			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[str]								=	["""werewolf"""]
					__a       :     Tuple								=	["""wereawolf"""]
					# S = 0, D = 1, I = 0, N = 8, CER = 0.125
					__a       :     Optional[Any]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.1_2_5			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[str]								=	["""werewolf"""]
					__a       :     Optional[Any]								=	["""wereolf"""]
					# S = 0, D = 0, I = 1, N = 8, CER = 0.125
					__a       :     int								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.1_2_5			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	["""werewolf"""]
					__a       :     Tuple								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertEqual(__UpperCamelCase  ,    0.0			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[str]								=	["""werewolf""", """I am your father"""]
					__a       :     int								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertEqual(__UpperCamelCase  ,    0.0			)

					__a       :     Dict								=	["""werewolf""", """I am your father""", """doge"""]
					__a       :     Optional[Any]								=	["""werxwolf""", """I       am your father""", """doge"""]
					# S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
					__a       :     Union[str, Any]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.0_3_5_7_1_4_2_8			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[str]								=	["""My hovercraft""", """is full of eels"""]
					__a       :     Union[str, Any]								=	["""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
					__a       :     str								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase  ,    concatenate_texts=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.0_7_1_4_2_8			) < 1E-6			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     int								=	["""我能吞下玻璃而不伤身体"""]
					__a       :     Optional[Any]								=	[""" 能吞虾玻璃而 不霜身体啦"""]
					# S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
					__a       :     List[Any]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5			) < 1E-6			)

					__a       :     Union[str, Any]								=	["""我能吞下玻璃""", """而不伤身体"""]
					__a       :     Optional[Any]								=	["""我    能 吞 下 玻 璃""", """而不伤身体"""]
					# S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
					__a       :     List[str]								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5_4_5			) < 1E-6			)

					__a       :     Union[str, Any]								=	["""我能吞下玻璃而不伤身体"""]
					__a       :     Dict								=	cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)
					self.assertFalse(__UpperCamelCase  ,    0.0			)

	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[Any]								=	[""""""]
					__a       :     Dict								=	["""Hypothesis"""]
					with self.assertRaises(__UpperCamelCase			):
									cer.compute(predictions=__UpperCamelCase  ,    references=__UpperCamelCase			)


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