


from __future__ import annotations

from collections import deque


class     lowercase__  :






  def __init__(					self      :					List[Any]		,						_lowercase      :					list[str] ):




         """simple docstring"""







         UpperCAmelCase__										=     []
         self.adlist.append(
             {"value": "", "next_states": [], "fail_state": 0, "output": []} )

         for keyword in keywords:
                self.add_keyword(__SCREAMING_SNAKE_CASE )
         self.set_fail_transitions()






  def 			_UpperCAmelCase  (					self      :					Tuple		,						_lowercase      :					int		,						_lowercase      :					str ):




         """simple docstring"""







         for state in self.adlist[current_state]["next_states"]:
                if char == self.adlist[state]["value"]:
                       return state
         return None






  def 			_UpperCAmelCase  (					self      :					List[str]		,						_lowercase      :					str ):




         """simple docstring"""







         UpperCAmelCase__										=     0
         for character in keyword:
                UpperCAmelCase__										=     self.find_next_state(__SCREAMING_SNAKE_CASE		,						__SCREAMING_SNAKE_CASE )
                if next_state is None:
                       self.adlist.append(
                           {
                               "value": character,
                               "next_states": [],
                               "fail_state": 0,
                               "output": [],
                           } )
                       self.adlist[current_state]["next_states"].append(len(self.adlist ) - 1 )
                       UpperCAmelCase__										=     len(self.adlist ) - 1
                else:
                       UpperCAmelCase__										=     next_state
         self.adlist[current_state]["output"].append(__SCREAMING_SNAKE_CASE )






  def 			_UpperCAmelCase  (					self      :					Dict ):




         """simple docstring"""







         UpperCAmelCase__										=     deque()
         for node in self.adlist[0]["next_states"]:
                q.append(__SCREAMING_SNAKE_CASE )
                UpperCAmelCase__										=     0
         while q:
                UpperCAmelCase__										=     q.popleft()
                for child in self.adlist[r]["next_states"]:
                       q.append(__SCREAMING_SNAKE_CASE )
                       UpperCAmelCase__										=     self.adlist[r]["fail_state"]
                       while (
                           self.find_next_state(__SCREAMING_SNAKE_CASE		,						self.adlist[child]["value"] ) is None
                           and state != 0
                       ):
                              UpperCAmelCase__										=     self.adlist[state]["fail_state"]
                       UpperCAmelCase__										=     self.find_next_state(
                           __SCREAMING_SNAKE_CASE		,						self.adlist[child]["value"] )
                       if self.adlist[child]["fail_state"] is None:
                              UpperCAmelCase__										=     0
                       UpperCAmelCase__										=     (
                           self.adlist[child]["output"]
                           + self.adlist[self.adlist[child]["fail_state"]]["output"]
                       )






  def 			_UpperCAmelCase  (					self      :					Optional[Any]		,						_lowercase      :					str ):




         """simple docstring"""







         UpperCAmelCase__										=     {}  # returns a dict with keywords and list of its occurrences
         UpperCAmelCase__										=     0
         for i in range(len(__SCREAMING_SNAKE_CASE ) ):
                while (
                    self.find_next_state(__SCREAMING_SNAKE_CASE		,						string[i] ) is None
                    and current_state != 0
                ):
                       UpperCAmelCase__										=     self.adlist[current_state]["fail_state"]
                UpperCAmelCase__										=     self.find_next_state(__SCREAMING_SNAKE_CASE		,						string[i] )
                if next_state is None:
                       UpperCAmelCase__										=     0
                else:
                       UpperCAmelCase__										=     next_state
                       for key in self.adlist[current_state]["output"]:
                              if key not in result:
                                     UpperCAmelCase__										=     []
                              result[key].append(i - len(__SCREAMING_SNAKE_CASE ) + 1 )
         return result


if __name__ == "__main__":
    import doctest

    doctest.testmod()









from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

A      = 6378137.0
A      = 6356752.314245
A      = 637_8137





def __UpperCAmelCase       (		__A ,						__A ,						__A ,						__A			)						->					float:



       '''simple docstring'''





       UpperCAmelCase__										=     (AXIS_A - AXIS_B) / AXIS_A
       # Parametric latitudes
       # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
       UpperCAmelCase__										=     atan((1 - flattening) * tan(radians(__A			)			)			)
       UpperCAmelCase__										=     atan((1 - flattening) * tan(radians(__A			)			)			)

       # Compute central angle between two points
       # using haversine theta. sigma =  haversine_distance / equatorial radius
       UpperCAmelCase__										=     haversine_distance(__A ,						__A ,						__A ,						__A			) / EQUATORIAL_RADIUS

       # Intermediate P and Q values
       UpperCAmelCase__										=     (b_lata + b_lata) / 2
       UpperCAmelCase__										=     (b_lata - b_lata) / 2

       # Intermediate X value
       # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
       UpperCAmelCase__										=     (sin(__A			) ** 2) * (cos(__A			) ** 2)
       UpperCAmelCase__										=     cos(sigma / 2			) ** 2
       UpperCAmelCase__										=     (sigma - sin(__A			)) * (x_numerator / x_demonimator)

       # Intermediate Y value
       # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
       UpperCAmelCase__										=     (cos(__A			) ** 2) * (sin(__A			) ** 2)
       UpperCAmelCase__										=     sin(sigma / 2			) ** 2
       UpperCAmelCase__										=     (sigma + sin(__A			)) * (y_numerator / y_denominator)

       return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
    import doctest

    doctest.testmod()





