Twisting Text

--bcaec51d29f2fdb131049f2dfabb
Content-Type: text/plain; charset=ISO-8859-1

Hello All,

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?

Regards,
Emeka
--
*Satajanus Nig. Ltd


*

--bcaec51d29f2fdb131049f2dfabb--
Emeka [ Mi, 23 März 2011 23:35 ] [ ID #2057047 ]

Re: Twisting Text

--000e0cdfda24d81504049f2f86c5
Content-Type: text/plain; charset=UTF-8

Emeka,

What you are looking for is a word stemmer. You might want to take a look
at something like Porter Stemmer.

-Greg


On Wed, Mar 23, 2011 at 5:35 PM, Emeka <emekamicro [at] gmail.com> wrote:

> Hello All,
>
> 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?
>
> Regards,
> Emeka
> --
> *Satajanus Nig. Ltd
>
>
> *
>

--000e0cdfda24d81504049f2f86c5--
Greg J [ Do, 24 März 2011 01:26 ] [ ID #2057088 ]

Re: Twisting Text

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, [at] {[ 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-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
jwkrahn [ Do, 24 März 2011 01:41 ] [ ID #2057089 ]

Re: Twisting Text

--90e6ba1eeed44f2453049f37a515
Content-Type: text/plain; charset=ISO-8859-1

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<jwkrahn [at] 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, [at] {[ 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-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>


--
*Satajanus Nig. Ltd


*

--90e6ba1eeed44f2453049f37a515--
Emeka [ Do, 24 März 2011 11:07 ] [ ID #2057094 ]
Perl » gmane.comp.lang.perl.beginners » Twisting Text

Vorheriges Thema: shift oo
Nächstes Thema: Re: Re:must 'x' in g^x be a prime number