in reply to Best way to print variables in regex
Perhaps the following will be helpful:
use strict; use warnings; use Lingua::EN::Tagger qw(add_tags); my %tags; my $postagger = new Lingua::EN::Tagger; my $text = "the quick brown fox jumped over the lazy dog"; my $tagged = $postagger->add_tags($text); print $tagged, "\n\n"; $tags{ uc $1 }++ while $tagged =~ m!<([^/]+?)>!g; print "$_: $tags{$_}\n" for sort keys %tags;
Output:
<det>the</det> <jj>quick</jj> <jj>brown</jj> <nn>fox</nn> <vbd>jumped< +/vbd> <in>over</in> <det>the</det> <jj>lazy</jj> <nn>dog</nn> DET: 2 IN: 1 JJ: 3 NN: 2 VBD: 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to print variables in regex
by Mordan (Initiate) on Jan 21, 2014 at 16:42 UTC | |
by tangent (Parson) on Jan 22, 2014 at 03:04 UTC | |
by Mordan (Initiate) on Jan 23, 2014 at 19:45 UTC | |
by tangent (Parson) on Jan 23, 2014 at 21:20 UTC |