Question: I need the answer in Python please from nltk.tokenize import word_tokenize import nltk import numpy as np all_documents = [Topic sentences are similar to mini
I need the answer in Python please

from nltk.tokenize import word_tokenize import nltk import numpy as np all_documents = ["""Topic sentences are similar to mini thesis statements. Like a thesis statement', 'a topic sentence has a specific main point. Whereas the thesis is the mai n point of the essay, the topic sentence is the main point of the paragraph . Like the thesis statement, a topic sentence has a unifying function. But a thesis statement or topic sentence alone doesnt guarantee unity.', 'An essay is unified if all the paragraphs relate to the thesis, whereas a paragraph is unified if all the sentences relate to the topic sentence.', 'A thesis on Roger Federer the greatest tennis player should be made', 'Nadal is also a great and he deserves a thesis in tennis"""]
\# Based on https://medium, com/Qashwinnaidul991/creating-a-tf-idf-model- from-scratch-in-python-71047fl 6494 - from nltk. tokenize import word_tokenize import nltk import numpy as np all documents = ['Topic sentences are similar to mini thesis statements. Li ke a thesis statement', 'a topic sentence has a specific main point. Whereas the thesis is the mai n point of the essay, the topic sentence is the main point of the paragraph a Like the thesis statement, a topic sentence has a unifying function. But a thesis statement or topic sentence alone doesn't guarantee unity.', 'An esiay is unified if all the paragraphs relate to the thesis, whereas a paragraph is unified if all the sentences relate to the topic sentence.', 'A thesis on Roger Federer the greatest tennis player should be made', 'Nadal is also a great and he deserves a thesis in tennis'] 2. Represent the documents contained in the list using . Use You are not allowed to use any library and you should build your TFIDF function from scratch. Use this link to help you build your representation. 3. Apply the cosine similarity using sklearn. Use the normal model that is computed using the below formula (Hint: you can use the Compressed Sparse Row matrix function sparse.csr matrix () to convert the list representing your TFIDF into ABAB=i=1nAi2i=1nBi2i=1nAiBi 4. Modify the function of Part-1 or use your own function to recommend a document to a user who likes the document that says: 'A thesis on Roger Federer the greatest tennis player should be made
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
