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

Re: extract phrases of n-words length

by Polyglot (Monk)
on Jun 24, 2009 at 15:37 UTC ( #774431=note: print w/ replies, xml ) Need Help??


in reply to extract phrases of n-words length

I might do it something like this:

my $abstract = 'Perl is a high-level, general-purpose, interpreted, dynamic programming language.'; my $maxphraselength = 4; my $minphraselength = 2; my %phrasearray; my ($i,$offset); $abstract =~ s/\n|\r//g; for ($i=$minphraselength; $i<$maxphraselength; $i++) { for ($offset=0; $offset<$i; $offset++) { while ($abstract =~ /(\w+\W+){$offset}((\w+\W+){$i})/) { $phrasearray{$2}++; } } } foreach(keys %phrasearray){ print $_."\n"; } #sample output
Would that work?

Blessings,

~Polyglot~


Comment on Re: extract phrases of n-words length
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (18)
As of 2014-07-10 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (212 votes), past polls