


import unittest

from cer import CER


_snake_case   = CER()




class    A_   ( unittest.TestCase     ):







 """simple docstring"""





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

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

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

      # consecutive whitespaces case 2
      UpperCAmelCase						:				str		  =			["were   wolf"]
      UpperCAmelCase						:				Any		  =			["were               wolf"]
      # S = 0, D = 0, I = 0, N = 9, CER = 0
      UpperCAmelCase						:				Optional[int]		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.0				) < 1E-6				)
 def   _UpperCamelCase    (			self					: int				)    ->			List[str]:
      UpperCAmelCase						:				Optional[int]		  =			["werewolf"]
      UpperCAmelCase						:				int		  =			["weaewolf"]
      # S = 1, D = 0, I = 0, N = 8, CER = 0.125
      UpperCAmelCase						:				int		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.1_2_5				) < 1E-6				)
 def   _UpperCamelCase    (			self					: Dict				)    ->			Optional[int]:
      UpperCAmelCase						:				List[str]		  =			["werewolf"]
      UpperCAmelCase						:				List[Any]		  =			["wereawolf"]
      # S = 0, D = 1, I = 0, N = 8, CER = 0.125
      UpperCAmelCase						:				List[str]		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.1_2_5				) < 1E-6				)
 def   _UpperCamelCase    (			self					: Any				)    ->			int:
      UpperCAmelCase						:				Optional[int]		  =			["werewolf"]
      UpperCAmelCase						:				Optional[int]		  =			["wereolf"]
      # S = 0, D = 0, I = 1, N = 8, CER = 0.125
      UpperCAmelCase						:				int		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.1_2_5				) < 1E-6				)
 def   _UpperCamelCase    (			self					: str				)    ->			Optional[Any]:
      UpperCAmelCase						:				Tuple		  =			["werewolf"]
      UpperCAmelCase						:				str		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertEqual(_a       ,    0.0				)
 def   _UpperCamelCase    (			self					: Tuple				)    ->			Optional[Any]:
      UpperCAmelCase						:				str		  =			["werewolf", "I am your father"]
      UpperCAmelCase						:				List[str]		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertEqual(_a       ,    0.0				)

      UpperCAmelCase						:				Optional[int]		  =			["werewolf", "I am your father", "doge"]
      UpperCAmelCase						:				Union[str, Any]		  =			["werxwolf", "I       am your father", "doge"]
      # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
      UpperCAmelCase						:				List[str]		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.0_3_5_7_1_4_2_8				) < 1E-6				)
 def   _UpperCamelCase    (			self					: Optional[Any]				)    ->			int:
      UpperCAmelCase						:				int		  =			["My hovercraft", "is full of eels"]
      UpperCAmelCase						:				Optional[int]		  =			["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						:				Optional[Any]		  =			cer.compute(predictions=_a       ,    references=_a       ,    concatenate_texts=_a				)
      self.assertTrue(abs(char_error_rate - 0.0_7_1_4_2_8				) < 1E-6				)
 def   _UpperCamelCase    (			self					: List[str]				)    ->			List[Any]:
      UpperCAmelCase						:				Dict		  =			["我能吞下玻璃而不伤身体"]
      UpperCAmelCase						:				List[Any]		  =			[" 能吞虾玻璃而 不霜身体啦"]
      # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
      UpperCAmelCase						:				Union[str, Any]		  =			cer.compute(predictions=_a       ,    references=_a				)
      self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5				) < 1E-6				)

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

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

 def   _UpperCamelCase    (			self					: Union[str, Any]				)    ->			Optional[Any]:
      UpperCAmelCase						:				Tuple		  =			[""]
      UpperCAmelCase						:				Tuple		  =			["Hypothesis"]
      with self.assertRaises(_a				):
           cer.compute(predictions=_a       ,    references=_a				)


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







import math







def   A   (		A__ ):
     UpperCAmelCase						:				List[str]		  =			math.log(2		,		1_0 ) * number
     UpperCAmelCase						:				int		  =			round((log_number - int(A__ ))		,		1_5 )

     return difference







def   A   (		A__ = 6_7_8_9_1_0 ):
     UpperCAmelCase						:				str		  =			9_0
     UpperCAmelCase						:				Any		  =			0

     UpperCAmelCase						:				Dict		  =			math.log(1.23		,		1_0 )
     UpperCAmelCase						:				Optional[Any]		  =			math.log(1.24		,		1_0 )
     UpperCAmelCase						:				Tuple		  =			0

     while position < number:
          UpperCAmelCase						:				Tuple		  =			log_difference(A__ )

          if difference >= upper_limit:
               power_iterator += 9_3

          elif difference < lower_limit:
               power_iterator += 1_9_6

          else:
               UpperCAmelCase						:				Any		  =			power_iterator
               power_iterator += 1_9_6
               position += 1

     return previous_power


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      print(f'''{solution() = }''')



