Skip to content

Instantly share code, notes, and snippets.

@himangSharatun
Created February 9, 2018 07:41
Show Gist options
  • Save himangSharatun/ac6402382763bba4bc6eef788f762b43 to your computer and use it in GitHub Desktop.
Save himangSharatun/ac6402382763bba4bc6eef788f762b43 to your computer and use it in GitHub Desktop.
from sklearn.feature_extraction.text import CountVectorizer
import json
vocab_path = 'vocabulary.json'
vocabulary = json.load(open(vocab_path))
vectorizer = CountVectorizer(vocabulary=vocabulary)
def tobow(string):
return vectorizer.transform([string]).toarray()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment