Hi all,
I'm a newbie.
I'm tryin to do an exercice but there's something that isn't working yet.
I've a text and I would like to do the analysis of it. The text is in french language.
"viens demain de bon matin"
I would like to analyse the text creating some arrays with the endings. In some cases endings are in common (for example "ain" is an adjectival and nominal ending at the same time, so "demain" will be displayed as "demain NOM ADJ").
How can I do this?
I'll put my code.
I'd like to have this output :
viens
me
trouver
demain ADJ NOM
de
bon
matin
I'm a newbie.
I'm tryin to do an exercice but there's something that isn't working yet.
I've a text and I would like to do the analysis of it. The text is in french language.
"viens demain de bon matin"
I would like to analyse the text creating some arrays with the endings. In some cases endings are in common (for example "ain" is an adjectival and nominal ending at the same time, so "demain" will be displayed as "demain NOM ADJ").
How can I do this?
I'll put my code.
Perl:
#!/usr/bin/perl
use warnings;
use diagnostics;
use Data::Dumper;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 0;
#scalars and arrays
my ($m, $file, $suf_adv, $line);
my (@suf_nom, @suf_adj, @suf_verb);
my %punt;
@suf_nom = qw(ard ain);
@suf_adj = qw(eux ain);
@suf_verb = qw(est iser ifier eter iller ouiller);
$suf_adv = "ment" ;
%punt = (
' ' => 1,
'' => 1,
',' => 1,
"'" => 1,
'.' => 1,
'?' => 1,
';' => 1,
'!' => 1,
'-' => 1,
':' => 1,
'?' => 1
);
$line = "viens me trouver demain de bon matin, ... \n";
@words = split (/(\pP|\pS|\s)/, $line);
foreach $w(@words) {
if ($w =~ m/$suf_nom[$_]/ and length($w) >= 6 and !exists $punt{$w}) {
print "$w NOM\n";
}
elsif ($w =~ m/$suf_adj[$_]/ and length($w) >= 6 and !exists $punt{$w}) {
print "$w ADJ\n";
}
elsif ($w =~ m/$suf_verb[$_]/ and length($w) >= 6 and !exists $punt{$w}) {
print "$w V\n";
}
else {
print "NC\n";
}
}
I'd like to have this output :
viens
me
trouver
demain ADJ NOM
de
bon
matin