0

我有一个单词列表,我想根据它们是否是动词/形容词/名词/等将它们分成不同的组。所以,基本上我正在寻找一个 Perl 模块,它告诉一个单词是否是动词/名词等。

我用谷歌搜索,但找不到我要找的东西。谢谢。

4

3 回答 3

1

请参阅CPAN 中的 Lingua::EN:: 命名空间。具体来说,Link GrammarLingua::EN::Tagger可以帮助你。WordNet 也提供了这种信息,您可以使用这个 perl 模块来查询它。

于 2012-07-12T12:54:19.977 回答
1

Lingua::EN::Tagger , Lingua::EN::Semtags::Engine , Lingua::EN::NamedEntity

于 2012-07-12T12:56:45.237 回答
0

按照代码 perl 帮助您在文件夹中的文本文件中找到所有这些东西只给出目录的路径,它将一次处理所有文件并将结果保存在 report.txt 文件中强文本

    #!/usr/local/bin/perl

# for loop execution



# Perl Program to calculate Factorial
sub fact
{

# Retriving the first argument
# passed with function calling
my $x = $_[0];
my @names = @{$_[1]};
my $length = $_[2];

# checking if that value is 0 or 1
if ($x < $length)
{
#print @names[$x],"\n";

 use Lingua::EN::Fathom;
 my $text = Lingua::EN::Fathom->new();

 # Analyse contents of a text file
 $dirlocation="./2015/";
 $path =$dirlocation.$names[$x];

 $text->analyse_file($path); # Analyse contents of a text file

 $accumulate = 1;
 # Analyse contents of a text string
 $text->analyse_block($text_string,$accumulate);
  # TO Do, remove repetition

 $num_chars             = $text->num_chars;
 $num_words             = $text->num_words;
 $percent_complex_words = $text->percent_complex_words;
 $num_sentences         = $text->num_sentences;
 $num_text_lines        = $text->num_text_lines;
 $num_blank_lines       = $text->num_blank_lines;
 $num_paragraphs        = $text->num_paragraphs;
 $syllables_per_word    = $text->syllables_per_word;
 $words_per_sentence    = $text->words_per_sentence;

# comment needed
 %words = $text->unique_words;
 foreach $word ( sort keys %words )
 {
#   print("$words{$word} :$word\n");
 }

 $fog     = $text->fog;
 $flesch  = $text->flesch;
 $kincaid = $text->kincaid;
 use strict;
 use warnings;
 use 5.010;

    my $filename = 'report.txt';
    open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
    say $fh $text->report;
    close $fh;
    say 'done';
    print($text->report);

    $x = $x+1;
    fact($x,\@names,$length);
}

# Recursively calling function with the next value
# which is one less than current one
else
{
    done();
}
}

# Driver Code
$a = 0;
@names = ("John Paul", "Lisa", "Kumar","touqeer");
opendir DIR1, "./2015" or die "cannot open dir: $!";
my @default_files= grep { ! /^\.\.?$/ } readdir  DIR1;
$length = scalar @default_files;
print $length;
# Function call and printing result after return
fact($a,\@default_files,$length);

sub done
{
    print "Done!";
}
于 2019-09-21T07:33:06.830 回答