


"""simple docstring"""






import unittest

from cer import CER


UpperCamelCase__							:Tuple       =  CER()






class     A(     unittest.TestCase		):

		"""simple docstring"""





		def      _UpperCamelCase(   self      )			->  str:

					"""simple docstring"""



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

					"""simple docstring"""



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

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

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

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

					"""simple docstring"""



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

					"""simple docstring"""



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

					"""simple docstring"""



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

					"""simple docstring"""



					_UpperCamelCase				:Optional[int]				    =  ["werewolf"]
					_UpperCamelCase				:Tuple				    =  cer.compute(predictions=__lowerCamelCase				,							references=__lowerCamelCase      )
					self.assertEqual(__lowerCamelCase				,							0.0      )
		def      _UpperCamelCase(   self      )			->  List[str]:

					"""simple docstring"""



					_UpperCamelCase				:Dict				    =  ["werewolf", "I am your father"]
					_UpperCamelCase				:int				    =  cer.compute(predictions=__lowerCamelCase				,							references=__lowerCamelCase      )
					self.assertEqual(__lowerCamelCase				,							0.0      )

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

					"""simple docstring"""



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

					"""simple docstring"""



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

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

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





		def      _UpperCamelCase(   self      )			->  Tuple:

					"""simple docstring"""



					_UpperCamelCase				:str				    =  [""]
					_UpperCamelCase				:Tuple				    =  ["Hypothesis"]
					with self.assertRaises(__lowerCamelCase      ):
								cer.compute(predictions=__lowerCamelCase				,							references=__lowerCamelCase      )


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





"""simple docstring"""






from __future__ import annotations

from enum import Enum






class     A(     lowerCamelCase__		):

		"""simple docstring"""





		A         =       24
		A         =       21
		A         =       18
		A         =       15
		A         =       12
		A         =       9
		A         =       6
		A         =       3
		A         =       2
		A         =       1
		A         =       -1
		A         =       -2
		A         =       -3
		A         =       -6
		A         =       -9
		A         =       -12
		A         =       -15
		A         =       -18
		A         =       -21
		A         =       -24






class     A(     lowerCamelCase__		):

		"""simple docstring"""





		A         =       8
		A         =       7
		A         =       6
		A         =       5
		A         =       4
		A         =       3
		A         =       2
		A         =       1





def 							A_					(   snake_case__					,				snake_case__					,				snake_case__					,				)				->     float:
			if isinstance(snake_case__					,				snake_case__		):
						_UpperCamelCase				:Tuple				    =  SIUnit[known_prefix.lower()]
			if isinstance(snake_case__					,				snake_case__		):
						_UpperCamelCase				:Optional[int]				    =  SIUnit[unknown_prefix.lower()]
			_UpperCamelCase				:float				    =  known_amount * (
			    10 ** (known_prefix.value - unknown_prefix.value)
			)
			return unknown_amount





def 							A_					(   snake_case__					,				snake_case__					,				snake_case__					,				)				->     float:
			if isinstance(snake_case__					,				snake_case__		):
						_UpperCamelCase				:Any				    =  BinaryUnit[known_prefix.lower()]
			if isinstance(snake_case__					,				snake_case__		):
						_UpperCamelCase				:Dict				    =  BinaryUnit[unknown_prefix.lower()]
			_UpperCamelCase				:float				    =  known_amount * (
			    2 ** ((known_prefix.value - unknown_prefix.value) * 10)
			)
			return unknown_amount


if __name__ == "__main__":
					import doctest

					doctest.testmod()

