#!/usr/bin/perl use utf8; binmode STDOUT,":utf8"; # Programme d'extraction de patron # sur sortie Cordial # Usage : perl pg.pl cordialFile patrons #---------------------------------- open(FIC,"<:encoding(utf8)",$ARGV[0]); my $chaine=""; while (my $ligne=<FIC>) { # je veux voir la POS et le TOKEN # sous cette forme : POS_FORME chomp $ligne; # inutile a priori... if (($ligne=~/^([^\t]+)\t[^\t]+\t([^\t]+)$/) and ($ligne!~/PCTFORTE/)) { my $f=$1; my $c=$2; $f=~s/ /#/g; $chaine = $chaine . $c."_".$f." "; } else { #print $chaine; #$continu=<STDIN>; open(TERM,"<:encoding(utf8)",$ARGV[1]); while (my $terme=<TERM>) { chomp($terme); #comment transformer : NCMP ADJMP #en : NOM_([^ ]+) ADJ_([^ ]+) # pour ensuite cherche $terme dans $chaine $terme=~s/([^ ]+)/$1_\[\^ \]+/g; #print "TERME :", $terme,"\n"; # ou $terme=~s/(\w+)/$1_\\w\+/g ; while($chaine=~/($terme)/g) { #print "CORRESPONDANCE...\n"; my $correspondance=$&; $correspondance=~s/[A-Z0-9]+_//g; $correspondance=~s/#/ /g; print $correspondance,"\n"; } } close(TERM); #-------------------------------- # a la fin $chaine=""; } } print $chaine; close(FIC);