class_docstr: Component that finds replacement candidates for tokens at a set Damerau-Levenshtein distance
  
  Args:
      words: list of every correct word
      max_distance: maximum allowed Damerau-Levenshtein distance between source words and candidates
      error_probability: assigned probability for every edit
      vocab_penalty: assigned probability of an out of vocabulary token being the correct one without changes
  
  Attributes:
      max_distance: maximum allowed Damerau-Levenshtein distance between source words and candidates
      error_probability: assigned logarithmic probability for every edit
      vocab_penalty: assigned logarithmic probability of an out of vocabulary token being the correct one without
       changes
class_docstr_tok: ["Component","that","finds","replacement","candidates","for","tokens","at","a","set","Damerau-Levenshtein","distance","Args",":","words",":","list","of","every","correct","word","max_distance",":","maximum","allowed","Damerau-Levenshtein","distance","between","source","words","and","candidates","error_probability",":","assigned","probability","for","every","edit","vocab_penalty",":","assigned","probability","of","an","out","of","vocabulary","token","being","the","correct","one","without","changes","Attributes",":","max_distance",":","maximum","allowed","Damerau-Levenshtein","distance","between","source","words","and","candidates","error_probability",":","assigned","logarithmic","probability","for","every","edit","vocab_penalty",":","assigned","logarithmic","probability","of","an","out","of","vocabulary","token","being","the","correct","one","without","changes"]
code: def _infer_instance(
      self, tokens: Iterable[str]
  ) -> List[List[Tuple[float, str]]]:
      candidates = []
      for word in tokens:
          if word in self._punctuation:
              candidates.append([(0, word)])
          else:
              c = {
                  candidate: self.error_probability * distance
                  for candidate, distance in self.searcher.search(
                      word, d=self.max_distance
                  )
              }
              c[word] = c.get(word, self.vocab_penalty)
              candidates.append(
                  [(score, candidate) for candidate, score in c.items()]
              )
      return candidates
  
file_path: DeepPavlov/deeppavlov/models/spelling_correction/levenshtein/searcher_component.py
imports: import string
  from logging import getLogger
  from math import log10
  from typing import Iterable, List, Tuple, Optional
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
  from .levenshtein_searcher import LevenshteinSearcher
label_desc: Use image node_id 2 for calling the LevenshteinSearcherComponent obj's underlying member method code with example usage: obj._infer_instance(tokens) and returns: candidates