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>
|
|---|