File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Help with design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help with design" Watch "Help with design" New topic
Author

Help with design

pandu chinnu
Greenhorn

Joined: Nov 21, 2006
Posts: 16
Hi,

I am currently doing a project where in I have to create a gui which reads a text document and gives options to output :

1) the number of words in that document
2) number of words with 9 or more characters
3) top 10 frequent words in the document
4)Words which occur only once or occur twice in document

5) total number of paragraphs in the document and the average paragraph length in the document. (Paragraph length should include total words in a paragraph and total sentences in a paragraph)

6)total number of sentences in the document and the average sentence length in the word document.(Number of words in each sentence divided by total number of words in all sentences in the document)

7) Finally an option to search for a particular word.


Could someone help me with the design. How to go about it. I have already created the GUI. Iam able to read the document too.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

So what are you having problems with specifically?


GenRocket - Experts at Building Test Data
pandu chinnu
Greenhorn

Joined: Nov 21, 2006
Posts: 16
I have created a class with main method that creates a GUI.I have also created a WordCount Class and intend to create a class for each of the functionality. Now how do I create implement the word count in the main class?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
JTextArea has a read() method which will read/display the text document.

after the doc has been read in, pass the text via textArea.getText() to your
WordProgram to process.

Instead of the WordProgram displaying e.g. there are so many words etc,
store the data in variables (int wordCount etc)

in your gui, link the menu/toolbar/whatever buttons to those variables,
to display (probably in a JLabel) when clicked
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
[pandu chinnu: ]Now how do I create implement the word count in the main class?

I faced exactly the same problem earler, I got it going by reading the work of David Eck - and in fact there is already two java source code files that do exactly two of the things your post asks about.

David Eck's website is:

David J. EckDavid J. Eck. (Ph.D. in Mathematics, Brandeis University, 1980) Department of Mathematics and Computer Science Hobart and William Smith Colleges Geneva,

web address:

http://math.hws.edu/eck/

look for javanotes ..... Chapter 10: Generic Programming and Collection Classes

The trick, I almost never got over it, was to key the collection on the string (word) then keep a value in the map that represents how many times the word has been found in the document.

I had it stuck in the thoughts that a keyed collection had to key on a numeric such as an int, or convert anything it found into an int before it would work.

That is bad path.


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help with design
 
Similar Threads
Files
Paginating through text.
Guidance needed
Difference between sorted and ordered?
Word count problem.