Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: hash comparison

by sarvan (Sexton)
on Jul 25, 2011 at 10:41 UTC ( #916507=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://916507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2023-09-25 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?