class_docstr: Provides a dictionary that performs fuzzy lookup
docstr: Returns the value whose key best matches lookfor
  
  if stop_on_first is True then the method returns as soon
  as it finds the first item
docstr_tok: ["Returns","the","value","whose","key","best","matches","lookfor","if","stop_on_first","is","True","then","the","method","returns","as","soon","as","it","finds","the","first","item"]
code: def _search(self, lookfor: typing.Any, stop_on_first: bool = False):
      """Returns the value whose key best matches lookfor
  
      if stop_on_first is True then the method returns as soon
      as it finds the first item
      """
  
      # if the item is in the dictionary then just return it
      if self._dict_contains(lookfor):
          return True, lookfor, self._dict_getitem(lookfor), 1
  
      # set up the fuzzy matching tool
      ratio_calc = difflib.SequenceMatcher()
      ratio_calc.set_seq1(lookfor)
  
      # test each key in the dictionary
      best_ratio = 0
      best_match = None
      best_key = None
      for key in self:
          # if the current key is not a string
          # then we just skip it
          try:
              # set up the SequenceMatcher with other text
              ratio_calc.set_seq2(key)
          except TypeError:
              continue
  
          # we get an error here if the item to look for is not a
          # string - if it cannot be fuzzy matched and we are here
          # this it is definitely not in the dictionary
          try:
              # calculate the match value
              ratio = ratio_calc.ratio()
          except TypeError:
              break
  
          # if this is the best ratio so far - save it and the value
          if ratio > best_ratio:
              best_ratio = ratio
              best_key = key
              best_match = self._dict_getitem(key)
  
          if stop_on_first and ratio >= self.cutoff:
              break
  
      return best_ratio >= self.cutoff, best_key, best_match, best_ratio
  
file_path: pyecharts/pyecharts/datasets/__init__.py
imports: import difflib
  import os
  import typing
  import urllib.request
  import simplejson
label_desc: Use image node_id 2 for calling the FuzzyDict obj's underlying member method code with example usage: obj._search(lookfor, stop_on_first) and returns: unknown,  best_key,  best_match,  best_ratio, True,  lookfor,  self,  int