Concept explainers
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:
- The first paragraph itself could be represented as:
- The first sentence in the second paragraph could be represented as:
- The second sentence in the second paragraph could be represented as:
- The second paragraph could be represented as:
- Finally, the document could be represented as:
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
Sample Output 0
Step by stepSolved in 4 steps with 5 images
- MySQL Workbench Will the following select statements work? If the queries don’t work, explain why and then correct them.a-) SELECT NAME, EMPLOYEE_ID, SALARYFROM EMPLOYEE_TBL E, EMPLOYEE_PAY_TBL EPWHERE EMPLOYEE_ID = EMPLOYEE_ID AND NAME LIKE '%MITH';b-) SELECT E.NAME, E.EMPLOYEE_ID, EP.SALARYFROM EMPLOYEE_TBL E, EMPLOYEE_PAY_TBL EPWHERE NAME LIKE '%MITH';c-) SELECT E.NAME, E.EMPLOYEE_ID, EP.SALARYFROM EMPLOYEE_TBL E, EMPLOYEE_PAY_TBL EPWHERE E.EMPLOYEE_ID = EP.EMPLOYEE_ID AND E.NAME LIKE '%MITH';d-) SELECT ENAME, COUNT(*)FROM EMPWHERE ENAME = '&NAME'ORDER BY ENAME;e-) SELECT DEPT_ID, COUNT(*)FROM EMPGROUP BY DEPT_IDHAVING ENAME='ALIYE';f-) SELECT F_NAME, L_NAMEWHERE F_NAME LIKE '%A'FROM EMP, DEPT;g-) SELECT NAME, SALARYFROM DEPT, EMPWHERE DEPT.ID = EMP.ID AND SUM(SALARY);arrow_forwardIn Android Studio, db is a SQLiteDatabase reference; sql is a String representing a delete SQL statement. Write a statement to execute that SQL statement.arrow_forwardPlease make sure you put the sqljdbc driver file under /Web-INF/lib folder to test. This is required for Webapplication to work with database. 1. Your regisLogin.jsp should ask user's ssn number (student's ssn) and move to validateLogin.java servlet.arrow_forward
- The Sqlite.py file contains several very specific queries: select_Query = "select sqlite_version()" delete_query = "DELETE from Database where id = "+str(id) sel = 'SELECT id FROM Database WHERE name == "{0}"'.format(value) insert_query = """INSERT INTO Database (id, name, photo, html) VALUES (?, ?, ?, ?)""" sqlite_select_query = """SELECT * from Database""" table_query = '''CREATE TABLE Database ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, photo text NOT NULL UNIQUE, html text NOT NULL UNIQUE)''' Write a QueryBuilder function. The QueryBuilder builds a generic Query to build ANY Query type (i.e. version, delete, select, insert, select, table). The QueryBuilder parameters require: The type of Query, the input tuple data and then constructs a query string based on the parameters.…arrow_forwardWhat’s the difference between the UNION and UNION ALL set operators?arrow_forwardThe InstantRide Driver Relationship team wants to learn how many travels each driver has done in the month of October. You need to send them the DRIVER_ID, and two calculated columns: DAY and RIDES. The DAY column is calculated using the DAY() function with the TRAVEL_START_TIME as the argument. The RIDES column is calculated by using the COUNT() function to determine the number of rides given for each day. Filter the results with the MONTH function.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