Mordan has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I am trying to get some expressions in the regex to print. I asked a related question to this and made a bit of a hash so starting afresh.
I am using tagger and want to be able to display the tags found in the regex.
$NUM = get_exp('cd'); $GER = get_exp('vbg'); $ADJ = get_exp('jj[rs]*'); $PART = get_exp('vbn'); $NN = get_exp('nn[sp]*'); $NNP = get_exp('nnp'); $PREP = get_exp('in'); $DET = get_exp('det'); $PAREN= get_exp('[lr]rb'); $QUOT = get_exp('ppr'); $SEN = get_exp('pp'); $WORD = get_exp('\p{IsWord}+');
I can display the text I input all tagged (code below), but what I want to do is display the count of tags. So like:
This code will output tagged text, but I can't seem to get it to tabulate the tags. My efforts, such as print $tag, print $GER and so on won't work.
Also I heard that tagger has problems accepting input from files rather than text in the coding, anyone else heard that?
#!/usr/bin/env perl use Lingua::EN::Tagger qw(add_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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to print variables in regex
by Kenosis (Priest) on Jan 20, 2014 at 23:22 UTC | |
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 | |
|
Re: Best way to print variables in regex
by jethro (Monsignor) on Jan 20, 2014 at 23:24 UTC | |
|
Re: Best way to print variables in regex
by tangent (Parson) on Jan 21, 2014 at 00:00 UTC | |
|
Re: Best way to print variables in regex
by Anonymous Monk on Jan 21, 2014 at 02:48 UTC |