class_docstr: KeywordProcessor
  
  Attributes:
      _keyword (str): Used as key to store keywords in trie dictionary.
          Defaults to '_keyword_'
      non_word_boundaries (set(str)): Characters that will determine if the word is continuing.
          Defaults to set([A-Za-z0-9_])
      keyword_trie_dict (dict): Trie dict built character by character, that is used for lookup
          Defaults to empty dictionary
      case_sensitive (boolean): if the search algorithm should be case sensitive or not.
          Defaults to False
  
  Examples:
      >>> # import module
      >>> from flashtext import KeywordProcessor
      >>> # Create an object of KeywordProcessor
      >>> keyword_processor = KeywordProcessor()
      >>> # add keywords
      >>> keyword_names = ['NY', 'new-york', 'SF']
      >>> clean_names = ['new york', 'new york', 'san francisco']
      >>> for keyword_name, clean_name in zip(keyword_names, clean_names):
      >>>     keyword_processor.add_keyword(keyword_name, clean_name)
      >>> keywords_found = keyword_processor.extract_keywords('I love SF and NY. new-york is the best.')
      >>> keywords_found
      >>> ['san francisco', 'new york', 'new york']
  
  Note:
      * loosely based on `Aho-Corasick algorithm <https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm>`_.
      * Idea came from this `Stack Overflow Question <https://stackoverflow.com/questions/44178449/regex-replace-is-taking-time-for-millions-of-documents-how-to-make-it-faster>`_.
