#!/usr#!/bin/perl < (motdroite-1,motdroite-2,...) # on n'ajoute qu'une seule occurrence des mots presents a droite mais on compte # la frequence d'un patron donne dans un tableau de patron #------------------------- open(F,$file); while (my $ligne=) { $ligne=~/([\wÆÁÂÀÅÃÄÇÇÇÐÉÊÈËÍÎÌÌÏÑÓÔÒØÕÖÞÚÛÙÜÝáâæàåãäçéêèðëíîìïñóôòøõößþúûùüýÿ]+)[^\wÆÁÂÀÅÃÄÇÇÇÐÉÊÈËÍÎÌÌÏÑÓÔÒØÕÖÞÚÛÙÜÝáâæàåãäçéêèðëíîìïñóôòøõößþúûùüýÿ]+([\wÆÁÂÀÅÃÄÇÇÇÐÉÊÈËÍÎÌÌÏÑÓÔÒØÕÖÞÚÛÙÜÝáâæàåãäçéêèðëíîìïñóôòøõößþúûùüýÿ]+)/; my $mot1=$1; my $mot2=$2; print "M1 : $mot1\n"; print "M2 : $mot2\n"; my $patron="$mot1\t$mot2"; if (!(exists($listeMot{$mot1}))) { my @tmp=(); push(@tmp,$mot2); $listeMot{$mot1}=\@tmp; # principale difficult de ce script : construction d'un rfrence vers un tableau print "FM : $listeMot{$mot1}\n"; $listePatron{$patron}++; } else { my $tmp=$listeMot{$mot1}; my @tmp2=@$tmp; if (!(grep(/$mot2/, @tmp2))) { push(@tmp2,$mot2); } $listeMot{$mot1}=\@tmp2; print "NM : $listeMot{$mot1}\n"; $listePatron{$patron}++; } } close(F); #print %listeMot,"\n"; #------------------------- # Partie 2 # A. Creation du fichier de sortie et squelette minimal # B. parcours du tableau des associations motgauche -> (motdroite-1,motdroite-2,...) # pour chaque motgauche on cree un noeud du graphe idem pour chaque mot de la liste associee # afin de ne pas creer de doublon on utilise un tableau contenant pour chaque mot son indice # on verifie dans ce tableau la presence ou non du mot a associer a un noeud #------------------------- open (F,">patron-graphml_tree.xml"); print F "\n"; print F "\n"; print F " \n"; print F " \n"; print F " \n"; my $id=1; my $listeId={}; while (($mot, $liste) = each(%listeMot)) { my @tmp=@$liste; print "$mot\t@tmp\n"; if ($mot !~/HASH/) { my $tmpID; if (!(exists($listeId{$mot}))) { print F " $mot\n"; $listeId{$mot}=$id; $tmpID=$id; $id++; } else { $tmpID=$listeId{$mot}; } foreach my $cible (@tmp) { my $nbpatron=0; $patron="$mot\t$cible"; $nbpatron=$listePatron{$patron}; if (!(exists($listeId{$cible}))) { print F " $cible\n"; $listeId{$cible}=$id; print F " $nbpatron\n"; $id++; } else { print F " $nbpatron\n"; } } } } print F " \n"; print F "\n"; close(F);