in reply to Re^2: Installing Lingua BrillTagger
in thread Installing Lingua BrillTagger

If that is a question, can you show small code sample, complete with small input and word description of what counts you expect?

Replies are listed 'Best First'.
Re^4: Installing Lingua BrillTagger
by Mordan (Initiate) on Jan 20, 2014 at 11:37 UTC

    Thanks. So using Lingua::EN::Tagger code below I can get the output of a file all tagged. But I still can't work out how just to display the tags.

    Looking at the .pm file I cannot see an obvious way for it to output, say, <NN> : 2, <CC> : 5 and so on. I can only see subs to add_tag to text, not just to display them.

    #!/usr/bin/env perl use Lingua::EN::Tagger qw(add_tags); my $postagger = new Lingua::EN::Tagger; my $file = "test.txt"; my $text = do { local $/ = undef; open my $fh, "<", $file or die "could not open $file: $!"; <$fh>; }; my $tagged = $postagger->add_tags($text); print $tagged, "\n";

      Here you go

      #!/usr/bin/perl -- ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" use strict; use warnings; use Data::Dump qw/ dd /; use Lingua::EN::Tagger ; Main( @ARGV ); exit( 0 ); sub Main { my $text = q{ If that is a question, can you show small code sample, complete with small input and word description of what counts you expect? Now <brackets> here :/ }; my $postagger = Lingua::EN::Tagger->new; my $tagged = $postagger->add_tags($text); #~ dd( $postagger, $tagged ); #~ dd ( map { [ $_, $postagger->$_( $text ) ] } qw{ get_words get_ +readable get_sentences } ); #~ dd ( map { [ $_, $postagger->$_( $tagged ) ] } qw{ get_proper_n +ouns get_nouns get_max_noun_phrases get_noun_phrases } ); dd( scalar $postagger->get_tag_counts( $tagged ) ); } ## end sub Main sub Lingua::EN::Tagger::get_tag_counts { #~ my( $self, $tagged ) = @_; my %counts; $counts{$1}++ while $_[1] =~ m{<([^>/]+)>}g; return wantarray ? %counts : \%counts; } __END__ { cc => 1, det => 2, in => 3, jj => 3, md => 1, nn => 6, pp => 1, ppc => 2, prp => 2, rb => 2, sym => 1, vbp => 2, vbz => 2, wp => 1, }
        Thank you!