#!/usr/bin/perl # CooccurrencesDansFenetre2IM.pl < . Cooccurrences Exemple : CooccurrencesDansFenetre2IM.pl PHILOLynx-dump-normaliseCordialLemmeCatBreve.ArticleEgalFenetre.index PHILOLynx-dump-normaliseCordialLemmeCatBreve.ArticleEgalFenetre.CoocMaxDistance20MinCooc3 5 > PHILOLynx-dump-normaliseCordialLemmeCatBreve.ArticleEgalFenetre.CoocMaxDistance20MinCooc5.IM Exemple d'appel : perl CooccurrencesDansFenetre2IM.pl PHILOLynx-dump-normaliseCordialLemmeCatBreveArticleEgalFenetre.Index PHILOLynx-dump-normaliseCordialLemmeCatBreveArticleEgalFenetre.CoocMaxDistance20MinCooc3 5 > PHILOLynx-dump-normaliseCordialLemmeCatBreveArticleEgalFenetreCoocMaxDistance20MinCooc5.IM Format de sortie : A faire : Bugs et problèmes : DOC $ChaineUsage = "Usage : CooccurrencesDansFenetre2IM.pl \n" ; if (@ARGV != 3) {die $ChaineUsage ; } $FichierIndex = $ARGV[0] ; $FichierCooccurrences = $ARGV[1] ; $CooccurrencePlancher = $ARGV[2] ; $Trace = 0 ; $Occurrences = 0 ; %Cooccurrent2Frequence = () ; if ($PourWindows == 0) { $FinLigne = "\n" ; } else { $FinLigne = "\r\n" ; } open(INDEX, $FichierIndex) ; # while ($LigneIndex = ){ if ($LigneIndex =~ /= $CooccurrencePlancher) { $Cooccurrent2Frequence{$Cooccurrent} = $Frequence ; if ($Trace == 1) {print "$Cooccurrent\t$Frequence\n" ; } } } } close(INDEX) ; imprimeEnTete() ; open(COOCCURRENCES, $FichierCooccurrences) ; # while ($LigneCooc = ){ if ($Trace == 1) {print $LigneCooc ; } if ($LigneCooc =~ /= $CooccurrencePlancher) { $FrequenceCooc1 = $Cooccurrent2Frequence{$Cooc1} ; $FrequenceCooc2 = $Cooccurrent2Frequence{$Cooc2} ; $ProbabiliteCofrequence = $Cofrequence / $Occurrences ; $ProbabiliteFrequenceCooc1 = $FrequenceCooc1 / $Occurrences ; $ProbabiliteFrequenceCooc2 = $FrequenceCooc2 / $Occurrences ; $InformationMutuelle = (log ($ProbabiliteCofrequence / ($ProbabiliteFrequenceCooc1 * $ProbabiliteFrequenceCooc2) ) / log 2) ; print "$FinLigne" ; } } } close(COOCCURRENCES) ; imprimeEnPied() ; sub imprimeEnTete{ print "$FinLigne$FinLigne" ; } sub imprimeEnPied{ print "$FinLigne" ; }