dictionary = corpora.Dictionary(line.lower().split() for line in open(
    'corpus.txt'))
corpus = [dictionary.doc2bow(line.lower().split()) for line in open(
    'corpus.txt')]
tfidf = models.TfidfModel(corpus)
Python - tf-idf predict a new document similarity