Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Unpredictable output form Text::ExtractWords

by epoptai (Curate)
on Aug 16, 2005 at 15:37 UTC ( #484174=note: print w/ replies, xml ) Need Help??


in reply to Unpredictable output from Text::ExtractWords

Lingua::EN::Splitter to the rescue:

#!/usr/bin/perl use strict; use warnings; use Lingua::EN::Splitter; my @strings = ( q|one two 'three'|, q|yes I am 'me'|, ); my %config = ( minlen => 3, maxlen => 32, locale => "en_US.ISO_8859-1", ); my $split = Lingua::EN::Splitter->new; my %count; for my $str (@strings){ print "$str\n"; my $words = $split->words($str); $count{$_}++ for @$words; for my $word (sort @$words) { $_ = length $word; next if $_ < $config{minlen} or $_ > $config{maxlen}; print $word, ' -> ', $count{$word}, "\n" } print '-' x 10, "\n"; } __END__ Output: one two 'three' one -> 1 three -> 1 two -> 1 ---------- yes I am 'me' yes -> 1

--
perl -MO=Deparse -e"u j t S n a t o e h r , e p l r a h k c r e"


Comment on Re: Unpredictable output form Text::ExtractWords
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://484174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2015-07-05 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls