Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 taking refuge in the Monastery: (7)
As of 2014-08-22 03:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (146 votes), past polls