Page 1 of 1

Find the repeating words in a sentence

PostPosted: Sun Sep 20, 2015 10:49 am
by sparrrow
Suppose my input sentence is:

"My friends who live in California are good. The people who work in my team are good."

My output will be:

my is present 2 times
in is present 2 times
are is present 2 times
good is present 2 times


While doing it with UNSTRING, I need to how many words are there present in the sentence.
But my input is given by user. So I do not know while coding that how many words will be present in the input sentence.
Please help to achieve this...

Re: Find the repeating words in a sentence

PostPosted: Sun Sep 20, 2015 5:18 pm
by Robert Sample
I'm not sure UNSTRING is a good choice here. Your sample input has two delimiters -- space and period. What other delimiters are allowed -- such as comma, semicolon, colon, question mark, exclamation point? Your program should find the next delimiter, get the word from the input variable into a holding variable, and then look at the word array to see if you've already got that word in the array. If not, add it to the array (you'll need to track how many entries you have in your word array), then go find the next delimiter. If I were doing this, I'd probably make a copy of the input and make the copy all lower case so capitalization doesn't cause any issues (your sample has My and my but they are counted together even though they aren't the same in EBCDIC).

Re: Find the repeating words in a sentence

PostPosted: Mon Sep 21, 2015 4:25 am
by BillyBoyo
It is Master the Mainframe competition time, although that could be coincidence :-)

Re: Find the repeating words in a sentence

PostPosted: Mon Sep 21, 2015 12:14 pm
by enrico-sorichetti
in my books it is called cheating ...
in the master of mainframes rules and regulations it is clearly stated that ...

By entering this Contest, you represent and warrant to Sponsor that each of your entries:
(i) are your own original creation and are 100% original,
(ii) are solely and exclusively owned by you;
(iii) does not infringe on third party rights,
(iv) has not won previous awards or has been posted on another Web site prior to submission and
(v) is suitable for publication.

Re: Find the repeating words in a sentence

PostPosted: Mon Sep 21, 2015 2:25 pm
by BillyBoyo
When I challenged someone (elsewhere) previously, they replied that "you're allowed a mentor, and everyone else has a mentor. I have no mentor, so...". Anything actually in the rules on mentoring?

I like the "original" followed by "100% original" :-)

Re: Find the repeating words in a sentence

PostPosted: Mon Sep 21, 2015 10:36 pm
by prino
sparrrow wrote:Suppose my input sentence is:

"My friends who live in California are good. The people who work in my team are good."

My output will be:

my is present 2 times
in is present 2 times
are is present 2 times
good is present 2 times


No, "my" is present once, and "My" is present once.