I cant understand how this can be done..anyone can help me..

I have to take a text. Count all the words in the text. This is logical. What really confuses me is how the machine is going to make a difference between plural pronouns, personal pronouns,determiners because what I have to do is count them all and ofcourse just printout the amount of each.

Thanks in advance.

[323 byte] By [Jimbo_22a] at [2007-11-26 20:18:10]
# 1
Well, how do *YOU* tell if something is a personal pronoun?
jverda at 2007-7-10 0:41:35 > top of Java-index,Java Essentials,New To Java...
# 2

Perhaps you can create 2 String arrays. One that contains all the personal pronouns, and one with all of the Plural pronouns.

Then when you read all the words through the text, do a search on every word. If any of the words equals anything in either of the 2 arrays, then you can add 1 to a variable called for instance, pluralPro or personalPro.

There aren't many plural and personal pronouns. So it shouldn't be a horrid task. :)

Link to pronouns:

http://grammar.uoregon.edu/pronouns/personal.html

lethalwirea at 2007-7-10 0:41:35 > top of Java-index,Java Essentials,New To Java...
# 3

Yes,I got the poin but what I need is a model code, to write the program.

This is the original task:

Your program counts the words in each of the following categories

Category 1 (determiners) word count (wc1):

a, as, the, this, that, its, one, two, more, some; any numeric such as 21 or 1.234.

Category 2 (plural pronouns) word count (wc2):

they, them, those

Category 3 (conjunctives) word count (wc3):

for, with, in, and, not, when, if, unless, but

Category 4 (personal pronouns) word count (wc4):

I, you, she, their, myself, yourself, herself, us

Thank you,again..

Jimbo_22a at 2007-7-10 0:41:35 > top of Java-index,Java Essentials,New To Java...
# 4

> Yes,I got the poin but what I need is a model code,

> to write the program. This is the original task:

Just an idea which basically runs along the same idea of the Chain

Of Responsibilities Pattern; here's one 'Responsibility:public interface Responsibility {

boolean processed(String word);

Map<String, Integer> getStatistics();

}

If you feed a word to a Responsibility through its 'processsed' method,

it either did process it or not. If not, feed the word to a 'next' Responsibility.

When all words have been processed, ask each Responsibility for its

statistics (read: word count). Here's an example of a Responsibility

that can process plural nouns:public class PluralNouns extends HashMap<String, Integer> {

public PluralNouns() {

// prefill the map (there are much smarter ways to do this)

put("they, null);

put("them", null);

put("those", null);

}

//

public boolean processed(String word) {

if (!contains(word)) return false; // no one of ours.

Integer i= get(word);

if (i == null)

i= 0;

put(word, i+1);

return true; // yep, it was one of ours and count's been updated

}

//

public Map<String, Integer> getStatistics() {

return this; // much better stats can be retrieved here

}

}

Build all those different Responsibilities, stick them in a Collection and

for every word check if one of them considers the word 'processed'. If

so go on to the next word, if not ask the next Responsibility.

kind regards,

Jos

JosAHa at 2007-7-10 0:41:35 > top of Java-index,Java Essentials,New To Java...
# 5
Thank a lot man, I will try this one...Have a nice day...
Jimbo_22a at 2007-7-10 0:41:35 > top of Java-index,Java Essentials,New To Java...