open(FILE,"$ARGV[0]");

my @lignes=<FILE>;
close(FILE);
my %dicopatron=();
while (my $ligne=shift(@lignes)) {
    chomp $ligne;
    my $sequence="";
    my $longueur=0;
    if ( $ligne =~ /<element><data type=\"type\">NOM<\/data><data type=\"lemma\">[^<]+<\/data><data type=\"string\">([^<]+)<\/data><\/element>/) {
		my $forme=$1;
		$sequence.=$forme;
		$longueur=1;
		my $nextligne=$lignes[1];
		if ( $nextligne =~ /<element><data type=\"type\">ADJ<\/data><data type=\"lemma\">[^<]+<\/data><data type=\"string\">([^<]+)<\/data><\/element>/) {
			my $forme=$1;
			$sequence.=" ".$forme;
			$longueur=2;
		}
    }
    if ($longueur == 2) {
		$dicopatron{$sequence}++; 
    }
}
foreach my $patron (sort {$dicopatron{$b} <=> $dicopatron{$a}} (keys %dicopatron)) {
	print "$patron : $dicopatron{$patron}\n";
}
