def build_vocab(sentences):
  """
  Builds a vocabulary mapping from word to index based on the sentences.
  Returns vocabulary mapping and inverse vocabulary mapping.
  """

  vocabulary_inv = []
  vocabulary_inv.append('<PAD/>')
  vocabulary_inv.append('UNK')
  for line in open('data/stopwords.txt') :
    line = line.strip()
    sep = line.split()

    word = sep[0]
    cnt = int(sep[1])

    if cnt < 5:
        continue

    vocabulary_inv.append(word)

  # Mapping from word to index
  vocabulary = {x: i for i, x in enumerate(vocabulary_inv)}

  return [vocabulary, vocabulary_inv]