Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Junk NOT words

by BrowserUk (Pope)
on Oct 30, 2002 at 19:24 UTC ( #209202=note: print w/ replies, xml ) Need Help??


in reply to Junk NOT words

This is a little crude, but given a less eclectic words file than the one I have, it might do better. In any case, it shouldn't be too hard to come up with a heuristic for making the decision, possibly based on the number or proportion of 1 and 2 character words or the average word length for example.

This code

#! perl -sw use vars qw($debug); use strict; local $\=$/; sub IsWord { no warnings; return if not @_ or length == 1; my ($word, $first, $c2n3) = $_[0] =~ /^((.)(..?)?.*)$/; $c2n3 = substr( $c2n3 . '__', 0, 2); local $_ = do{ local (@ARGV,$/) = "c:/test/words/$first/$c2n3"; <> + }; return /^$word$/im; } while(<DATA>) { chomp(my $phrase = $_); my $c= - length $phrase; my @words; while (length $phrase) { my $bit = substr($phrase, $c); if (IsWord($bit)) { unshift @words, $bit; $phrase = substr($phrase, 0, $c); $c = - length $phrase; } else { ++$c; last if 0 == (length($phrase)- $c); } } print "${_}may consist of the words\n@words\n"; } __END__ hudjheuhfnnvgxvbchnfhfujryyfgbch whererangesarealltherage thequickbrownfoxjumpsoverthelazydog hsdkjfhuewfklJLKSDossfdlkjaslduasl PeterPiperPickedAPeckOfPickledPepper lazinessimpatiencehubris

Gives

C:\test>209141 hudjheuhfnnvgxvbchnfhfujryyfgbch may consist of the words hu dj he uhf n nv g xv bch n f h fu j ry y f g bch whererangesarealltherage may consist of the words where range sare all the rage thequickbrownfoxjumpsoverthelazydog may consist of the words the quick brown fox jumps over the lazy dog hsdkjfhuewfklJLKSDossfdlkjaslduasl may consist of the words hs dk j f hu ew f kl J L KS Doss f d l k jas l du as l PeterPiperPickedAPeckOfPickledPepper may consist of the words Peter Piper Pick edA Peck Of Pickled Pepper lazinessimpatiencehubris may consist of the words laziness impatience hubris C:\test>

Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy


Comment on Re: Junk NOT words
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (19)
As of 2014-07-23 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (145 votes), past polls