Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: find words around a word in a file.

by Not_a_Number (Parson)
on Jul 28, 2011 at 18:09 UTC ( #917309=note: print w/ replies, xml ) Need Help??


in reply to find words around a word in a file.

Following GrandFather's advice:

use strict; use warnings; use Lingua::EN::Bigram; my $text = q{i ain't going home they are going school. sam isn't going to lunch. "Going going gone!" quoth the auctioneer}; my $ngrams = Lingua::EN::Bigram->new; $ngrams->text( $text ); my @trigrams = $ngrams->ngram( 3 ); for ( @trigrams ) { print "$_\n" if ( split )[1] eq 'going'; }

Output:

ain't going home are going school isn't going to . going going going going gone


Comment on Re: find words around a word in a file.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-09-21 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls