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 __init__(
      self,
      words: Iterable[str],
      max_distance: int = 1,
      error_probability: float = 1e-4,
      vocab_penalty: Optional[float] = None,
      **kwargs,
  ):
      words = list(
          {word.strip().lower().replace("ё", "е") for word in words}
      )
      alphabet = sorted({letter for word in words for letter in word})
      self.max_distance = max_distance
      self.error_probability = log10(error_probability)
      self.vocab_penalty = (
          self.error_probability
          if vocab_penalty is None
          else log10(vocab_penalty)
      )
      self.searcher = LevenshteinSearcher(
          alphabet, words, allow_spaces=True, euristics=2
      )
  
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 1 to create a new LevenshteinSearcherComponent object from inherited base classes: Component with example: obj = LevenshteinSearcherComponent(words, max_distance, error_probability, vocab_penalty)