import unittest

from cer import CER


__lowerCAmelCase    :  Union[str, Any]										= CER()
class 				lowerCamelCase			(							unittest.TestCase					):






      def 			lowerCAmelCase_   (      self						)     ->				List[str]:


          '''simple docstring'''







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






      def 			lowerCAmelCase_   (      self						)     ->				int:


          '''simple docstring'''







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

          snake_case:						Tuple         =   ["""werewolf"""]
          snake_case:						List[str]         =   ["""weae     wolf"""]
          # S = 1, D = 1, I = 0, N = 8, CER = 0.25
          snake_case:						List[Any]         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.25						) < 1e-6						)

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

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






      def 			lowerCAmelCase_   (      self						)     ->				List[str]:


          '''simple docstring'''







          snake_case:						Union[str, Any]         =   ["""werewolf"""]
          snake_case:						Tuple         =   ["""weaewolf"""]
          # S = 1, D = 0, I = 0, N = 8, CER = 0.125
          snake_case:						str         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.125						) < 1e-6						)






      def 			lowerCAmelCase_   (      self						)     ->				List[Any]:


          '''simple docstring'''







          snake_case:						Union[str, Any]         =   ["""werewolf"""]
          snake_case:						List[str]         =   ["""wereawolf"""]
          # S = 0, D = 1, I = 0, N = 8, CER = 0.125
          snake_case:						Optional[int]         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.125						) < 1e-6						)






      def 			lowerCAmelCase_   (      self						)     ->				List[Any]:


          '''simple docstring'''







          snake_case:						Optional[Any]         =   ["""werewolf"""]
          snake_case:						Dict         =   ["""wereolf"""]
          # S = 0, D = 0, I = 1, N = 8, CER = 0.125
          snake_case:						Optional[Any]         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.125						) < 1e-6						)






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


          '''simple docstring'''







          snake_case:						Tuple         =   ["""werewolf"""]
          snake_case:						Dict         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertEqual(__lowerCamelCase  ,		0.0						)






      def 			lowerCAmelCase_   (      self						)     ->				List[str]:


          '''simple docstring'''







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

          snake_case:						int         =   ["""werewolf""", """I am your father""", """doge"""]
          snake_case:						str         =   ["""werxwolf""", """I       am your father""", """doge"""]
          # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
          snake_case:						Optional[Any]         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.03_571_428						) < 1e-6						)






      def 			lowerCAmelCase_   (      self						)     ->				Union[str, Any]:


          '''simple docstring'''







          snake_case:						Tuple         =   ["""My hovercraft""", """is full of eels"""]
          snake_case:						Union[str, Any]         =   ["""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
          snake_case:						Dict         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase  ,		concatenate_texts=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.071_428						) < 1e-6						)






      def 			lowerCAmelCase_   (      self						)     ->				List[str]:


          '''simple docstring'''







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

          snake_case:						str         =   ["""我能吞下玻璃""", """而不伤身体"""]
          snake_case:						Any         =   ["""我    能 吞 下 玻 璃""", """而不伤身体"""]
          # S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
          snake_case:						Optional[int]         =   cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)
          self.assertTrue(abs(char_error_rate - 0.454_545_454_545						) < 1e-6						)

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






      def 			lowerCAmelCase_   (      self						)     ->				str:


          '''simple docstring'''







          snake_case:						Tuple         =   [""""""]
          snake_case:						Optional[Any]         =   ["""Hypothesis"""]
          with self.assertRaises(__lowerCamelCase						):
              cer.compute(predictions=__lowerCamelCase  ,		references=__lowerCamelCase						)


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



def   a_					(_lowerCAmelCase  :   int       )->				str:
    if not isinstance(_lowerCAmelCase			,	_lowerCAmelCase       ):
        snake_case:						Optional[Any]         =   (
            """operation can not be conducted on a object of type """
            F"{type(_lowerCAmelCase       ).__name__}"
        )
        raise TypeError(_lowerCAmelCase       )
    snake_case:						List[Any]         =   """"""
    for _ in range(0			,	32       ):
        bit_string += str(number % 2       )
        snake_case:						Any         =   number >> 1
    return bit_string

def   a_					(_lowerCAmelCase  :   int       )->				str:
    if number < 0:
        raise ValueError("""the value of input must be positive"""       )
    elif isinstance(_lowerCAmelCase			,	_lowerCAmelCase       ):
        raise TypeError("""Input value must be a 'int' type"""       )
    elif isinstance(_lowerCAmelCase			,	_lowerCAmelCase       ):
        raise TypeError("""'<' not supported between instances of 'str' and 'int'"""       )
    snake_case:						Optional[Any]         =   0
    # iterator over [1 to 32],since we are dealing with 32 bit integer
    for _ in range(1			,	33       ):
        # left shift the bits by unity
        snake_case:						Dict         =   result << 1
        # get the end bit
        snake_case:						Union[str, Any]         =   number % 2
        # right shift the bits by unity
        snake_case:						Union[str, Any]         =   number >> 1
        # add that bit to our ans
        snake_case:						Tuple         =   result | end_bit
    return get_reverse_bit_string(_lowerCAmelCase       )


if __name__ == "__main__":
    import doctest

    doctest.testmod()


