Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: word association problem

by Chmrr (Vicar)
on Aug 06, 2002 at 03:58 UTC ( #187919=note: print w/ replies, xml ) Need Help??


in reply to Re: word association problem
in thread word association problem

Looks like this will nearly do the trick, but not quite. The main problem with this is that, contrary to the details above, this will include "accumbering" in the "accumb:" line. Hence, we need to start from the longest master words, and remove words from the wordlist as they match. We can also get a slight speedup by using index instead of a regex.

#!/usr/bin/perl -w use strict; open(LIST, "wordlist.txt") or die "$!"; my @wordlist = map { chomp; $_ } <LIST>; close LIST; open(MSTR, "master.txt") or die "$!"; my @master = sort {length $b <=> length $a} map { chomp; $_ } <MSTR>; close MSTR; foreach my $word ( @master ) { my @matches; for (@wordlist) { next unless defined $_ and index($_, $word) >= 0; push @matches, $_; $_ = undef; } $word = [$word, join(", ",@matches)]; } print map {"$_->[0]: $_->[1].\n"} sort {$a->[0] cmp $b->[0]} @master;

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'


Comment on Re: Re: word association problem
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-21 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls