5 Answers
New Answer5 Answers
New AnswerJaz , may be you should read this first before starting any coding try. https://www.journaldev.com/46591/bag-of-words-model-in-python https://vitalflux.com/text-classification-bag-of-words-model-python-sklearn/ https://www.analyticsvidhya.com/blog/2021/08/a-friendly-guide-to-nlp-bag-of-words-with-python-example/
You can use collections.Counter(). https://docs.python.org/3/library/collections.html#collections.Counter
Why wouldn't you want to use CountVectorizer? Wouldn't that just end up with less functionality? Just asking.
Bob_Li because we were asked by our professor to find an alternative for CountVectorizer in our assignment.
kung-fu training for programmers π you have to replace CountVectorizer with something else. maybe this? Count Vectorizer vs TFIDF Vectorizer | Natural Language Processing https://www.linkedin.com/pulse/count-vectorizers-vs-tfidf-natural-language-processing-sheel-saket https://neptune.ai/blog/vectorization-techniques-in-nlp-guide
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message