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";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|