Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

LO 2.4 Understand the important role of mobile applications.

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago