Write a function get_quotes (text) that takes in a string of English text, and extracts a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function get_quotes (text) that takes in a string of English text, and extracts a list of all of the quotations from the string. Here a quotation is defined as the sequence of characters that occur between the first quotation mark (") in the text and the second, and those that occur between the third quotation mark and the fourth, and so on. You can assume that there will be an even number of quotation marks in the string, and that there will be no apostrophe/single quote marks (') within the string (mostly because they will be used to start/end the string itself). Hint: While this can be done using .find or regular expressions, there's a very simple solution that uses.split and slicing. Examples: >>> get_quotes ('I began. "Here is a quote", I said. She nodded; "This is also a quote", she replied.') ['Here is a quote', 'This is also a quote'] >>> get_quotes('Again he said:-"Welcome to my house. Come freely. Go safely; and leave something of the happiness you bring!" The strength of the handshake was so much akin to that which I had noticed in the driver, whose face I had not seen, that for a moment I doubted if it were not the same person to whom I was speaking; so to make sure, I said interrogatively:-"Count Dracula?" He bowed in a courtly way as he replied: "I am Dracula; and I bid you welcome, Mr. Harker, to my house."') ['Welcome to my ho se. Come freely. Go safely; and leave something the happiness you bring!', 'Count Dracula?', 'I am Dracula; and I bid you welcome, Mr. Harker, to my house.'] >>> get_quotes ('"The man who wrote it was presumably well to do, I remarked, endeavouring to imitate my companion's processes. "Such paper could not be bought under half a crown a packet. It is peculiarly strong and stiff." "Peculiar-that is the very word," said Holmes. "It is not an English paper at all. Hold it up to the light." I did so.') 11 Write a function get_quotes (text) that takes in a string of English text, and extracts a list of all of the quotations from the string. Here a quotation is defined as the sequence of characters that occur between the first quotation mark (") in the text and the second, and those that occur between the third quotation mark and the fourth, and so on. You can assume that there will be an even number of quotation marks in the string, and that there will be no apostrophe/single quote marks (') within the string (mostly because they will be used to start/end the string itself). Hint: While this can be done using .find or regular expressions, there's a very simple solution that uses.split and slicing. Examples: >>> get_quotes ('I began. "Here is a quote", I said. She nodded; "This is also a quote", she replied.') ['Here is a quote', 'This is also a quote'] >>> get_quotes('Again he said:-"Welcome to my house. Come freely. Go safely; and leave something of the happiness you bring!" The strength of the handshake was so much akin to that which I had noticed in the driver, whose face I had not seen, that for a moment I doubted if it were not the same person to whom I was speaking; so to make sure, I said interrogatively:-"Count Dracula?" He bowed in a courtly way as he replied: "I am Dracula; and I bid you welcome, Mr. Harker, to my house."') ['Welcome to my ho se. Come freely. Go safely; and leave something the happiness you bring!', 'Count Dracula?', 'I am Dracula; and I bid you welcome, Mr. Harker, to my house.'] >>> get_quotes ('"The man who wrote it was presumably well to do, I remarked, endeavouring to imitate my companion's processes. "Such paper could not be bought under half a crown a packet. It is peculiarly strong and stiff." "Peculiar-that is the very word," said Holmes. "It is not an English paper at all. Hold it up to the light." I did so.') 11
Expert Answer:
Related Book For
Posted Date:
Students also viewed these computer network questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Your current bank offers interest on deposits at 5% compounded annually.Western Bank would like to lure you to their bank and will offer you daily compounding. What stated APR must Western Bank offer...
-
Read ADEC case study and make a presentation showing impact of EMIRATI culture on cross-cultural communication in Abu Dhabi education council schools
-
A flat sheet that has an area of \(3.0 \mathrm{~m}^{2}\) is placed in a uniform electric field of magnitude \(10 \mathrm{~N} / \mathrm{C}\). While keeping the shect flat, can you orient it so that...
-
On 1 July 2025, McGregor and Roberts decided to amalgamate their businesses and to share profits equally. Financial information at that date was as follows. At 1 July 2025, McGregors accounts...
-
In the early twentieth century, there was an ambitious young man named Arthur who started working at a company in Chicago as a mailroom clerk. He was a hard worker and very smart, eventually ending...
-
(a) A mutual fund raised Rs. 150 lakhs on April 1, 2018 by issue of 15 lakh units at Rs. 10 per unit. The fund invested in several capital market instruments to build a portfolio of Rs. 140 lakhs,...
-
The Alfredo Fragrance Company produces only one product, a perfume called Hint of Elegance. Hint of Elegance consists of two secret ingredients blended into an exclusive fragrance, which is marketed...
-
Government officials of Country Z estimate that next years public programs will cost $19 million but that tax revenues will be only $15 million. Which of the following statements is false? A. Country...
-
Consider the function f(x)=x-5x+7x-3. (a) (i) Find f'(x) and "(x). [1 mark] (ii) Using Newton's method, find a root of f(x) starting with po =0.9 by completing the following table. Use FOUR decimal...
-
The $7,800 has already been spent or committed. What does the relevant income or loss represent for Flagstone?
-
The mean outstanding credit card balance distributed normally for young American couples is u = $650 with a standard deviation = $420. In a simple random sample of 100 couples, what is the...
-
What series of payments is represented by the present value A.Q B-(Da)n?
-
If your company recently received items it ordered from a vendor, and the bill will arrive in one week's time, what can you do in QuickBooks to keep your records the most up-to-date?
-
The function f(*) satisfies the following. Draw the graph on the axis provided. Include asymptotes as dashed lines. Removable singularities (holes): x = -10 X-intercepts (zeros): x 3 and x 7...
-
Test whether the 5-year survival rate for breast cancer is significantly different between African American and Caucasian women who are younger than 50 years of age and have localized disease....
-
Let us use the alphabet = {a b c d}. Build a 3PDA that accepts the language {a n b n c n d n }.
-
Using bottom-up parsing, find any derivation in the grammar PLUS-TIMES for the following expressions: (i) i * (i) (ii) ((i) + ((i))) (iii) (i * i + i) (iv) i * (i + i) (v) (i * i) * i
-
The set POLYNOMIAL defined in this chapter contains only the polynomials in the one variable x. Write a recursive definition for the set of all polynomials in the two variables x and y.
-
How can we effectively analyze a firm's financial ratios?
-
In 2019, Italia Mining Corporation had sales of \($69\) million, total assets of \($45\) million, and total liabilities of \($23\) million. The interest rate on the debt is 6.5 percent, and its tax...
-
BlackBerry Ltd. has a target current ratio of 2.0 but has experienced some difficulties financing its expanding sales in the past few months. At present, the firm has current assets of $750,000 and a...
Study smarter with the SolutionInn App