#/usr/bin/perl
use utf8;
binmode STDOUT,":utf8";

open(FICHIER,"<:encoding(utf8)",$ARGV[0]) or die $!;
my $chaine="";

while (my $ligne=<FICHIER>){
	chomp $ligne; #a priori inutile

	if (($ligne=~/^([^\t]+)\t[^\t]+\t([^\t]+)$/) and ($ligne!~/PCTFORTE/)){
		my $forme=$1; 
		$forme=~s/ /#/g;
		$chaine=$chaine.$POS."_".$forme." "; 
	}	
	else{
		
		open(PATRONS,"<:encoding(utf8)",$ARGV[1]); 
		while (my $motif=<PATRONS>){ 
			chomp($motif); 
			$motif=~s/([^ ]+)/$1_\[\^ \]\+/g; 
			print $moti;
			
			while($chaine=~/($motif)/g){ 
				my $correspondance=$&; 
				$correspondance=~s/[A-Z]+\d?[A-Z]?_//g; 
				$correspondance=~s/#/ /g; 
				
				print $correspondance,"\n";
			}
		}		
		
		$chaine="";
		}
}
close(FICHIER);
exit;