Blame view
tools/PACKAGE_MESURES_V1.0/script/AssociateScoreToCtm.pl
1.81 KB
e6be5137b reinitialized pro... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
#!/usr/bin/perl -w # use strict; use Cwd; use warnings; if (@ARGV < 3) { print "<i: scores> <i: dossier res> <o: dossier align> "; exit 0; } my $RepRes=$ARGV[1]; my $RepAlign=$ARGV[2]; open SCORE, "$ARGV[0]" or die "impossible d'ouvrir $ARGV[0] "; opendir REP, $RepRes; my $currWorkDir = &Cwd::cwd(); chdir ($RepRes); my @ListRes=readdir(REP); closedir(REP); chdir($currWorkDir); my %Scores; my %MotsRef; foreach my $Ligne (<SCORE>) { $Ligne=~/(.*?\.res)_(.*?)_(.*?)_(.*?)\t(.*)/; if (! exists $Scores{$1}) { my %NewTable; my %NewTable2; $Scores{$1}=\%NewTable; $MotsRef{$1}=\%NewTable2; } my $mot = $4; my $sc = $5+0.0; my $time = $2*100; $time=int($time); $Scores{$1}->{$time}=$sc; $MotsRef{$1}->{$time}=$mot; #print "$1 : $time : $mot : $sc "; } close(SCORE); foreach my $FichierRes (@ListRes) { my $First=1; my $ZERO=0.0; if ($FichierRes=~/.*\.res$/) { open RES, "$RepRes/$FichierRes" or die "(res) impossible d'ouvrir $RepRes/$FichierRes "; open ALIGN, ">$RepAlign/$FichierRes" or die "(align) impossible d'ouvrir $RepAlign/$FichierRes "; #open ALIGN, ">to" or die "(align) impossible d'ouvrir $RepAlign/$FichierRes "; foreach my $Ligne (<RES>) { my $NotFound=1; chomp $Ligne; $Ligne=~/.*? .*? (.*?) .* ([^ ]+) ?$/; if ($First == 1) { $ZERO=$1*100; $ZERO=int($ZERO); } my $time=($1*100)-$ZERO; $time=int($time); $First=0; #print "----> $2 "; #print "a : $FichierRes "; for (my $i = -10; $i < 10 ; $i++) { my $tmp = $time+$i; if (exists $Scores{$FichierRes}->{$tmp} && $MotsRef{$FichierRes}->{$tmp} eq $2) { print ALIGN "$Ligne $Scores{$FichierRes}->{$tmp} "; $NotFound=0; last; } } if ($NotFound == 1) { print ALIGN "$Ligne 0.6 "; } } close RES; } } |