Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

funtion on array elements

by sarvan (Sexton)
on Sep 05, 2011 at 20:13 UTC ( [id://924292]=perlquestion: print w/replies, xml ) Need Help??

sarvan has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a array with set of elements. I want to send all the array elements to a funtion called stop word removal and get the words back in to the same array after stop word removal. The funtion take word one by one and removes stop words and returns it.

I said i have a module which actually does stop word removal. My prob is on array. I need to get the element of array and remove stop words and then send back the element to the same position.

For eg my arr is @array. it should have the same elements after stop-word removal, but stop-words wont be there.

Replies are listed 'Best First'.
Re: funtion on array elements
by Corion (Patriarch) on Sep 05, 2011 at 20:23 UTC

    I would review my course material. It is highly unlikely that your teacher asks you something that has not been extensively covered in the lessons and the course material.

    Personally, I would look at Stemmers on CPAN, and at perlfunc for the grep and map functions.

Re: funtion on array elements
by davido (Cardinal) on Sep 05, 2011 at 20:25 UTC

    So each element of the array is one word? Lingua::EN::StopWords

    use strict; use warnings; use Lingua::EN::StopWords qw/%StopWords/; my @words = qw/ .......whatever words you're testing...... /; @words = grep { !StopWords{$_} } @words;

    All credit to the module's POD. There's also Lingua::StopWords::EN, if the first module doesn't work out for you.

    Update: But Corion is probably right. Ask the professor. ;)


    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://924292]
Approved by JSchmitz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-20 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found