This
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 and punctuation discarded and turned into the set containing the words {chocolate, ice, cream, milk, and, bars, are, delicious}. An identical processis 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.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
EBK PROBLEM SOLVING WITH C++
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out With Visual Basic (8th Edition)
Software Engineering (10th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out With Visual Basic (7th Edition)
- Write a java program to place ten queens on 10 x 10 chessboard in such a way that one queen is to bein each row. A program will use 2 DIMENIONAL array x[r][c] to do this configuration. If x[r] hasvalue c, then in row r there is a queen in column c. Write a program that asks a user to enter thecolumns that contain queens in the ten rows. The program then places the queens in thesecolumns (one per row) and prints the board.arrow_forwardWrite a program that creates a table for the user's choice of basic math operations (+, -, *, /, and %). These operations will all be performed in an integer-only way. (Modulo doesn't work with decimals anyway... And you're going to have enough trouble lining up the table without dealing with decimal places on division!) The user should also be allowed to choose the size of the table (it will, of course, be square: 4x4, 5x5, etc.). You may limit the maximum size of the table, for formatting purposes. Make sure your table is neat and lines up nicely (see the examples below). Columns should all be of equal width. This should be the minimum width necessary to hold the largestanswer for the table's operation. (Be careful! This may be a negative value!) Note that, if each column is as small as possible, you can fit more of them on the screen... Try to use functions to break up the program into more manageable -- re-usable -- pieces. (You'll note that most of the table display is identical…arrow_forwardSolve in Python: Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the last name. Ex: If the input is: Michael Jordan 1991 the output is: Your login name: JordaM91 Ex: If the input is: Kanye West 2024 the output is: Your login name: WestK24arrow_forward
- Write a program that reads HAND_SIZE cards from the user, then analyzes the cards and prints out the type of poker hand that they represent. (HAND_SIZE will be a global constant, typically 5, but your program must still work if it is set to something other than 5.) Poker hands are categorized according to the following hand-types: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card. To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from LOWEST_NUM to HIGHEST_NUM. (These will be global constants. We'll use LOWEST_NUM = 2 and HIGHEST_NUM = 9, but your program must work if these are set to something different.) When your program runs it should start by collecting HAND_SIZE integer values from the user and placing the integers into an array that has HAND_SIZE elements. It might look like this: Enter 5 numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card…arrow_forwardWrite a program that reads HAND_SIZE cards from the user, then analyzes the cards and prints out the type of poker hand that they represent. (HAND_SIZE will be a global constant, typically 5, but your program must still work if it is set to something other than 5.) Poker hands are categorized according to the following hand-types: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card. To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from LOWEST_NUM to HIGHEST_NUM. (These will be global constants. We'll use LOWEST_NUM = 2 and HIGHEST_NUM = 9, but your program must work if these are set to something different.) When your program runs it should start by collecting HAND_SIZE integer values from the user and placing the integers into an array that has HAND_SIZE elements. It might look like this: Enter 5 numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card…arrow_forwardWrite a Python program, in a file called number_guessing.py, to play a number guessing game with twoplayers.The game is played for a fixed number of “sets” as pre-determined by the players. For each set, each player isgiven 2 tries to guess the value of a randomly generated number (between 1 and 6, inclusive). A differentrandom number is used for each player, for each set. If the player guesses the number on the first try, they get5 points (and don’t have to guess again), if they guess the number on the second try, they get 3 points,otherwise they get no points. The player with the highest number of points, at the end of all sets, wins thegame (or there can be a tie/draw).Your program should include the following functions:• function main to do the following:o obtain as input, the number of sets that the players wish to playo obtain the name of the two playerso for each set of the game, and for each player, randomly generate the number to be guessedo compute and return the points for a…arrow_forward
- Our usual number system is base 10, because it strings together the digits 0 – 9 to form any whole number (there is a 1’s place, a 10’s place, a 10-squared’s place, etc). Hexadecimal numbers are written in base 16. This means they string together the digits 0 – 9 and the letters A – F to form any whole number (there is a 1’s place, a 16’s place, a 16-squared’s place, etc). For example, BD3C8 and 305A2 are two different 5-digit hexadecimal numbers. How many 9-digit hexadecimal numbers are there that have exactly 4 zeroes. (Note: Hexadecimal numbers, like our normal base 10 numbers, cannot start with a 0)arrow_forwardI need help with creating a Java program described below: Hamming distance. The Hamming distance between two-bit strings of length n is equal to the number of bits in which the two strings differ. Write a program that reads in an integer k and a bit string s from the command line, and prints all bit strings that have Hamming distance at most k from s. For example, if k is 2 and s is 0000, then your program should print 0011 0101 0110 1001 1010 1100 Hint: Choose k as the number of bits to flip in s.arrow_forwardIn PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The output of this code should be a third sequence that is a COMBINATION of both sequences 1 and 2 and is sorted in non-decreasing order where if there are two of the same number they are put together in the final sequence. Such as 1, 20.3, 20.3, 66, 7, 4 please do this using PYTHON, ONLY using while loops. NO language of "break", "len", "True", or "return" anywhere in the code! DO THIS USING 3 SEPARATE LISTS!arrow_forward
- In PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The output of this code should be a third sequence that is a COMBINATION of both sequences 1 and 2 and is sorted in non-decreasing order where if there are two of the same number they are put together in the final sequence. Such as 1, 20.3, 20.3, 66, 7, 4 please do this using PYTHON, ONLY using while loops. NO language of "break", "len", "True", or "return" anywhere in the code! DO THIS USING 3 SEPARATE WHILE LOOPS!arrow_forwardWrite a python program: In the first century AD, Nicomachus suggested in his book entitled Introduction Arithmetica that “Cubical numbers can always be represented as the sum of successive odd numbers.” For example, 1^3= 1 = 1 2^3 = 8 = 3 + 5 3^3 = 27 = 7 + 9 + 11 4^3 = 64 = 13 + 15 + 17 + 19 Input N and output the successive odd integers whose sum is i^3 for all i in the set { 1,2,..,N } .arrow_forwardWrite program in Java: Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (currentPrice * 0.051) / 12 (Note: Output directly. Do not store in a variable.). Ex: If the input is: 200000 210000 the output is: This house is $200000. The change is $-10000 since last month. The estimated monthly mortgage is $850.0. Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming. LabProgram.java: import java.util.Scanner; public class LabProgram {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);int currentPrice; int lastMonthsPrice; currentPrice = scnr.nextInt(); lastMonthsPrice = scnr.nextInt();/* Type your code…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education