Home > Archive > PERL Beginners > October 2006 > Stemming words
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi all,
I am a beginner in perl. I am trying to write some code to stem words
in a given senstence. I have installed the module Lingua::Stem....donno
if it got installed??
when I run the below code, it prints out the Array(0x1834430) instaed
of root words.
Is there any bug in my code?? Please help me out with this...Thnaks
#!/usr/local/bin/perl -w
use Lingua::Stem;
my @words =("doing","done","cats"); # # input
words, prints fine
print "@words";
my $stemmer = Lingua::Stem->new({-locale => 'EN-US'});
$stemmer->stem_caching({ -level => 2 });
my @array = $stemmer->stem(@words);
print "@array"; ## print root words. prints ARRAY(0x1834430)
intstead of root words
| |
| Paul Lalli 2006-10-05, 6:58 pm |
| sj wrote
> I am a beginner in perl. I am trying to write some code to stem words
> in a given senstence. I have installed the module Lingua::Stem....donno
> if it got installed??
If it hadn't, Perl would have told you as soon as you tried to run the
program "Cannot locate Lingua/Stemp.pm in @INC....".
> when I run the below code, it prints out the Array(0x1834430) instaed
> of root words.
>
> #!/usr/local/bin/perl -w
You forgot:
use strict;
> use Lingua::Stem;
>
> my @words =("doing","done","cats"); # # input
> words, prints fine
> print "@words";
> my $stemmer = Lingua::Stem->new({-locale => 'EN-US'});
> $stemmer->stem_caching({ -level => 2 });
> my @array = $stemmer->stem(@words);
> print "@array"; ## print root words. prints ARRAY(0x1834430)
> intstead of root words
Without knowing anything about this module, I'm guessing that the
stem() method returns a reference to an array, rather than an actual
array. Change your code to:
my $arr_ref = $stemmer->stem(@words);
print "@$arr_ref\n";
Paul Lalli
| |
|
|
sj wrote:
> Hi all,
>
> I am a beginner in perl. I am trying to write some code to stem words
> in a given senstence. I have installed the module Lingua::Stem....donno
> if it got installed??
>
> when I run the below code, it prints out the Array(0x1834430) instaed
> of root words.
> Is there any bug in my code?? Please help me out with this...Thnaks
>
>
> #!/usr/local/bin/perl -w
> use Lingua::Stem;
>
> my @words =("doing","done","cats"); # # input
> words, prints fine
> print "@words";
> my $stemmer = Lingua::Stem->new({-locale => 'EN-US'});
> $stemmer->stem_caching({ -level => 2 });
> my @array = $stemmer->stem(@words);
> print "@array"; ## print root words. prints ARRAY(0x1834430)
> intstead of root words
Look at the documentation for the stem method. It returns a scalar, not
an array, that
is a reference to an array.
see 'perldoc perlref'
Ken
|
|
|
|
|