



"""simple docstring"""


import unittest

from cer import CER


snake_case_         = CER()







class    A_    (  unittest.TestCase       ):



						"""simple docstring"""






						def 			UpperCAmelCase__  (      self				:Optional[Any]      )       ->    str:
												UpperCAmelCase    =				['White House']
												UpperCAmelCase    =				['white house']
												# S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.18_1818_1818      ) < 1E-6      )






						def 			UpperCAmelCase__  (      self				:str      )       ->    Dict:
												UpperCAmelCase    =				['were wolf']
												UpperCAmelCase    =				['werewolf']
												# S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.111_1111      ) < 1E-6      )

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

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

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






						def 			UpperCAmelCase__  (      self				:List[str]      )       ->    Any:
												UpperCAmelCase    =				['werewolf']
												UpperCAmelCase    =				['weaewolf']
												# S = 1, D = 0, I = 0, N = 8, CER = 0.125
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.125      ) < 1E-6      )






						def 			UpperCAmelCase__  (      self				:List[str]      )       ->    List[str]:
												UpperCAmelCase    =				['werewolf']
												UpperCAmelCase    =				['wereawolf']
												# S = 0, D = 1, I = 0, N = 8, CER = 0.125
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.125      ) < 1E-6      )






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






						def 			UpperCAmelCase__  (      self				:str      )       ->    List[Any]:
												UpperCAmelCase    =				['werewolf']
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertEqual(lowercase_     ,						0.0      )






						def 			UpperCAmelCase__  (      self				:Union[str, Any]      )       ->    str:
												UpperCAmelCase    =				['werewolf', 'I am your father']
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertEqual(lowercase_     ,						0.0      )

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






						def 			UpperCAmelCase__  (      self				:Dict      )       ->    Tuple:
												UpperCAmelCase    =				['My hovercraft', 'is full of eels']
												UpperCAmelCase    =				['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
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_     ,						concatenate_texts=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.07_1428      ) < 1E-6      )






						def 			UpperCAmelCase__  (      self				:Union[str, Any]      )       ->    List[str]:
												UpperCAmelCase    =				['我能吞下玻璃而不伤身体']
												UpperCAmelCase    =				[' 能吞虾玻璃而 不霜身体啦']
												# S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
												UpperCAmelCase    =				cer.compute(predictions=lowercase_     ,						references=lowercase_      )
												self.assertTrue(abs(char_error_rate - 0.45_4545_4545      ) < 1E-6      )

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

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






						def 			UpperCAmelCase__  (      self				:Any      )       ->    List[str]:
												UpperCAmelCase    =				['']
												UpperCAmelCase    =				['Hypothesis']
												with self.assertRaises(lowercase_      ):
																		cer.compute(predictions=lowercase_     ,						references=lowercase_      )


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










"""simple docstring"""


from math import exp

def 				_lowerCAmelCase   (     lowercase_		):
						return 8 * x - 2 * exp(-x		)

def 				_lowerCAmelCase   (     lowercase_	,			lowercase_	,			lowercase_		):
						UpperCAmelCase    =				lower_bound
						UpperCAmelCase    =				upper_bound
						for _ in range(0	,			lowercase_		):
												UpperCAmelCase   ,					UpperCAmelCase    =				xa, xa - (f(lowercase_		) * (xa - xa)) / (f(lowercase_		) - f(lowercase_		))
						return xa


if __name__ == "__main__":
				print(f'''Example: {secant_method(1, 3, 2)}''')





