



from __future__ import annotations

from collections import deque

class 					_A :



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


           '''simple docstring'''

           __a		 =       []
           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 	_lowerCamelCase    (	self							:  Tuple  ,	__SCREAMING_SNAKE_CASE							:  int  ,	__SCREAMING_SNAKE_CASE							:  str):


           '''simple docstring'''

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



       def 	_lowerCamelCase    (	self							:  List[str]  ,	__SCREAMING_SNAKE_CASE							:  str):


           '''simple docstring'''

           __a		 =       0
           for character in keyword:
               __a		 =       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)
                   __a		 =       len(self.adlist) - 1
               else:
                   __a		 =       next_state
           self.adlist[current_state]["output"].append(__SCREAMING_SNAKE_CASE)



       def 	_lowerCamelCase    (	self							:  Dict):


           '''simple docstring'''

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





       def 	_lowerCamelCase    (	self							:  Optional[Any]  ,	__SCREAMING_SNAKE_CASE							:  str):


           '''simple docstring'''

           __a		 =       {}  # returns a dict with keywords and list of its occurrences
           __a		 =       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
               ):
                   __a		 =       self.adlist[current_state]['''fail_state''']
               __a		 =       self.find_next_state(__SCREAMING_SNAKE_CASE  ,	string[i])
               if next_state is None:
                   __a		 =       0
               else:
                   __a		 =       next_state
                   for key in self.adlist[current_state]["output"]:
                       if key not in result:
                           __a		 =       []
                       result[key].append(i - len(__SCREAMING_SNAKE_CASE) + 1)
           return result


if __name__ == "__main__":
 import doctest

 doctest.testmod()










def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase = False       ):

    if not isinstance(_UpperCAmelCase     ,				_UpperCAmelCase       ):
        __a		 =       f'Expected string as input, found {type(_UpperCAmelCase       )}'
        raise ValueError(_UpperCAmelCase       )
    if not isinstance(_UpperCAmelCase     ,				_UpperCAmelCase       ):
        __a		 =       f'Expected boolean as use_pascal parameter, found {type(_UpperCAmelCase       )}'
        raise ValueError(_UpperCAmelCase       )

    __a		 =       input_str.split('''_'''       )

    __a		 =       0 if use_pascal else 1

    __a		 =       words[start_index:]

    __a		 =       [word[0].upper() + word[1:] for word in words_to_capitalize]

    __a		 =       '''''' if use_pascal else words[0]

    return "".join([initial_word, *capitalized_words]       )


if __name__ == "__main__":
 from doctest import testmod

 testmod()





