Counting number of sentences and words in text
Submissions: 188   Accuracy:


  Difficulty: Easy   Marks: 2

Given a text. The task is to count number of sentences and words in text. 

Definition of a sentence :- Sentences are defined as contiguous strings of characters ending in an  end of sentence punctuation (. ! or ?) or the last contiguous set of characters in the string, even if they don't end with a punctuation mark.

Definition of a word :- "Words" are defined as contiguous strings of alphabetic characters  i.e. any upper or lower case characters a-z or A-Z

The first line contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line which contains a text.

Corresponding to each test case, print space separated number of sentences and words.

1 <=T<= 100
0 <=  |text| <= 250

where |text| denoted the length of text


many??? Sentences are

1 1
0 0
2 3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Gaurav Miglani
Author: gaurav miglani

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.