SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Friends Overloaded Operators And Arrays In Classes
Exercise:
Programming Projects
Question:13 | ISBN:9780321531346 | Edition: 7

Question

This programming project requires you to complete Programming Project

12 first.

The field of information retrieval is concerned with finding relevant

electronic documents based upon a query. For example, given a group of

keywords (the query), a search engine retrieves Web pages (documents)

and displays them sorted by relevance to the query. This technology

requires a way to compare a document with the query to see which is

most relevant to the query.

A simple way to make this comparison is to compute the binary cosine

coefficient. The coefficient is a value between 0 and 1, where 1 indicates

that the query is very similar to the document and 0 indicates that the

query has no keywords in common with the document. This approach

treats each document as a set of words. For example, given the following

sample document:

Chocolate ice cream, chocolate milk, and chocolate bars are delicious.”

This document would be parsed into keywords where case is ignored,

punctuation discarded, and turned into the set containing the words

{chocolate, ice, cream, milk, and, bars, are, delicious}. An identical

process is performed on the query to turn it into a set of strings.

Once we have a query Q represented as a set of words and a document D

represented as a set of words, the similarity between Q and D is computed by: treats each document as a set of words. For example, given the following

sample document:

Chocolate ice cream, chocolate milk, and chocolate bars are delicious.”

This document would be parsed into keywords where case is ignored,

punctuation discarded, and turned into the set containing the words

{chocolate, ice, cream, milk, and, bars, are, delicious}. An identical

process is performed on the query to turn it into a set of strings.

Once we have a query Q represented as a set of words and a document D

represented as a set of words, the similarity between Q and D is computed by:

Sim Q D

Q D

= ------------------------

Modify the StringSet from Programming Project 12 by adding an

additional member function that computes the similarity between the

current StringSet and an input parameter of type StringSet. The sqrt

function is in the cmath library.

Create two text files on your disk named Document1.txt and Document2.txt.

Write some text content of your choice in each file, but make sure that

each file contains different content. Next, write a program that allows the

user to input from the keyboard a set of strings that represents a query.

The program should then compare the query to both text files on the disk

and output the similarity to each one using the binary cosine coefficient.

Test your program with different queries to see if the similarity metric is

working correctly.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.