Mordan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks! Can you help? I have searched the web and read the readme but just cannot get Lingua Brill Tagger to install.

there is something about installing the patch but I cannot do this. All new to Perl and the readme just isn't clear enough for a newbie like me. I am using a Mac and have searched and tried a few methods before asking this question.

Replies are listed 'Best First'.
Re: Installing Lingua BrillTagger
by Anonymous Monk on Jan 20, 2014 at 02:41 UTC
      Thank you superdoc, I would have kept trying if you hadn't said! LinguaTagger is okay but I am having problems getting the tag output out. I can get the tagged sentence out from it, just not the count of indiviudal tags (so like "<NN> = 2").
        If that is a question, can you show small code sample, complete with small input and word description of what counts you expect?
Re: Installing Lingua BrillTagger
by tangent (Parson) on Jan 20, 2014 at 23:39 UTC
    I couldn't find a way to count the tags just using the Tagger module, but as the tagged text is in an XML style you could use an XML parser - this example uses XML::LibXML. I initially tried to use Text::Balanced but had to give up as I couldn't work out how to extract multiple variable tags. You will need a full list of the tags which you can build from the Tagger README document.
    use strict; use warnings; use Data::Dumper; use XML::LibXML; use Lingua::EN::Tagger qw(add_tags); my $text = <<'EOT'; The set of POS tags used here is a modified version of the Penn Treebank tagset. Tags with non-letter characters have been redefined to work better in our data structures. EOT my $tagger = Lingua::EN::Tagger->new; my $tagged = $tagger->add_tags($text); my $tree = XML::LibXML->load_xml(string => "<doc>$tagged</doc>"); my @tags = qw(CC DET NN NNP RB VBZ); # add the rest my %count; for my $tag (@tags) { my $lctag = lc($tag); # lowercase tag name my @nodes = $tree->findnodes("//$lctag"); $count{$tag} = scalar @nodes; } print Dumper(\%count); for my $tag (sort keys %count) { print "$tag:\t$count{$tag}\n"; }
    Output:
    $VAR1 = { 'CC' => 0, 'VBZ' => 1, 'RB' => 2, 'NNP' => 3, 'NN' => 4, 'DET' => 3 }; CC: 0 DET: 3 NN: 4 NNP: 3 RB: 2 VBZ: 1