def getTfidfFeat(words, dictionary, tfidf_model):
    """ Generate tf-idf feature in VW format."""
    # bow feats
    bow = dictionary.doc2bow(words)
    # tf-idf feats
    tfidf = tfidf_model[bow]
    feat = ""
    if len(tfidf) > 0:
        for f in tfidf:
            feat += "%s:%s " % (f[0], f[1])
        feat = feat[:-1]
    return feat