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"). | [reply] |
If that is a question, can you show small code sample, complete with small input and word description of what counts you expect?
| [reply] |
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";
| [reply] [d/l] |