



"""simple docstring"""


def 					_lowerCAmelCase (  lowercase_						,      lowercase_		):
						UpperCAmelCase			 =					[]
						UpperCAmelCase			 =					len(lowercase_		)
						for i in range(lowercase_		):
												UpperCAmelCase			 =					[]
												for j in range(lowercase_		):
																		UpperCAmelCase			 =					0
																		for k in range(lowercase_		):
																								UpperCAmelCase			 =					val + matrix_a[i][k] * matrix_b[k][j]
																		list_a.append(lowercase_		)
												matrix_c.append(lowercase_		)
						return matrix_c

def 					_lowerCAmelCase (  lowercase_		):
						return [[int(row == column		) for column in range(lowercase_		)] for row in range(lowercase_		)]

def 					_lowerCAmelCase (  lowercase_		):
						if n <= 1:
												return n
						UpperCAmelCase			 =					identity(2		)
						UpperCAmelCase			 =					[[1, 1], [1, 0]]
						UpperCAmelCase			 =					n - 1
						while n > 0:
												if n % 2 == 1:
																		UpperCAmelCase			 =					multiply(lowercase_						,      lowercase_		)
												UpperCAmelCase			 =					multiply(lowercase_						,      lowercase_		)
												UpperCAmelCase			 =					int(n / 2		)
						return res_matrix[0][0]

def 					_lowerCAmelCase (  lowercase_		):
						if n <= 1:
												return n
						UpperCAmelCase			 =					0
						UpperCAmelCase			 =					1
						for _ in range(2						,      n + 1		):
												UpperCAmelCase ,       UpperCAmelCase			 =					fiba, fiba + fiba
						return fiba

def 					_lowerCAmelCase (  ):
						for ordinal in "0th 1st 2nd 3rd 10th 100th 1000th".split():
												UpperCAmelCase			 =					int(''.join(c for c in ordinal if c in '0123456789'		)		)  # 1000th --> 1000
												print(
												    F"""{ordinal} fibonacci number using matrix exponentiation is """
												    F"""{nth_fibonacci_matrix(lowercase_		)} and using bruteforce is """
												    F"""{nth_fibonacci_bruteforce(lowercase_		)}\n"""		)
						# from timeit import timeit
						# print(timeit("nth_fibonacci_matrix(1000000)",
						#              "from main import nth_fibonacci_matrix", number=5))
						# print(timeit("nth_fibonacci_bruteforce(1000000)",
						#              "from main import nth_fibonacci_bruteforce", number=5))
						# 2.3342058970001744
						# 57.256506615000035


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				main()













"""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()

