You will write a program to solve the co-occurrence problem. The co-occurrence problem is stat- ed...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will write a program to solve the co-occurrence problem. The co-occurrence problem is stat- ed as follows. We have a file containing English sentences, one sentence per line. Given a list of query words, your program should output the line number of lines that have all those words. Show your pointer prowess in completing this assignment. Assume the text in file contains only lowercase letters, does not have these punctuation charac- ters (; " * - ) and no digits. Ignore all other punctuation characters while processing the file. Here is one example. Assume that the following is the content of the file. Line numbers are in- cluded for clarity; the actual file doesn't have line numbers. 1. try not to become a man of success, but rather try to become a man of value. 2. look deep into nature, and then you will understand everything better. 3. the true sign of intelligence is not knowledge but imagination. 4. we cannot solve our problems with the same thinking we used when we created them. 5. weakness of attitude becomes weakness of character. 6. you can not blame gravity for falling in love. 7. the difference between stupidity and genius is that genius has its limits. (These are quotes from Albert Einstein. ) If we are asked to find all the lines that contain this set of words: {"knowledge", "imagination","true"} the answer will be line 3 because all three words appeared in line 3. If they appear in more than one line, your program should report all of them. For example, co-oc- currence of {"the", "is"} will be lines 3 and 7. Sample Output Test 1 Enter a file name: einstein.txt Enter space-separated words: the The co-occurance for word: the Lines: 3, 4, 7 Enter space-separated words: the is The co-occurance for words: the, is Lines: 3, 7 Enter space-separated words: true knowledge imagination The co-occurance for: true, knowledge, imagination Lines: 3 Enter space-separated words: q You will write a program to solve the co-occurrence problem. The co-occurrence problem is stat- ed as follows. We have a file containing English sentences, one sentence per line. Given a list of query words, your program should output the line number of lines that have all those words. Show your pointer prowess in completing this assignment. Assume the text in file contains only lowercase letters, does not have these punctuation charac- ters (; " * - ) and no digits. Ignore all other punctuation characters while processing the file. Here is one example. Assume that the following is the content of the file. Line numbers are in- cluded for clarity; the actual file doesn't have line numbers. 1. try not to become a man of success, but rather try to become a man of value. 2. look deep into nature, and then you will understand everything better. 3. the true sign of intelligence is not knowledge but imagination. 4. we cannot solve our problems with the same thinking we used when we created them. 5. weakness of attitude becomes weakness of character. 6. you can not blame gravity for falling in love. 7. the difference between stupidity and genius is that genius has its limits. (These are quotes from Albert Einstein. ) If we are asked to find all the lines that contain this set of words: {"knowledge", "imagination","true"} the answer will be line 3 because all three words appeared in line 3. If they appear in more than one line, your program should report all of them. For example, co-oc- currence of {"the", "is"} will be lines 3 and 7. Sample Output Test 1 Enter a file name: einstein.txt Enter space-separated words: the The co-occurance for word: the Lines: 3, 4, 7 Enter space-separated words: the is The co-occurance for words: the, is Lines: 3, 7 Enter space-separated words: true knowledge imagination The co-occurance for: true, knowledge, imagination Lines: 3 Enter space-separated words: q
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
General Instructions Create a new notebook named HW_05_YourLastName.ipynb and complete problems 1 - 8 described below. Download the files diamonds_partial.txt and titanic_partial.txt , placing them...
-
what are the possible impacts of a restrictive monetary policy on the housing market assuming its a closed economy? What conditions (other than a reversal of the monetary policy) may counter act...
-
Davidson Industries, a sole proprietorship, sold the following assets in 2016: a. The following questions relate to the sale of the warehouse: (1). What is the adjusted basis of the warehouse? (2)....
-
Use Theorem 3.3 to find an error bound for the approximations in Exercise 1. In Exercise 1 For the given functions f (x), let x0 = 0, x1 = 0.6, and x2 = 0.9. Construct interpolation polynomials of...
-
One critical-thinking skill is a heightened awareness of the danger of reaching a conclusion prior to acquiring missing information that were it known would have a reasonable probability of altering...
-
Law Publishing Inc. began printing operations on January 1. Jobs 401 and 402 were completed during the month, and all costs applicable to them were recorded on the related cost sheets. Jobs 403 and...
-
The bar BC exerts a force on the cables at B that is directed along the line from C to B. (Figure 1) The mass of the suspended load is 190 kg. Suppose that = 20 and = 20. Part A What is the tension...
-
Ryan and Blake Lively are married filing jointly taxpayers. Ryan's birthdate is August 10, 1982 and Social Security number is 434-14-4448. Blake's birthdate is March 19, 1983 and their Social...
-
41 m to the left of the laser and a vertical distance AyA= 11 m below the laser. Refer to the figure. The laser light incident on the mirror (ray A) is reflected (ray B) and hits a bull's-eye that is...
-
You have to pay 11.9% retail tax where you live and you are buying a $17.60 case to protect your phone, what number should you multiply the price of the case by, in order to get the total amount of...
-
Preston Partners, a calendar-year partnership, has two unrelated general partners, Jack Preston and Diane Dunn. Jack has a 75 percent ownership interest in the partnership and Diane has a 25 percent...
-
Approximately a year and a half ago, you were hired as a Contracting Officer of NAVSYSCOM. You were previously employed by Company B, a DoD contractor. WHen you left, you maintained your 401K, but it...
-
5. There are three categories for movie tickets, with the following prices: General admission: $12.50 Senior citizen: Child under 10: $11.00 $9.00 Write a Python program that prompts the customer for...
-
Perform an online search using the words "old economy new economy marketing jobs" and read three (3) related sites. Once you have read the article or articles, use the websites below and any other...
-
Business strategy: Corporate-level strategy of Under Armour: 1. Does Under Armour Inc. has moderate to high levels of diversification? Please provide the relevant facts. 2. Is the diversification...
-
A spacecraft has left the earth and is moving toward Mars. An observer on the earth finds that, relative to measurements made when the spacecraft was at rest, its a. length is shorter b. KE is less...
-
Write a method to generate a perfectly balanced binary search tree of height h with keys 1 through 2h+1 1. What is the running time of your method?
-
Write a method to generate an N-node random binary search tree with distinct keys 1 through N. What is the running time of your routine?
-
If a hopscotch table with parameter MAX_DIST has load factor 0.5, what is the approximate probability that an insertion requires a rehash?
-
Kids Sports Consulting Pty Ltd is a company set up by sports and recreation management students to gain experience in running their own business. It had the following contribution margin income...
-
V. Zarb, the marketing manager for Maltese Treasures Ltd, is preparing a sales budget for the year ended 30 June 2020. In reviewing the actual sales data for the previous year, the sales and...
-
The following expenses budget has been prepared for Abacus Services for the year ending 30 June 2020. Professional salaries, secretarial wages and training are paid in the quarter in which they are...
Study smarter with the SolutionInn App