



import unittest

from cer import CER


__lowerCamelCase  				=					CER()



class 		_snake_case      (			unittest.TestCase				):





  """simple docstring"""



  def lowercase_		(						self					)	->							Optional[Any]:




    """simple docstring"""







    _A           =    ['''White House''']
    _A           =    ['''white house''']
    # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.1_818_181_818					) < 1e-6					)
  def lowercase_		(						self					)	->							int:




    """simple docstring"""







    _A           =    ['''were wolf''']
    _A           =    ['''werewolf''']
    # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.1_111_111					) < 1e-6					)

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

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

    # consecutive whitespaces case 2
    _A           =    ['''were   wolf''']
    _A           =    ['''were               wolf''']
    # S = 0, D = 0, I = 0, N = 9, CER = 0
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.0					) < 1e-6					)
  def lowercase_		(						self					)	->							List[Any]:




    """simple docstring"""







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




    """simple docstring"""







    _A           =    ['''werewolf''']
    _A           =    ['''wereawolf''']
    # S = 0, D = 1, I = 0, N = 8, CER = 0.125
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.125					) < 1e-6					)
  def lowercase_		(						self					)	->							Optional[int]:




    """simple docstring"""







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




    """simple docstring"""







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




    """simple docstring"""







    _A           =    ['''werewolf''', '''I am your father''']
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertEqual(a_	,    0.0					)

    _A           =    ['''werewolf''', '''I am your father''', '''doge''']
    _A           =    ['''werxwolf''', '''I       am your father''', '''doge''']
    # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.03_571_428					) < 1e-6					)
  def lowercase_		(						self					)	->							List[Any]:




    """simple docstring"""







    _A           =    ['''My hovercraft''', '''is full of eels''']
    _A           =    ['''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           =    cer.compute(predictions=a_	,    references=a_	,    concatenate_texts=a_					)
    self.assertTrue(abs(char_error_rate - 0.071_428					) < 1e-6					)
  def lowercase_		(						self					)	->							Optional[int]:




    """simple docstring"""







    _A           =    ['''我能吞下玻璃而不伤身体''']
    _A           =    [''' 能吞虾玻璃而 不霜身体啦''']
    # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
    _A           =    cer.compute(predictions=a_	,    references=a_					)
    self.assertTrue(abs(char_error_rate - 0.4_545_454_545					) < 1e-6					)

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

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



  def lowercase_		(						self					)	->							Dict:




    """simple docstring"""







    _A           =    ['''''']
    _A           =    ['''Hypothesis''']
    with self.assertRaises(a_					):
      cer.compute(predictions=a_	,    references=a_					)


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




def     UpperCAmelCase__ (							__snake_case						,				__snake_case						,				__snake_case						,				__snake_case						,				__snake_case							)   -> None:
  if target == 0:
    answer.append(path.copy()							)
  else:
    for index in range(__snake_case						,				len(__snake_case							)							):
      if target >= candidates[index]:
        path.append(candidates[index]							)
        backtrack(__snake_case						,				__snake_case						,				__snake_case						,				target - candidates[index]						,				__snake_case							)
        path.pop(len(__snake_case							) - 1							)




def     UpperCAmelCase__ (							__snake_case						,				__snake_case							)   -> list:
  _A           =    []  # type: list[int]
  _A           =    []  # type: list[int]
  backtrack(__snake_case						,				__snake_case						,				__snake_case						,				__snake_case						,				0							)
  return answer




def     UpperCAmelCase__ (							)   -> None:
  print(combination_sum([-8, 2.3, 0]						,				1							)							)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()