Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space that measures the cosine of the angle between them.
Similarity = (A.B) / (||A||.||B||) where A and B are vectors.
Cosine similarity and nltk toolkit module are used in this program. To execute this program nltk must be installed in your system. In order to install nltk module follow the steps below –
1. Open terminal(Linux). 2. sudo pip3 install nltk 3. python3 4. import nltk 5. nltk.download(‘all’)
nltk.tokenize: It is used for tokenization. Tokenization is the process by which big quantity of text is divided into smaller parts called tokens.
word_tokenize(X)split the given sentence X into words and return list.
nltk.corpus: In this program, it is used to get a list of stopwords. A stop word is a commonly used word (such as “the”, “a”, “an”, “in”).
- Movie recommender based on plot summary using TF-IDF Vectorization and Cosine similarity
- Measure similarity between images using Python-OpenCV
- scipy stats.cosine() | Python
- Python | Word Similarity using spaCy
- Statistical Functions in Python | Set 1 (Averages and Measure of Central Location)
- Statistical Functions in Python | Set 2 ( Measure of Spread)
- Python - Measure time taken by program to execute
- Python | Test list element similarity
- Python | Similarity metrics of strings
- Python | Percentage similarity of lists
- Measuring the Document Similarity in Python
- Python - Alternate elements Similarity
- Degree Centrality (Centrality Measure)
- Katz Centrality (Centrality Measure)
- ML | V-Measure for Evaluating Clustering Performance
- NLP | WuPalmer - WordNet Similarity
- NLP | Leacock Chordorow (LCH) and Path similarity for Synset
- Python | Difference between two dates (in minutes) using datetime.timedelta() method
- Python | Calculate Distance between two places using Geopy
- Make filled polygons between two curves in Python using Matplotlib
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.