




'''simple docstring'''





import unittest

from cer import CER


a		:  int   			=			CER()




class     UpperCamelCase					(  unittest.TestCase					):



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       Union[str, Any]       					=			["""White House"""]
      _a							:       Union[str, Any]       					=			["""white house"""]
      # S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
      _a							:       Optional[Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.1818181818   ) < 1e-6   )



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       List[str]       					=			["""were wolf"""]
      _a							:       Tuple       					=			["""werewolf"""]
      # S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
      _a							:       Union[str, Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.1111111   ) < 1e-6   )

      _a							:       str       					=			["""werewolf"""]
      _a							:       Optional[Any]       					=			["""weae     wolf"""]
      # S = 1, D = 1, I = 0, N = 8, CER = 0.25
      _a							:       Tuple       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.25   ) < 1e-6   )

      # consecutive whitespaces case 1
      _a							:       Tuple       					=			["""were wolf"""]
      _a							:       Dict       					=			["""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							:       Union[str, Any]       					=			["""were               wolf"""]
      # S = 0, D = 0, I = 0, N = 9, CER = 0
      _a							:       Union[str, Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.0   ) < 1e-6   )



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       str       					=			["""werewolf"""]
      _a							:       Union[str, Any]       					=			["""weaewolf"""]
      # S = 1, D = 0, I = 0, 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 						a_       ( self   ):







      '''simple docstring'''


      _a							:       Union[str, Any]       					=			["""werewolf"""]
      _a							:       Dict       					=			["""wereawolf"""]
      # S = 0, D = 1, I = 0, N = 8, CER = 0.125
      _a							:       List[Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.125   ) < 1e-6   )



  def 						a_       ( self   ):







      '''simple docstring'''


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



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       List[Any]       					=			["""werewolf"""]
      _a							:       Union[str, Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertEqual(__lowerCAmelCase		,    0.0   )



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       Tuple       					=			["""werewolf""", """I am your father"""]
      _a							:       Optional[int]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertEqual(__lowerCAmelCase		,    0.0   )

      _a							:       str       					=			["""werewolf""", """I am your father""", """doge"""]
      _a							:       Tuple       					=			["""werxwolf""", """I       am your father""", """doge"""]
      # S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
      _a							:       int       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.03571428   ) < 1e-6   )



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       List[Any]       					=			["""My hovercraft""", """is full of eels"""]
      _a							:       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
      _a							:       Union[str, Any]       					=			cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase		,    concatenate_texts=__lowerCAmelCase   )
      self.assertTrue(abs(char_error_rate - 0.071428   ) < 1e-6   )



  def 						a_       ( self   ):







      '''simple docstring'''


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

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

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



  def 						a_       ( self   ):







      '''simple docstring'''


      _a							:       List[str]       					=			[""""""]
      _a							:       Any       					=			["""Hypothesis"""]
      with self.assertRaises(__lowerCAmelCase   ):
          cer.compute(predictions=__lowerCAmelCase		,    references=__lowerCAmelCase   )


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








'''simple docstring'''





from math import exp





def UpperCAmelCase						(					UpperCAmelCase_	):
    return 8 * x - 2 * exp(-x	)





def UpperCAmelCase						(					UpperCAmelCase_      ,  UpperCAmelCase_      ,  UpperCAmelCase_	):
    _a							:       Optional[int]       					=			lower_bound
    _a							:       str       					=			upper_bound
    for _ in range(0      ,  UpperCAmelCase_	):
        _a					,   _a							:       List[str]       					=			xa, xa - (f(UpperCAmelCase_	) * (xa - xa)) / (f(UpperCAmelCase_	) - f(UpperCAmelCase_	))
    return xa


if __name__ == "__main__":
  print(F"""Example: {secant_method(1, 3, 2)}""")


