Thanks all, however I have the below observations.

John's version is not exact for heaves ,,, it has sashes which has two "s"
more than heaves.
Greg's  Porter Stemmer looks cool but may not  go deep. Example ... for
trace ..... I may also get rat , race , ate ,eat, crate, but he base word is
trace.

I am checking on this game http://games.yahoo.com/game/text-twist-2, that is
why I am looking at the algorithm to use to get this achieved.

Regards,
Emeka

On Thu, Mar 24, 2011 at 1:41 AM, John W. Krahn r<jwkr...@shaw.ca> wrote:

> Emeka wrote:
>
>> Hello All,
>>
>
> Hello,
>
>
>  I have a file containing dictionary of words ... I would like to play with
>> the file in this way.  Say I pick a word "Heaves" . I would like to find
>> other words that could be derive from
>> "Heaves"
>>
>> Have, Haves, eave , eaves, Has, see, eves and so on. I would not want to
>> use
>> brute force , I have an algorithm to speed things up. Can somebody help
>> me?
>>
>
> $ perl -lne'
> BEGIN {
>    $word     = lc "Heaves";
>    $pattern  = qr/\A[$word]{1,@{[ length $word ]}}\z/;
>    }
>
> print if lc =~ $pattern;
>
> ' /usr/share/dict/words  | cat -n
>     1  A
>     2  As
>     3  Ashe
>     4  Av
>     5  Ava
>     6  Ave
>     7  Aves
>     8  E
>     9  Es
>    10  Eva
>    11  Eve
>    12  H
>    13  Haas
>    14  He
>    15  Hess
>    16  Hesse
>    17  S
>    18  Sasha
>    19  Se
>    20  Shea
>    21  V
>    22  Va
>    23  a
>    24  ah
>    25  aha
>    26  ahas
>    27  as
>    28  ash
>    29  ashes
>    30  ass
>    31  asses
>    32  assess
>    33  e
>    34  ease
>    35  eases
>    36  eave
>    37  eaves
>    38  eh
>    39  es
>    40  eve
>    41  eves
>    42  h
>    43  ha
>    44  hah
>    45  hahs
>    46  has
>    47  hash
>    48  hashes
>    49  have
>    50  haves
>    51  he
>    52  heave
>    53  heaves
>    54  hes
>    55  s
>    56  sash
>    57  sashes
>    58  sass
>    59  sasses
>    60  save
>    61  saves
>    62  sea
>    63  seas
>    64  see
>    65  sees
>    66  sh
>    67  shah
>    68  shahs
>    69  shave
>    70  shaves
>    71  she
>    72  sheave
>    73  shes
>    74  v
>    75  vase
>    76  vases
>    77  vs
>
>
>
>
> John
> --
> Any intelligent fool can make things bigger and
> more complex... It takes a touch of genius -
> and a lot of courage to move in the opposite
> direction.                   -- Albert Einstein
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*Satajanus  Nig. Ltd


*

Reply via email to