User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 456,197 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,943 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 457 | Replies: 1
Reply
Join Date: May 2007
Posts: 5
Reputation: javageak is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
javageak javageak is offline Offline
Newbie Poster

Help sentenceCount and paragraphCount

  #1  
May 3rd, 2007
I need help in figuring out how to make the code for sentences by determining that there is ., ?, ! in the sentence at the end. And the paragraph where you find each paragraph by the spaces between the lines. If you could just help me start, I'll finish it...

scanner = new Scanner(new File("C://README.txt"));
while (scanner.hasNext())
{
String input = scanner.nextLine();
StringTokenizer tokenizer = new StringTokenizer(input);
charCount = charCount + input.length();
lineCount = lineCount + 1;

while (tokenizer.hasMoreTokens())
{
word = tokenizer.nextToken();
wordCount = wordCount + 1;


for( int i = 0; i < input.length(); i++ )
{
if( Character.isLetter(input.length()) == true )
{
charPerWordCount = charPerWordCount + 1;
}
}//end Character Per Word

for( int k = 0; k < input.length(); k++ )
{
if( Character.isWhitespace('\r') == true )
{
paragraphCount = paragraphCount + 1;
}
}// end Paragraph



}//end StringTokenizer
}// end Scanner
scanner.close();

// print out statistics
System.out.println( "Page count: " + lineCount/60 );
System.out.println( "Word count: " + wordCount );
System.out.println( "Line Count: " + lineCount );
System.out.println( "Character count: " + charCount );
System.out.println( "Character per word count: " + charPerWordCount );
System.out.println( "Sentence count: " + sentenceCount );
System.out.println( "Paragraph count: " + paragraphCount );
}
}//end TextFileStats.java

AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,832
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 324
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: sentenceCount and paragraphCount

  #2  
May 3rd, 2007
>If you could just help me start, I'll finish it..
So you have your ideas, now put them into practise.
... the hat of 'is this a cat in a hat?'
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 3:50 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC