






"""simple docstring"""
def 			lowerCamelCase_    (		_lowerCamelCase							):
 if not isinstance(_lowerCamelCase     ,  _lowerCamelCase							):
  raise ValueError('double_factorial() only accepts integral values'							)
 if num < 0:
  raise ValueError('double_factorial() not defined for negative values'							)
 lowerCamelCase__	:     Union[str, Any]								=		1
 for i in range(_lowerCamelCase     ,  0     ,  -2							):
  value *= i
 return value


if __name__ == "__main__":
      import doctest

      doctest.testmod()









"""simple docstring"""
import unittest

from cer import CER


A_     :					Union[str, Any]							=     CER()



class 						a_ (      unittest.TestCase					):







      '''simple docstring'''

      def      a__				(self   ):

       '''simple docstring'''



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




      def      a__				(self   ):

       '''simple docstring'''



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

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

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

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




      def      a__				(self   ):

       '''simple docstring'''



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




      def      a__				(self   ):

       '''simple docstring'''



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




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     List[Any]								=		['werewolf']
       lowerCamelCase__	:     Dict								=		['wereolf']
       # S = 0, D = 0, I = 1, N = 8, CER = 0.125
       lowerCamelCase__	:     int								=		cer.compute(predictions=lowerCamelCase_,	references=lowerCamelCase_   )
       self.assertTrue(abs(char_error_rate - 0.125   ) < 1e-6   )




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Optional[int]								=		['werewolf']
       lowerCamelCase__	:     Tuple								=		cer.compute(predictions=lowerCamelCase_,	references=lowerCamelCase_   )
       self.assertEqual(lowerCamelCase_,	0.0   )




      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     List[str]								=		['werewolf', 'I am your father']
       lowerCamelCase__	:     List[Any]								=		cer.compute(predictions=lowerCamelCase_,	references=lowerCamelCase_   )
       self.assertEqual(lowerCamelCase_,	0.0   )

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




      def      a__				(self   ):

       '''simple docstring'''



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




      def      a__				(self   ):

       '''simple docstring'''



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

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

       lowerCamelCase__	:     Optional[int]								=		['我能吞下玻璃而不伤身体']
       lowerCamelCase__	:     Union[str, Any]								=		cer.compute(predictions=lowerCamelCase_,	references=lowerCamelCase_   )
       self.assertFalse(lowerCamelCase_,	0.0   )





      def      a__				(self   ):

       '''simple docstring'''



       lowerCamelCase__	:     Optional[int]								=		['']
       lowerCamelCase__	:     Optional[int]								=		['Hypothesis']
       with self.assertRaises(lowerCamelCase_   ):
        cer.compute(predictions=lowerCamelCase_,	references=lowerCamelCase_   )


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