class_docstr_tok: ["KeywordProcessor","Attributes",":","_keyword","(","str",")",":","Used","as","key","to","store","keywords","in","trie","dictionary",".","Defaults","to","'_keyword_'","non_word_boundaries","(","set","(","str",")",")",":","Characters","that","will","determine","if","the","word","is","continuing",".","Defaults","to","set","(","[","A-Za-z0-9_","]",")","keyword_trie_dict","(","dict",")",":","Trie","dict","built","character","by","character",",","that","is","used","for","lookup","Defaults","to","empty","dictionary","case_sensitive","(","boolean",")",":","if","the","search","algorithm","should","be","case","sensitive","or","not",".","Defaults","to","False","Examples",":",">",">",">","#","import","module",">",">",">","from","flashtext","import","KeywordProcessor",">",">",">","#","Create","an","object","of","KeywordProcessor",">",">",">","keyword_processor","=","KeywordProcessor","(",")",">",">",">","#","add","keywords",">",">",">","keyword_names","=","[","'NY","'",",","'new-york","'",",","'SF","'","]",">",">",">","clean_names","=","[","'new","york","'",",","'new","york","'",",","'san","francisco","'","]",">",">",">","for","keyword_name",",","clean_name","in","zip","(","keyword_names",",","clean_names",")",":",">",">",">","keyword_processor.add_keyword","(","keyword_name",",","clean_name",")",">",">",">","keywords_found","=","keyword_processor.extract_keywords","(","'","I","love","SF","and","NY",".","new-york","is","the","best",".","'",")",">",">",">","keywords_found",">",">",">","[","'san","francisco","'",",","'new","york","'",",","'new","york","'","]","Note",":","*","loosely","based","on","`","Aho-Corasick","algorithm","<","https",":","\/\/en.wikipedia.org\/wiki\/Aho","%","E2","%","80","%","93Corasick_algorithm",">","`","_",".","*","Idea","came","from","this","`","Stack","Overflow","Question","<","https",":","\/\/stackoverflow.com\/questions\/44178449\/regex-replace-is-taking-time-for-millions-of-documents-how-to-make-it-faster",">","`","_","."]
docstr: Retrieve the nodes where there is a fuzzy match,
  via levenshtein distance, and with respect to max_cost
  
  Args:
      word (str): word to find a fuzzy match for
      max_cost (int): maximum levenshtein distance when performing the fuzzy match
      start_node (dict): Trie node from which the search is performed
  
  Yields:
      node, cost, depth (tuple): A tuple containing the final node,
                                the cost (i.e the distance), and the depth in the trie
  
  Examples:
      >>> from flashtext import KeywordProcessor
      >>> keyword_processor = KeywordProcessor(case_sensitive=True)
      >>> keyword_processor.add_keyword('Marie', 'Mary')
      >>> next(keyword_processor.levensthein('Maria', max_cost=1))
      >>> ({'_keyword_': 'Mary'}, 1, 5)
      ...
      >>> keyword_processor = KeywordProcessor(case_sensitive=True
      >>> keyword_processor.add_keyword('Marie Blanc', 'Mary')
      >>> next(keyword_processor.levensthein('Mari', max_cost=1))
      >>> ({' ': {'B': {'l': {'a': {'n': {'c': {'_keyword_': 'Mary'}}}}}}}, 1, 5)
docstr_tok: ["Retrieve","the","nodes","where","there","is","a","fuzzy","match",",","via","levenshtein","distance",",","and","with","respect","to","max_cost","Args",":","word","(","str",")",":","word","to","find","a","fuzzy","match","for","max_cost","(","int",")",":","maximum","levenshtein","distance","when","performing","the","fuzzy","match","start_node","(","dict",")",":","Trie","node","from","which","the","search","is","performed","Yields",":","node",",","cost",",","depth","(","tuple",")",":","A","tuple","containing","the","final","node",",","the","cost","(","i.e","the","distance",")",",","and","the","depth","in","the","trie","Examples",":",">",">",">","from","flashtext","import","KeywordProcessor",">",">",">","keyword_processor","=","KeywordProcessor","(","case_sensitive=True",")",">",">",">","keyword_processor.add_keyword","(","'Marie","'",",","'Mary","'",")",">",">",">","next","(","keyword_processor.levensthein","(","'Maria","'",",","max_cost=1",")",")",">",">",">","(","{","'_keyword_","'",":","'Mary","'","}",",","1",",","5",")","...",">",">",">","keyword_processor","=","KeywordProcessor","(","case_sensitive=True",">",">",">","keyword_processor.add_keyword","(","'Marie","Blanc","'",",","'Mary","'",")",">",">",">","next","(","keyword_processor.levensthein","(","'Mari","'",",","max_cost=1",")",")",">",">",">","(","{","'","'",":","{","'","B","'",":","{","'","l","'",":","{","'","a","'",":","{","'n","'",":","{","'","c","'",":","{","'_keyword_","'",":","'Mary","'","}","}","}","}","}","}","}",",","1",",","5",")"]
code: def levensthein(self, word, max_cost=2, start_node=None):
      """
      Retrieve the nodes where there is a fuzzy match,
      via levenshtein distance, and with respect to max_cost
  
      Args:
          word (str): word to find a fuzzy match for
          max_cost (int): maximum levenshtein distance when performing the fuzzy match
          start_node (dict): Trie node from which the search is performed
  
      Yields:
          node, cost, depth (tuple): A tuple containing the final node,
                                    the cost (i.e the distance), and the depth in the trie
  
      Examples:
          >>> from flashtext import KeywordProcessor
          >>> keyword_processor = KeywordProcessor(case_sensitive=True)
          >>> keyword_processor.add_keyword('Marie', 'Mary')
          >>> next(keyword_processor.levensthein('Maria', max_cost=1))
          >>> ({'_keyword_': 'Mary'}, 1, 5)
          ...
          >>> keyword_processor = KeywordProcessor(case_sensitive=True
          >>> keyword_processor.add_keyword('Marie Blanc', 'Mary')
          >>> next(keyword_processor.levensthein('Mari', max_cost=1))
          >>> ({' ': {'B': {'l': {'a': {'n': {'c': {'_keyword_': 'Mary'}}}}}}}, 1, 5)
      """
      start_node = start_node or self.keyword_trie_dict
      rows = range(len(word) + 1)
  
      for char, node in start_node.items():
          yield from self._levenshtein_rec(
              char, node, word, rows, max_cost, depth=1
          )
  
imports: import os
  import string
  import io
label_desc: Use image node_id 22 for calling the KeywordProcessor obj's underlying member method code with example usage: obj.levensthein(word, max_cost, start_node) without return types