Click here to Skip to main content
15,887,946 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
At the beginning a number N will be given. N number of paragraphs will follow. For each paragraph you have to find the following:
i) How many articles (grammatical meaning implied) of each type are there in the paragraph. That means how many 'a', how many 'an' and how many 'the'
ii) How many date information is there in the paragraph. (A date for this task is defined as one which has the information of all the components- date, month and year). Be aware that a date can be expressed in different ways: 12/07/2014, 06/31/2014, 6-31-2014, 15 July, 2014, 15 Jul 2014, 15th July 2014, 15th of July 2014, December 15, 2015 etc....the more variety you can handle the more accurate your result will be

Example input:

3
The French Revolution was a period of far-reaching social and political upheaval in France that lasted from 1789 until 1799, and was partially carried forward by Napoleon during the later expansion of the French Empire.
Dehradun is the capital city of the state of Uttarakhand in the northern part of India. Located in the Garhwal region, it lies 236 kilometres (147 miles) north of India's capital New Delhi.
The Indian general election of 2014 was held to constitute the 16th Lok Sabha, electing members of parliament for all 543 parliamentary constituencies of India. Running in nine phases from 7 April 2014 to 12 May 2014, it was the longest election in the country's history. According to the Election Commission of India, 814.5 million people were eligible to vote, with an increase of 100 million voters since the last general election in 2009, making it the largest-ever election in the world.

The output will be:

1,0,3,0
0,0,4,0
0,1,8,2

Explanation: The first paragraph (on French revolution) has 1 occurrence on ‘a’, 0 occurrence of ‘an’, ‘3’ occurrences of ‘the’ and 0 occurrences of ‘date information.’ Same for other two paragraphs.

What I have tried:

i have not tried much...got too less time to try anything
Posted
Updated 2-May-16 15:37pm
Comments
Patrice T 2-May-16 13:09pm    
Start working !
Sergey Alexandrovich Kryukov 2-May-16 14:50pm    
5!—SA
nv3 2-May-16 13:58pm    
You know, I always wanted to do someone else's homework. I am so glad you posted this question. Otherwise I would not know what to do with my time. And what a great coincidence that you yourself don't find the time for it. So I will start right away getting it done for you ... Is that the kind of response you were expecting?
Patrice T 2-May-16 15:09pm    
But do you also plan to give him the full blow up solution ?
Sergey Alexandrovich Kryukov 2-May-16 14:52pm    
Sarcasm aside, we cannot deal with non-questions.
If this description is your homework assignment, it looks like you decided to fail your education. It's easier than you may think.
—SA

If time is short, you had better get moving fast then. Otherwise you will have nothing to hand in...
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
As with any other programming task you need to divide the problem into smaller pieces.

1. Split up the text into paragraphs.
You already know there are 3 of them, but you need to find out what separates the paragraphs.
Have a look at a dot (.) followed by a line feed (\n) or carriage return + line feed (\r\n).
Here strtok()[^] could be used.

2. Now you can use a loop and search through each paragraph for your key words.
You can use strstr()[^] in a loop until the function returns NULL.
Do this for each keyword.

Hint. Don't look for the letter 'a' only, look for " a " (spaces on each side).

Using Regular Expressions would solve this problem in a breeze, but that is probably a bit too advanced.

This should help you getting started.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900