'''simple docstring'''




import unittest

from cer import CER


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

class      lowerCamelCase_     (unittest.TestCase   ):
      '''simple docstring'''

      def 					_A     (	self						:    List[Any]	):
             _UpperCAmelCase					:  Optional[Any]											=   ["White House"]
             _UpperCAmelCase					:  Tuple											=   ["white house"]
             # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
             _UpperCAmelCase					:  List[str]											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.1_818_181_818	) < 1E-6	)




      def 					_A     (	self						:    int	):
             _UpperCAmelCase					:  int											=   ["were wolf"]
             _UpperCAmelCase					:  List[Any]											=   ["werewolf"]
             # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
             _UpperCAmelCase					:  Optional[int]											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.1_111_111	) < 1E-6	)

             _UpperCAmelCase					:  int											=   ["werewolf"]
             _UpperCAmelCase					:  int											=   ["weae     wolf"]
             # S = 1, D = 1, I = 0, N = 8, CER = 0.25
             _UpperCAmelCase					:  Optional[Any]											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.25	) < 1E-6	)

             # consecutive whitespaces case 1
             _UpperCAmelCase					:  Any											=   ["were wolf"]
             _UpperCAmelCase					:  str											=   ["were               wolf"]
             # S = 0, D = 0, I = 0, N = 9, CER = 0
             _UpperCAmelCase					:  Dict											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.0	) < 1E-6	)

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




      def 					_A     (	self						:    str	):
             _UpperCAmelCase					:  str											=   ["werewolf"]
             _UpperCAmelCase					:  Tuple											=   ["weaewolf"]
             # S = 1, D = 0, I = 0, N = 8, CER = 0.125
             _UpperCAmelCase					:  int											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.125	) < 1E-6	)




      def 					_A     (	self						:    Any	):
             _UpperCAmelCase					:  Optional[int]											=   ["werewolf"]
             _UpperCAmelCase					:  Dict											=   ["wereawolf"]
             # S = 0, D = 1, I = 0, N = 8, CER = 0.125
             _UpperCAmelCase					:  Dict											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.125	) < 1E-6	)




      def 					_A     (	self						:    int	):
             _UpperCAmelCase					:  int											=   ["werewolf"]
             _UpperCAmelCase					:  List[Any]											=   ["wereolf"]
             # S = 0, D = 0, I = 1, N = 8, CER = 0.125
             _UpperCAmelCase					:  int											=   cer.compute(predictions=A						, references=A	)
             self.assertTrue(abs(char_error_rate - 0.125	) < 1E-6	)




      def 					_A     (	self						:    Tuple	):
             _UpperCAmelCase					:  Dict											=   ["werewolf"]
             _UpperCAmelCase					:  Optional[int]											=   cer.compute(predictions=A						, references=A	)
             self.assertEqual(A						, 0.0	)




      def 					_A     (	self						:    Tuple	):
             _UpperCAmelCase					:  Optional[int]											=   ["werewolf", "I am your father"]
             _UpperCAmelCase					:  Any											=   cer.compute(predictions=A						, references=A	)
             self.assertEqual(A						, 0.0	)

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




      def 					_A     (	self						:    Any	):
             _UpperCAmelCase					:  Dict											=   ["My hovercraft", "is full of eels"]
             _UpperCAmelCase					:  List[str]											=   ["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
             _UpperCAmelCase					:  str											=   cer.compute(predictions=A						, references=A						, concatenate_texts=A	)
             self.assertTrue(abs(char_error_rate - 0.071_428	) < 1E-6	)




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

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

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





      def 					_A     (	self						:    List[str]	):
             _UpperCAmelCase					:  str											=   [""]
             _UpperCAmelCase					:  int											=   ["Hypothesis"]
             with self.assertRaises(A	):
                    cer.compute(predictions=A						, references=A	)


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


'''simple docstring'''




from itertools import compress, repeat
from math import ceil, sqrt

def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   list[int]:


       """simple docstring"""







       if num <= 2:
              return []
       if num == 3:
              return [2]

       # Odd sieve for numbers in range [3, num - 1]
       _UpperCAmelCase					:  Optional[int]											=   bytearray(b"\x01"   ) * ((num >> 1) - 1)

       for i in range(3      ,     int(sqrt(_UpperCAmelCase   )   ) + 1      ,     2   ):
              if sieve[(i >> 1) - 1]:
                     _UpperCAmelCase					:  List[Any]											=   i**2
                     _UpperCAmelCase					:  Optional[int]											=   repeat(
                         0      ,     ceil((num - i_squared) / (i << 1)   )   )

       return [2] + list(compress(range(3      ,     _UpperCAmelCase      ,     2   )      ,     _UpperCAmelCase   )   )


if __name__ == "__main__":
  import doctest

  doctest.testmod()

