





"""simple docstring"""




import unittest

from cer import CER


UpperCamelCase_	 =CER()




class 					_a		( unittest.TestCase							):






				def 							snake_case      (					self						:       int				)      -> Tuple:




										'''simple docstring'''



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






				def 							snake_case      (					self						:       Any				)      -> str:




										'''simple docstring'''



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

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

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

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






				def 							snake_case      (					self						:       Tuple				)      -> str:




										'''simple docstring'''



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






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




										'''simple docstring'''



										_UpperCamelCase     :   Tuple      =       ['''werewolf''']
										_UpperCamelCase     :   Optional[Any]      =       ['''wereawolf''']
										# S = 0, D = 1, I = 0, N = 8, CER = 0.125
										_UpperCamelCase     :   Any      =       cer.compute(predictions=SCREAMING_SNAKE_CASE_,					references=SCREAMING_SNAKE_CASE_				)
										self.assertTrue(abs(char_error_rate - 0.125				) < 1e-6				)






				def 							snake_case      (					self						:       List[str]				)      -> int:




										'''simple docstring'''



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






				def 							snake_case      (					self						:       Optional[Any]				)      -> List[Any]:




										'''simple docstring'''



										_UpperCamelCase     :   Any      =       ['''werewolf''']
										_UpperCamelCase     :   int      =       cer.compute(predictions=SCREAMING_SNAKE_CASE_,					references=SCREAMING_SNAKE_CASE_				)
										self.assertEqual(SCREAMING_SNAKE_CASE_,					0.0				)






				def 							snake_case      (					self						:       Optional[Any]				)      -> Tuple:




										'''simple docstring'''



										_UpperCamelCase     :   int      =       ['''werewolf''', '''I am your father''']
										_UpperCamelCase     :   Any      =       cer.compute(predictions=SCREAMING_SNAKE_CASE_,					references=SCREAMING_SNAKE_CASE_				)
										self.assertEqual(SCREAMING_SNAKE_CASE_,					0.0				)

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






				def 							snake_case      (					self						:       int				)      -> List[Any]:




										'''simple docstring'''



										_UpperCamelCase     :   Optional[int]      =       ['''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     :   Optional[Any]      =       cer.compute(predictions=SCREAMING_SNAKE_CASE_,					references=SCREAMING_SNAKE_CASE_,					concatenate_texts=SCREAMING_SNAKE_CASE_				)
										self.assertTrue(abs(char_error_rate - 0.071_428				) < 1e-6				)






				def 							snake_case      (					self						:       Optional[int]				)      -> Optional[int]:




										'''simple docstring'''



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

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

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






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




										'''simple docstring'''



										_UpperCamelCase     :   int      =       ['''''']
										_UpperCamelCase     :   Any      =       ['''Hypothesis''']
										with self.assertRaises(SCREAMING_SNAKE_CASE_				):
																cer.compute(predictions=SCREAMING_SNAKE_CASE_,					references=SCREAMING_SNAKE_CASE_				)


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









"""simple docstring"""





_lowercase						   =     (1, 1_53, 3_70, 3_71, 16_34, 24_67_80_51, 1_15_13_22_19_01_87_63_99_25_65_09_55_97_97_39_71_52_24_01)
_lowercase						   =     (-1_53, -1, 0, 1.2, 2_00, "A", [], {}, None)

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if not isinstance(lowerCamelCase   ,      lowerCamelCase		) or n < 1:
												return False

						# Initialization of sum and number of digits.
						snake_case__							:       Optional[Any]				      =       0
						snake_case__							:       Union[str, Any]				      =       0
						snake_case__							:       List[str]				      =       n
						# Calculation of digits of the number
						while temp > 0:
												number_of_digits += 1
												temp //= 10
						# Dividing number into separate digits and find Armstrong number
						snake_case__							:       Optional[int]				      =       n
						while temp > 0:
												snake_case__							:       Optional[int]				      =       temp % 10
												total += rem**number_of_digits
												temp //= 10
						return n == total

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if not isinstance(lowerCamelCase   ,      lowerCamelCase		) or n < 1:
												return False

						# Init a "histogram" of the digits
						snake_case__							:       Union[str, Any]				      =       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
						snake_case__							:       int				      =       0
						snake_case__							:       int				      =       0
						snake_case__							:       Dict				      =       n
						while temp > 0:
												snake_case__      ,						snake_case__							:       Optional[int]				      =       divmod(lowerCamelCase   ,      10		)
												digit_histogram[rem] += 1
												digit_total += 1

						for cnt, i in zip(lowerCamelCase   ,      range(len(lowerCamelCase		)		)		):
												total += cnt * i**digit_total

						return n == total

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if not isinstance(lowerCamelCase   ,      lowerCamelCase		) or n < 1:
												return False
						snake_case__							:       Union[str, Any]				      =       len(str(lowerCamelCase		)		)  # the power that all digits will be raised to
						# check if sum of each digit multiplied expo times is equal to number
						return n == sum(int(lowerCamelCase		) ** expo for i in str(lowerCamelCase		)		)

def 		lowerCAmelCase				(			):
						'''simple docstring'''


						snake_case__							:       Dict				      =       int(input('''Enter an integer to see if it is an Armstrong number: '''		).strip()		)
						print(f'''{num} is {'' if armstrong_number(lowerCamelCase		) else 'not '}an Armstrong number.'''		)
						print(f'''{num} is {'' if narcissistic_number(lowerCamelCase		) else 'not '}an Armstrong number.'''		)
						print(f'''{num} is {'' if pluperfect_number(lowerCamelCase		) else 'not '}an Armstrong number.'''		)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()


