


'''simple docstring'''


import unittest

from cer import CER


_UpperCamelCase          =     CER()







class        __magic_name__  (					unittest.TestCase   ):

     """simple docstring"""






     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Union[str, Any]						     =       ["White House"]
          __A  :					int						     =       ["white house"]
          # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
          __A  :					Optional[int]						     =       cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)
          self.assertTrue(abs(char_error_rate - 0.18_1818_1818		) < 1E-6		)


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Union[str, Any]						     =       ["were wolf"]
          __A  :					Optional[Any]						     =       ["werewolf"]
          # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
          __A  :					Optional[Any]						     =       cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)
          self.assertTrue(abs(char_error_rate - 0.111_1111		) < 1E-6		)

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

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

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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Any						     =       ["werewolf"]
          __A  :					str						     =       ["wereolf"]
          # S = 0, D = 0, I = 1, N = 8, CER = 0.125
          __A  :					Union[str, Any]						     =       cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)
          self.assertTrue(abs(char_error_rate - 0.125		) < 1E-6		)


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Optional[int]						     =       ["werewolf"]
          __A  :					Tuple						     =       cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)
          self.assertEqual(lowerCamelCase ,    0.0		)


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Any						     =       ["werewolf", "I am your father"]
          __A  :					Dict						     =       cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)
          self.assertEqual(lowerCamelCase ,    0.0		)

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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





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

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

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


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Tuple						     =       [""]
          __A  :					Union[str, Any]						     =       ["Hypothesis"]
          with self.assertRaises(lowerCamelCase		):
               cer.compute(predictions=lowerCamelCase ,    references=lowerCamelCase		)


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





'''simple docstring'''


import math
from collections.abc import Generator


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)       ))
     for i in (n for n in numbers if n > 1):
          for j in range(2					,				SCREAMING_SNAKE_CASE       ):
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)       ))
     for i in (n for n in numbers if n > 1):
          # only need to check for factors up to sqrt(i)
          __A  :					Optional[Any]						     =       int(math.sqrt(SCREAMING_SNAKE_CASE       )       ) + 1
          for j in range(2					,				SCREAMING_SNAKE_CASE       ):
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)					,				2       ))
     # It's useless to test even numbers as they will not be prime
     if max_n > 2:
          yield 2  # Because 2 will not be tested, it's necessary to yield it now
     for i in (n for n in numbers if n > 1):
          __A  :					List[str]						     =       int(math.sqrt(SCREAMING_SNAKE_CASE       )       ) + 1
          for j in range(3					,				SCREAMING_SNAKE_CASE					,				2       ):
               # As we removed the even numbers, we don't need them now
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   ():




     '''simple docstring'''





     from timeit import timeit

     __A  :					List[str]						     =       "from __main__ import slow_primes, primes, fast_primes"
     print(timeit("slow_primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )
     print(timeit("primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )
     print(timeit("fast_primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )


if __name__ == "__main__":
      _UpperCamelCase          =     int(input("""Calculate primes up to:\n>> """).strip())
      for ret in primes(number):
            print(ret)
      benchmark()

