Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Extracting common words

by Old_Gray_Bear (Bishop)
on Oct 22, 2015 at 22:41 UTC ( #1145700=note: print w/replies, xml ) Need Help??


in reply to Extracting common words

In Pseudo-Code:
open file1 loop over file 1 extract each $word $results{$word} = 1 end-loop close file1 open file2 loop over file2 extract each $word $results{$word" += 2 #### Note: '+=', not '=' end-loop close file2 ## ### %results contains all of the words in both files. ### Words that appear in both files will have a value of '3'. ### Iterate over the %results keys and print only the ### when the value is '3'. ##

----
I Go Back to Sleep, Now.

OGB

Replies are listed 'Best First'.
Re^2: Extracting common words
by BrowserUk (Pope) on Oct 22, 2015 at 23:08 UTC
    ## ### %results contains all of the words in both files. ### Words that appear in both files will have a value of '3'. ### Iterate over the %results keys and print only the ### when the value is '3'. ##

    If a word appears once in the first file and twice in the second, the value will 5; if it appears 3 times in the second file ...


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Extracting common words
by Anonymous Monk on Oct 22, 2015 at 23:39 UTC
    $results{$word" |= 2 #### Note: '|=', not '+=' and not '='

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-08-19 20:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (187 votes). Check out past polls.

    Notices?