import collections


def get_vocab(dataset):
  """Count words and build vocab."""
  vocab = {}

  # create a counter for each word
  for example in dataset:
    example_as_list = example.split()
    for word in example_as_list:
      vocab[word] = 0

  for example in dataset:
    example_as_list = example.split()
    for word in example_as_list:
      vocab[word] += 1

  # sort from greatest to least by count
  return collections.OrderedDict(
      sorted(vocab.items(), key=lambda x: x[1], reverse=True))