

import unittest

from cer import CER


lowerCamelCase_					  =   CER()







class 					__lowerCamelCase							(      unittest.TestCase      ):







      def       lowerCAmelCase_       (	self  )		->			Dict:
        snake_case_					= ["""White House"""]
        snake_case_					= ["""white house"""]
        # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.18_1818_1818  ) < 1e-6  )







      def       lowerCAmelCase_       (	self  )		->			Optional[int]:
        snake_case_					= ["""were wolf"""]
        snake_case_					= ["""werewolf"""]
        # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.111_1111  ) < 1e-6  )

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

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

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







      def       lowerCAmelCase_       (	self  )		->			Optional[Any]:
        snake_case_					= ["""werewolf"""]
        snake_case_					= ["""weaewolf"""]
        # S = 1, D = 0, I = 0, N = 8, CER = 0.125
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.125  ) < 1e-6  )







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







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







      def       lowerCAmelCase_       (	self  )		->			Dict:
        snake_case_					= ["""werewolf"""]
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertEqual(lowerCamelCase				,    0.0  )







      def       lowerCAmelCase_       (	self  )		->			Optional[Any]:
        snake_case_					= ["""werewolf""", """I am your father"""]
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertEqual(lowerCamelCase				,    0.0  )

        snake_case_					= ["""werewolf""", """I am your father""", """doge"""]
        snake_case_					= ["""werxwolf""", """I       am your father""", """doge"""]
        # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.0357_1428  ) < 1e-6  )







      def       lowerCAmelCase_       (	self  )		->			List[Any]:
        snake_case_					= ["""My hovercraft""", """is full of eels"""]
        snake_case_					= ["""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_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase				,    concatenate_texts=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.07_1428  ) < 1e-6  )







      def       lowerCAmelCase_       (	self  )		->			Optional[int]:
        snake_case_					= ["""我能吞下玻璃而不伤身体"""]
        snake_case_					= [""" 能吞虾玻璃而 不霜身体啦"""]
        # S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
        snake_case_					= cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )
        self.assertTrue(abs(char_error_rate - 0.45_4545_4545  ) < 1e-6  )

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

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







      def       lowerCAmelCase_       (	self  )		->			str:
        snake_case_					= [""""""]
        snake_case_					= ["""Hypothesis"""]
        with self.assertRaises(lowerCamelCase  ):
          cer.compute(predictions=lowerCamelCase				,    references=lowerCamelCase  )


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


def   UpperCamelCase(   lowercase_				)      ->							str:





  '''simple docstring'''





  return "".join(chr(ord(lowercase_				) + 32				) if """A""" <= char <= """Z""" else char for char in word				)


if __name__ == "__main__":
    from doctest import testmod

    testmod()