Nlp

NLP Knowledge and experiences

Python

import sklearn
from sklearn.feature_extraction.text import CountVectorizer
# instantiate an ngram counter
counts = CountVectorizer(analyzer='word', ngram_range=(n,n))

# create a dictionary of n-grams by calling `.fit`
vocab2int = counts.fit([a_text, s_text]).vocabulary_

Resources

Last updated