in reply to Re: hash comparison
in thread hash comparison

Hi marshall, Thanks for the code..

And one little modification i want to do on that.. Now it gives me all the words in both the candidate and reference and their counts.

But the output i look for is, i want to know only minimum count of candidate words among both candidate and reference..

for e.g if a word "the" appears 7 times in candidate and 2 times in reference. it should be able to get 2 as the min between two counts. like this for all the words in candidate alone..

please give me an idea how to do this. I will try

Thanks...

Replies are listed 'Best First'.
Re^3: hash comparison
by Marshall (Canon) on Jul 25, 2011 at 12:17 UTC
    Hi sarvan,
    I think that if you study the code, you will find that you have all that you need. The last "foreach" loop is on the fancy side of things, but it just loops over all of the unique keys in a special sort order. $cand_histogram{$key}||='0' uses 0 as the value in the case that there is no value for $cand_histogram{$key}. The print statement prints the 3 things that you need in order to calculate what you want. Why don't you give some code a try? Post your effort back here after you study it a bit.