



'''simple docstring'''

import unittest

from cer import CER


UpperCAmelCase			=    CER()

class __snake_case(      unittest.TestCase					):


						'''simple docstring'''



						def 				__snake_case    (					self      )	->	Dict:
							lowerCAmelCase    =	["""White House"""]
							lowerCAmelCase    =	["""white house"""]
							# S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.1_8_1_8_1_8_1_8_1_8      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	Any:
							lowerCAmelCase    =	["""were wolf"""]
							lowerCAmelCase    =	["""werewolf"""]
							# S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.1_1_1_1_1_1_1      ) < 1e-6      )

							lowerCAmelCase    =	["""werewolf"""]
							lowerCAmelCase    =	["""weae     wolf"""]
							# S = 1, D = 1, I = 0, N = 8, CER = 0.25
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.2_5      ) < 1e-6      )

							# consecutive whitespaces case 1
							lowerCAmelCase    =	["""were wolf"""]
							lowerCAmelCase    =	["""were               wolf"""]
							# S = 0, D = 0, I = 0, N = 9, CER = 0
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.0      ) < 1e-6      )

							# consecutive whitespaces case 2
							lowerCAmelCase    =	["""were   wolf"""]
							lowerCAmelCase    =	["""were               wolf"""]
							# S = 0, D = 0, I = 0, N = 9, CER = 0
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.0      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	str:
							lowerCAmelCase    =	["""werewolf"""]
							lowerCAmelCase    =	["""weaewolf"""]
							# S = 1, D = 0, I = 0, N = 8, CER = 0.125
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.1_2_5      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	Tuple:
							lowerCAmelCase    =	["""werewolf"""]
							lowerCAmelCase    =	["""wereawolf"""]
							# S = 0, D = 1, I = 0, N = 8, CER = 0.125
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.1_2_5      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	Dict:
							lowerCAmelCase    =	["""werewolf"""]
							lowerCAmelCase    =	["""wereolf"""]
							# S = 0, D = 0, I = 1, N = 8, CER = 0.125
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.1_2_5      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	Union[str, Any]:
							lowerCAmelCase    =	["""werewolf"""]
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertEqual(A_	,       0.0      )


						def 				__snake_case    (					self      )	->	Optional[Any]:
							lowerCAmelCase    =	["""werewolf""", """I am your father"""]
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertEqual(A_	,       0.0      )

							lowerCAmelCase    =	["""werewolf""", """I am your father""", """doge"""]
							lowerCAmelCase    =	["""werxwolf""", """I       am your father""", """doge"""]
							# S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.0_3_5_7_1_4_2_8      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	int:
							lowerCAmelCase    =	["""My hovercraft""", """is full of eels"""]
							lowerCAmelCase    =	["""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    =	cer.compute(predictions=A_	,       references=A_	,       concatenate_texts=A_      )
							self.assertTrue(abs(char_error_rate - 0.0_7_1_4_2_8      ) < 1e-6      )


						def 				__snake_case    (					self      )	->	Dict:
							lowerCAmelCase    =	["""我能吞下玻璃而不伤身体"""]
							lowerCAmelCase    =	[""" 能吞虾玻璃而 不霜身体啦"""]
							# S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5      ) < 1e-6      )

							lowerCAmelCase    =	["""我能吞下玻璃""", """而不伤身体"""]
							lowerCAmelCase    =	["""我    能 吞 下 玻 璃""", """而不伤身体"""]
							# S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5_4_5      ) < 1e-6      )

							lowerCAmelCase    =	["""我能吞下玻璃而不伤身体"""]
							lowerCAmelCase    =	cer.compute(predictions=A_	,       references=A_      )
							self.assertFalse(A_	,       0.0      )




						def 				__snake_case    (					self      )	->	Union[str, Any]:
							lowerCAmelCase    =	[""""""]
							lowerCAmelCase    =	["""Hypothesis"""]
							with self.assertRaises(A_      ):
								cer.compute(predictions=A_	,       references=A_      )


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




'''simple docstring'''

from __future__ import annotations






def 		_snake_case		(					_SCREAMING_SNAKE_CASE     :						list[int]							,		_SCREAMING_SNAKE_CASE     :						int							)			->						list[int]:







	"""simple docstring"""
	lowerCAmelCase    =	{}
	for index, val in enumerate(_SCREAMING_SNAKE_CASE							):
		lowerCAmelCase    =	target - val
		if compl in chk_map:
			return [chk_map[compl], index]
		lowerCAmelCase    =	index
	return []


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				print(F'''{two_sum([2, 7, 11, 15], 9) = }''')