class_docstr: Language model container class to consolidate functionality.
  
  This class is a wrapper around the kenlm language model. It provides
  functionality to score tokens and to get the initial state.
  
  Taken from: https://github.com/kensho-technologies/pyctcdecode
  
  Arguments
  ---------
  kenlm_model : kenlm.Model
      Kenlm model.
  unigrams : list
      List of known word unigrams.
  alpha : float
      Weight for language model during shallow fusion.
  beta : float
      Weight for length score adjustment of during scoring.
  unk_score_offset : float
      Amount of log score offset for unknown tokens.
  score_boundary : bool
      Whether to have kenlm respect boundaries when scoring.
class_docstr_tok: ["Language","model","container","class","to","consolidate","functionality",".","This","class","is","a","wrapper","around","the","kenlm","language","model",".","It","provides","functionality","to","score","tokens","and","to","get","the","initial","state",".","Taken","from",":","https",":","\/\/github.com\/kensho-technologies\/pyctcdecode","Arguments","--","--","--","--","-","kenlm_model",":","kenlm.Model","Kenlm","model",".","unigrams",":","list","List","of","known","word","unigrams",".","alpha",":","float","Weight","for","language","model","during","shallow","fusion",".","beta",":","float","Weight","for","length","score","adjustment","of","during","scoring",".","unk_score_offset",":","float","Amount","of","log","score","offset","for","unknown","tokens",".","score_boundary",":","bool","Whether","to","have","kenlm","respect","boundaries","when","scoring","."]
docstr: Score word conditional on start state.
docstr_tok: ["Score","word","conditional","on","start","state","."]
code: def score(
      self, prev_state, word: str, is_last_word: bool = False
  ) -> Tuple[float, KenlmState]:
      """Score word conditional on start state."""
      if not isinstance(prev_state, KenlmState):
          raise AssertionError(
              f"Wrong input state type found. Expected KenlmState, got {type(prev_state)}"
          )
      end_state = _get_empty_lm_state()
      lm_score = self._kenlm_model.BaseScore(
          prev_state.state, word, end_state
      )
      # override UNK prob. use unigram set if we have because it's faster
      if (
          len(self._unigram_set) > 0
          and word not in self._unigram_set
          or word not in self._kenlm_model
      ):
          lm_score += self.unk_score_offset
      # add end of sentence context if needed
      if is_last_word:
          # note that we want to return the unmodified end_state to keep extension capabilities
          lm_score = lm_score + self._get_raw_end_score(end_state)
      lm_score = (
          self.alpha * lm_score * 1.0 / math.log10(math.e) + self.beta
      )
      return lm_score, KenlmState(end_state)
  
file_path: speechbrain/speechbrain/decoders/language_model.py
imports: import logging
  from typing import Collection, Optional, Set, Tuple, cast
  from pygtrie import CharTrie
  import math
label_desc: Use image node_id 6 for calling the LanguageModel obj's underlying member method code with example usage: obj.score(prev_state, word, is_last_word) and returns: lm_score,  KenlmState