document

How to display filenames of word documents in a folder using python?

How to display filenames of word documents in a folder using python? Question: I want to display the filenames of word document present in a specified path using python. Asked By: JUSTIN || Source Answers: this could work for you: for file in os.listdir(PATH): if file.endswith(“.doc”) or file.endswith(“.docx”): print(file) Answered By: sxeros It could be …

Total answers: 4

Using Sklearn's TfidfVectorizer transform

Using Sklearn's TfidfVectorizer transform Question: I am trying to get the tf-idf vector for a single document using Sklearn’s TfidfVectorizer object. I create a vocabulary based on some training documents and use fit_transform to train the TfidfVectorizer. Then, I want to find the tf-idf vectors for any given testing document. from sklearn.feature_extraction.text import TfidfVectorizer self.vocabulary …

Total answers: 1

Simple implementation of N-Gram, tf-idf and Cosine similarity in Python

Simple implementation of N-Gram, tf-idf and Cosine similarity in Python Question: I need to compare documents stored in a DB and come up with a similarity score between 0 and 1. The method I need to use has to be very simple. Implementing a vanilla version of n-grams (where it possible to define how many …

Total answers: 5