code: def read_freqs(
      freqs_loc, max_length=100, min_doc_freq=5, min_freq=50
  ):
      print("Counting frequencies...")
      counts = PreshCounter()
      total = 0
      with freqs_loc.open() as f:
          for i, line in tqdm(enumerate(f)):
              freq, doc_freq, key = line.rstrip().split("\t", 2)
              freq = int(freq)
              counts.inc(i + 1, freq)
              total += freq
      counts.smooth()
      log_total = math.log(total)
      probs = {}
      with freqs_loc.open() as f:
          for line in tqdm(f):
              freq, doc_freq, key = line.rstrip().split("\t", 2)
              doc_freq = int(doc_freq)
              freq = int(freq)
              if (
                  doc_freq >= min_doc_freq
                  and freq >= min_freq
                  and len(key) < max_length
              ):
                  try:
                      word = literal_eval(key)
                  except SyntaxError:
                      # Take odd strings literally.
                      word = literal_eval("'%s'" % key)
                  smooth_count = counts.smoother(int(freq))
                  probs[word] = math.log(smooth_count) - log_total
      oov_prob = math.log(counts.smoother(0)) - log_total
      return probs, oov_prob
  
file_path: scispacy/scripts/convert_freqs.py
imports: import argparse
  import math
  import json
  from ast import literal_eval
  from tqdm import tqdm
  from preshed.counter import PreshCounter
  from spacy.util import ensure_path
  from scispacy.file_cache import cached_path
label_desc: Use image node_id 1 for calling a global function with example usage: read_freqs(freqs_loc, max_length, min_doc_freq, min_freq) and returns: probs,  oov_prob