Showing 1 changed files with 14 additions and 5 deletions
+14 -5
renomme
... ...
@@ -81,18 +81,27 @@ cd $temp
81 81
 if [[ $nouveau = @(check|prox|leven) ]]; then
82 82
     unzip -qq "$manuscrit"
83 83
     for param in $(seq 4 $#); do
84
-        for dst in ins del rep; do
84
+        for dst in ins del rep max; do
85 85
             eval "if test -n '\$$param' && [[ \"\$$param\" =~ $dst=[0-9]+ ]]; then cost_$dst=\${$param#*=}; fi"
86 86
         done
87 87
     done
88
+    for dst in ins del rep; do
89
+        eval "cost_$dst=\${cost_$dst:-1}"
90
+    done
91
+    cost_max=${cost_max:-$(($cost_ins + $cost_del + $cost_rep))}
92
+    if test $cost_max -ge ${#ancien}; then
93
+        cost_max=$(( ${#ancien} - 1 ))
94
+    fi
95
+
88 96
     echo paramètres d\'approximation
89
-    echo "caractère manquant (del=): ${cost_del:-1}"
90
-    echo "caractère inséré   (ins=): ${cost_ins:-1}"
91
-    echo "caractère remplacé (rep=): ${cost_rep:-1}"
97
+    echo "caractère manquant (del=): $cost_del"
98
+    echo "caractère inséré   (ins=): $cost_ins"
99
+    echo "caractère remplacé (rep=): $cost_rep"
100
+    echo "distance maximale  (max=): ${cost_max:-$(($cost_ins + $cost_del + $cost_rep))}"
92 101
     for f in $(find . -type f); do
93 102
         let wc+=$(wc -w < $f)
94 103
     done
95
-    awk -v ancien=$ancien -v wc=$wc -v cost_ins=${cost_ins:-1} -v cost_del=${cost_del:-1} -v cost_rep=${cost_rep:-1} '
104
+    awk -v ancien=$ancien -v wc=$wc -v cost_ins=$cost_ins -v cost_del=$cost_del -v cost_rep=$cost_rep -v cost_max=$cost_max '
96 105
         BEGIN {
97 106
             RS="[[:punct:]]"
98 107
             progress_mod    = 10