A document is represented as a collection paragraphs, a paragraph is represented as a collection of sentences, a sentence is represented as a collection of words and a word is represented as a collection of lower-case ([a-z]) and upper-case ([A-Z]) English characters. You will convert a raw text document into its component paragraphs, sentences and words. To test your results, queries will ask you to return a specific paragraph, sentence or word as described below. Alicia is studying the C programming language at the University of Dunkirk and she represents the words, sentences, paragraphs, and documents using pointers: A word is described by . A sentence is described by . The words in the sentence are separated by one space (" "). The last word does not end with a space(" "). A paragraph is described by . The sentences in the paragraph are separated by one period ("."). A document is described by . The paragraphs in the document are separated by one newline("\n"). The last paragraph does not end with a newline. For example: Learning C is fun. Learning pointers is more fun.It is good to have pointers. The only sentence in the first paragraph could be represented as: char**first_sentence_in_first_paragraph={"Learning","C","is","fun"}; The first paragraph itself could be represented as: char***first_paragraph={{"Learning","C","is","fun"}}; The first sentence in the second paragraph could be represented as: char**first_sentence_in_second_paragraph={"Learning","pointers","is","more","fun"}; The second sentence in the second paragraph could be represented as: char**second_sentence_in_second_paragraph={"It","is","good","to","have","pointers"}; The second paragraph could be represented as: char***second_paragraph={{"Learning","pointers","is","more","fun"},{"It","is","good","to","have","pointers"}}; Finally, the document could be represented as: char****document={{{"Learning","C","is","fun"}},{{"Learning","pointers","is","more","fun"},{"It","is","good","to","have","pointers"}}}; Alicia has sent a document to her friend Teodora as a string of characters, i.e. represented by  not . Help her convert the document to  form by completing the following functions:  to return the document represented by .  to return the  paragraph.  to return the  sentence in the  paragraph.  to return the  word in the  sentence of the  paragraph. Input Format The first line contains the integer . Each of the next  lines contains a paragraph as a single string. The next line contains the integer , the number of queries. Each of the next  lines or groups of lines contains a query in one of the following formats: 1 The first line contains : The next line contains an integer , the number of sentences in the  paragraph. Each of the next  lines contains an integer , the number of words in the  sentence. This query corresponds to calling the function . 2 The first line contains : The next line contains an integer , the number of words in the  sentence of the  paragraph. This query corresponds to calling the function  3 The only line contains : This query corresponds to calling the function  Constraints The text which is passed to the  has words separated by a space (" "), sentences separated by a period (".") and paragraphs separated by a newline("\n"). The last word in a sentence does not end with a space. The last paragraph does not end with a newline. The words contain only upper-case and lower-case English letters.  number of characters in the entire document   number of paragraphs in the entire document  Output Format Print the paragraph, sentence or the word corresponding to the query to check the logic of your code. Sample Input 0 2Learning C is fun.Learning pointers is more fun.It is good to have pointers.31 22562 1 143 1 1 1 Sample Output 0 Learning pointers is more fun.It is good to have pointers.Learning C is funLearning Explanation 0 The first query corresponds to returning the second paragraph with  sentences of lengths  and  words. The second query correspond to returning the first sentence of the first paragraph. It contains  words. The third query corresponds to returning the first word of the first sentence of the first paragraph.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A document is represented as a collection paragraphs, a paragraph is represented as a collection of sentences, a sentence is represented as a collection of words and a word is represented as a collection of lower-case ([a-z]) and upper-case ([A-Z]) English characters.

You will convert a raw text document into its component paragraphs, sentences and words. To test your results, queries will ask you to return a specific paragraph, sentence or word as described below.

Alicia is studying the C programming language at the University of Dunkirk and she represents the words, sentences, paragraphs, and documents using pointers:

  • A word is described by .
  • A sentence is described by . The words in the sentence are separated by one space (" "). The last word does not end with a space(" ").
  • A paragraph is described by . The sentences in the paragraph are separated by one period (".").
  • A document is described by . The paragraphs in the document are separated by one newline("\n"). The last paragraph does not end with a newline.

For example:

Learning C is fun.
Learning pointers is more fun.It is good to have pointers.

  • The only sentence in the first paragraph could be represented as:
char**first_sentence_in_first_paragraph={"Learning","C","is","fun"};
  • The first paragraph itself could be represented as:
char***first_paragraph={{"Learning","C","is","fun"}};
  • The first sentence in the second paragraph could be represented as:
char**first_sentence_in_second_paragraph={"Learning","pointers","is","more","fun"};
  • The second sentence in the second paragraph could be represented as:
char**second_sentence_in_second_paragraph={"It","is","good","to","have","pointers"};
  • The second paragraph could be represented as:
char***second_paragraph={{"Learning","pointers","is","more","fun"},{"It","is","good","to","have","pointers"}};
  • Finally, the document could be represented as:
char****document={{{"Learning","C","is","fun"}},{{"Learning","pointers","is","more","fun"},{"It","is","good","to","have","pointers"}}};

Alicia has sent a document to her friend Teodora as a string of characters, i.e. represented by  not . Help her convert the document to  form by completing the following functions:

  •  to return the document represented by .
  •  to return the  paragraph.
  •  to return the  sentence in the  paragraph.
  •  to return the  word in the  sentence of the  paragraph.

Input Format

The first line contains the integer .
Each of the next  lines contains a paragraph as a single string.
The next line contains the integer , the number of queries.
Each of the next  lines or groups of lines contains a query in one of the following formats:

  • 1 The first line contains :

    • The next line contains an integer , the number of sentences in the  paragraph.
    • Each of the next  lines contains an integer , the number of words in the  sentence.
    • This query corresponds to calling the function .
  • 2 The first line contains :

    • The next line contains an integer , the number of words in the  sentence of the  paragraph.
    • This query corresponds to calling the function 
  • 3 The only line contains :

    • This query corresponds to calling the function 

Constraints

  • The text which is passed to the  has words separated by a space (" "), sentences separated by a period (".") and paragraphs separated by a newline("\n").
  • The last word in a sentence does not end with a space.
  • The last paragraph does not end with a newline.
  • The words contain only upper-case and lower-case English letters.
  •  number of characters in the entire document 
  •  number of paragraphs in the entire document 

Output Format

Print the paragraph, sentence or the word corresponding to the query to check the logic of your code.

Sample Input 0

2Learning C is fun.Learning pointers is more fun.It is good to have pointers.31 22562 1 143 1 1 1

Sample Output 0

Learning pointers is more fun.It is good to have pointers.Learning C is funLearning

Explanation 0

The first query corresponds to returning the second paragraph with  sentences of lengths  and  words.
The second query correspond to returning the first sentence of the first paragraph. It contains  words.
The third query corresponds to returning the first word of the first sentence of the first paragraph.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
Lock objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education