from gensim import corpora
docs = ['this is a foo bar', 'you are a foo']
texts = [[i for i in doc.lower().split()] for doc in docs]
print(texts)
dictionary = corpora.Dictionary(texts)
dictionary.save('foobar.txtdic')
Gensim Dictionary Implementation