• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Help with design

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what are you having problems with specifically?
 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[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.
reply
    Bookmark Topic Watch Topic
  • New Topic