Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: StringSet Class Define a class called StringSet that will be used to store a set of STL strings. Use an array or a

Part 1: StringSet Class

Define a class called StringSet that will be used to store a set of STL strings. Use an array or a vector to store the string.

Create a constructor that takes as an input parameter an array of strings for the initial values in the set. Then write member functions to add a string, remove a string from the set, clear the entire set, return the number of strings in the set, and output all strings in the set. Overload the + operator so that it returns the unions of two StringSet objects. Also overload the *operator so that it returns the intersection of two StringSetobejcts.

Write a program to test all member functions and overloaded operators in your class.

Part 2: StringSet Similarity

Add a member function that computes the similarity between the currentStringSet and an input parameter of type StringSet.

The field of information retrieval is concerned with finding relevant electronic documents based upon a query. For example, given a group of keywords (query), a search engine retrieves Web pages (documents) and displays them sorted by relevance to the query.

A way to make this comparison is to compute the binary cosine coefficient. The coefficient is a value between 0 and 1, where I 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:

Write a program to test all member functions and overloaded operators in your class.

This document would be pared into keywords where case is ignored and punctuation discarded and turned into the set containing the words

{write, a, program, to, test, all member, functions, and, overloaded, operators, in, your, class}

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|

Create two text files named doc1.txt and doc2.txt. Write some text content of your choice in each file, but make sure that each file contains different content.

Write a program that allows the user to input form the keyboard a set of strings that represents a query. The program should then compare the query to both text files and the 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.

Submission

You are to submit electronically:

All files constituting the solution of this assignment. Post the source codes of part 1 and 2, along with the doc1.txt and doc2.txt.

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago