def read_dictionary(dict_file):
  """
  Read dictionary of words from file.
  The dictionary file must be sorted by frequency of words in ascending order.
  The file must be formatted as:

  word1 freq1
  word2 freq2

  with space as separator
  """
  words = {}
  with open(dict_file, 'r', encoding='utf-8') as fp:
    for line in fp:
      w, i = line.split(' ')
      words[w] = int(i)
  return words