-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvectoriel.pl
executable file
·54 lines (47 loc) · 1.13 KB
/
vectoriel.pl
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
#!/usr/bin/perl -w
use strict;
use warnings;
use open qw(:std :utf8);
if($#ARGV+1 != 2){
print "Vous devez renseigner les deux arguments\n $0 input.stem output.mat\n";
exit(0);
}
open(FILER,"<$ARGV[0]") or die("Fichier introuvable ou Impossible d'ouvrir le fichier en lecture");
open(FILEW,">$ARGV[1]") or die("Fichier introuvable ou Impossible d'ouvrir le fichier en ecriture");
my (%matrice,%M,@words,$word,$nb_ligne,$exist);
my($c,$v,$i,$d,$w,$e,$x);
while( defined( my $row = <FILER> ) ) {
chomp($row);
@words = split(' ',$row);
foreach $word (@words){
$matrice{$word}{$.}++;
$M{$word}++;
}
$nb_ligne = $.;
}
close(FILER);
for($i=1;$i<=$nb_ligne;$i++){
while (($c,$v) = each(%matrice)) {
while (($d,$w) = each($v)){
if($d==$i){
if($w==1){
$exist = 0;
while(($e,$x) = each(%M)){
if($c eq $e){
if($x<=1){
$exist = 1;
}
}
}
if($exist == 0){
print(FILEW "$i\t$c\t$w\n");
}
}
else{
print(FILEW "$i\t$c\t$w\n");
}
}
}
}
}
close(FILEW);