docstr: load unigram dict and user dict
docstr_tok: ["load","unigram","dict","and","user","dict"]
code: def load_dict(self):
      """load unigram dict and user dict"""
      import ahocorasick
  
      self.total_count = 0.0
      self.ngram_dict = {}
      print("Loading dict...")
      for line in io.open(
          self.ngram_dict_path, mode="r", encoding="utf-8"
      ):
          if six.PY2:
              word, pos, wordfreq = (
                  line.encode("utf-8").strip("\n").split("\t")
              )
          else:
              word, pos, wordfreq = line.strip("\n").split("\t")
          wordfreq = int(wordfreq)
          if pos.lower() not in self.all_pos_types:
              continue
          assert wordfreq > 0, "Word frequency must be postive integer!"
          self.total_count += wordfreq
          self.ngram_dict[word + "/" + pos] = wordfreq
      for key in self.ngram_dict:
          wordfreq = self.ngram_dict[key]
          self.ngram_dict[key] = np.log(wordfreq / self.total_count)
      self.oov_score = np.log(1 / self.total_count)
  
      self.user_dict = ahocorasick.Automaton()
      for line in io.open(
          self.user_dict_path, mode="r", encoding="utf-8"
      ):
          if six.PY2:
              word, pos, wordfreq = (
                  line.encode("utf-8").strip("\n").split("\t")
              )
          else:
              word, pos, wordfreq = line.strip("\n").split("\t")
          wordfreq = int(wordfreq)
          assert pos in self.all_pos_types, "Invalid POS type"
          assert wordfreq > 0, "Word frequency must be postive integer!"
          self.ngram_dict[word + "/" + pos] = np.log(
              wordfreq / self.total_count
          )
          self.user_dict.add_word(word, (word, pos, wordfreq))
      self.user_dict.make_automaton()
  
imports: import io
  import numpy
  import six
label_desc: Use image node_id 3 for calling the Interventer obj's underlying member method code with example usage: obj.load_dict() without return types