Answers for "calculate idf of a corpus python without sklearn"

2

get tfidf score for a sentence

>>> from sklearn.feature_extraction.text import TfidfVectorizer
>>> corpus = [
...     'This is the first document.',
...     'This document is the second document.',
...     'And this is the third one.',
...     'Is this the first document?',
... ]
>>> vectorizer = TfidfVectorizer()
>>> X = vectorizer.fit_transform(corpus)
>>> print(vectorizer.get_feature_names())
['and', 'document', 'first', 'is', 'one', 'second', 'the', 'third', 'this']
>>> print(X.shape)
(4, 9)
Posted by: Guest on June-07-2020

Code answers related to "calculate idf of a corpus python without sklearn"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language