






"""simple docstring"""



import unittest

from cer import CER


_UpperCamelCase		:  List[str]						=		CER()

class 	a					(       unittest.TestCase     ):







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['White House']
      lowercase							   =	['white house']
      # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
      lowercase							   =	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	):
      lowercase							   =	['were wolf']
      lowercase							   =	['werewolf']
      # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertTrue(abs(char_error_rate - 0.1_1_1_1_1_1_1	) < 1e-6	)

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

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

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['werewolf']
      lowercase							   =	['weaewolf']
      # S = 1, D = 0, I = 0, N = 8, CER = 0.125
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['werewolf']
      lowercase							   =	['wereawolf']
      # S = 0, D = 1, I = 0, N = 8, CER = 0.125
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['werewolf']
      lowercase							   =	['wereolf']
      # S = 0, D = 0, I = 1, N = 8, CER = 0.125
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['werewolf']
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertEqual(_lowerCamelCase							,		0.0	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['werewolf', 'I am your father']
      lowercase							   =	cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)
      self.assertEqual(_lowerCamelCase							,		0.0	)

      lowercase							   =	['werewolf', 'I am your father', 'doge']
      lowercase							   =	['werxwolf', 'I       am your father', 'doge']
      # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
      lowercase							   =	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	):
      lowercase							   =	['My hovercraft', 'is full of eels']
      lowercase							   =	['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
      lowercase							   =	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	):
      lowercase							   =	['我能吞下玻璃而不伤身体']
      lowercase							   =	[' 能吞虾玻璃而 不霜身体啦']
      # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
      lowercase							   =	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	)

      lowercase							   =	['我能吞下玻璃', '而不伤身体']
      lowercase							   =	['我    能 吞 下 玻 璃', '而不伤身体']
      # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
      lowercase							   =	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	)

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	['']
      lowercase							   =	['Hypothesis']
      with self.assertRaises(_lowerCamelCase	):
        cer.compute(predictions=_lowerCamelCase							,		references=_lowerCamelCase	)


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










"""simple docstring"""



def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  Dict		, __snake_case      :  str   ):





  '''simple docstring'''





  lowercase							   =	1
  while b > 0:
    if b & 1:
      res *= a

    a *= a
    b >>= 1

  return res
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  int		, __snake_case      :  List[str]		, __snake_case      :  str   ):





  '''simple docstring'''





  lowercase							   =	1
  while b > 0:
    if b & 1:
      lowercase							   =	((res % c) * (a % c)) % c

    a *= a
    b >>= 1

  return res


