l10n-check 0.2.1
Bonjour,
après une utilisation intensive avec le ddts, voici quelques
corrections.
journal des modification :
version 0.2.1
- add: `$word_regex' config variable to define words for ispell
- bug fix:
- add: keep only 25 choices in choose menu
- add: re-parse line only if a change has been made when checking rules
- change: set next match after last word if no change has been made when
checkin spelling
Il faut ajouter la ligne suivante dans votre .l10n-check :
$word_letters = "a-zÂâÀàÉéÊêÈèËëÎîÏïÔôÛûÙùÜüÇç'-"; # letters used to define a word for ispell (this is for french)
La rustine est attachée, le scritp complet ici :
http://perso.wanadoo.fr/nico.bertol/l10n-check/l10n-check.txt
J'ai aussi attaché le nouveau fichier de règles communes dans lequel
j'ai supprimé ce qui concerne ispell et n'est plus nécessaire.
Nicolas
--
--- l10n-check_0.2.txt Sat Jan 19 19:55:09 2002
+++ l10n-check_0.2.1.txt Sun Jan 20 17:25:30 2002
@@ -44,6 +44,7 @@
$debug, # = 0;
$ispell, # = "yes";
$dictionary, # = "francais";
+ $word_letters, # = "a-zÂâÀàÉéÊêÈèËëÎîÏïÔôÛûÙùÜüÇç'-";
$review, # = "no";
$highlight_text_color, # = $TEXT_COLORS{'normal'}.$TEXT_COLORS{'red_h'};
$comment_text_color, # = $TEXT_COLORS{'normal'}.$TEXT_COLORS{'cyan'};
@@ -53,12 +54,12 @@
# Read the config file
my $config = $ENV{HOME}."/.l10n-check"; # config file
die("You must define \$rules_dir, \$rules_e, \$bak_e, \$debug, \$ispell, \$dictionary,\n"
- ."\$review, \$highlight_text_color, \$comment_text_color, \$letter_color Perl\n"
- ."variables in \$HOME/.l10n-check\n") unless -r $config;
+ ."\$word_letters, \$review, \$highlight_text_color, \$comment_text_color,\n"
+ ."\$letter_color Perl variables in \$HOME/.l10n-check\n") unless -r $config;
scalar eval `cat $config`; # get the variables
# Test if variables are defined
-foreach (qw(rules_dir rules_e bak_e debug ispell dictionary review
+foreach (qw(rules_dir rules_e bak_e debug ispell dictionary word_letters review
highlight_text_color comment_text_color letter_color)) {
eval "\$config=\$$_";
suicide("\$$_ not defined in \$HOME/.l10n-check") unless ($config ne "");
@@ -102,7 +103,7 @@
# 'post_insert' => [ post_insert0, ...],
# 'post_fix' => [ post_fix0, ... ] },
# ... }
-my $version = "0.2";
+my $version = "0.2.1";
# Test if configuration as been made
my @dir=split("/", $rules_dir); # get all subdirs
@@ -240,6 +241,8 @@
my @choices = @{ (shift) };
my $align = shift;
+ @choices = @choices[0..(@choices<25?@choices-1:24)];
+
debug 3, "choose correction";
my $letter = "a"; # letter counter for choice
@@ -333,16 +336,18 @@
my @choices; # fix choices
push (@choices, ($pos eq "pre_")?"$_$c":"$c$_") foreach @{ $Rules->{$item}{$pos.'insert'} };
push (@choices, "$_") foreach @{ $Rules->{$item}{$pos.'fix'} };
+ my $hint = $Rules->{$item}{$pos.'hint'};
my $save = pos $line; # save last match position
+ my $old_line = $line;
- my @ret = choice ($Rules->{$item}{$pos.'hint'}, $l, $c, $r, \@choices, 0);
+ my @ret = choice ($hint, $l, $c, $r, \@choices, 0);
$line = pop @ret; # fixed line
push (@comments, @ret); # comments
- pos $line = $save - length($c) + 1; # set last match position at the beginning of the modification
+ pos $line = ($save - length($c) + 1); # set last match position at the beginning of the modification
- redo REDO_ALL;
+ redo REDO_ALL if ($old_line ne $line); # re-parse if the line has been changed
}
}
} }
@@ -351,14 +356,14 @@
pos $line = 0; # start from beginning
- while ($line =~ /(\w+)/g) { # find next token
+ while ($line =~ /($word_letters+)/gi) { # find next token
my $l = $` || ''; # left part
my $w = $&; # word
my $r = $' || ''; # right part
debug 3, "checking `$w'";
- $_ = `echo '$w' | ispell -a -b $dictionary`; # run ispell
+ $_ = `echo "$w" | ispell -a -d $dictionary`; # run ispell
suicide "Cannot run ispell: ($?)$!" if $?;
/^& $w \d+ \d+: (.*)$/m; # get correction proposal line
next if $1 eq $w; # next if no proposal
@@ -366,13 +371,15 @@
my @choices = split(", ", $1);
my $save = pos $line; # save last match position
+ my $old_line = $line;
my @ret = choice ("ispell $w", $l, $w, $r, \@choices, 1);
$line = pop @ret; # fixed line
push (@comments, @ret); # comments
- pos $line = $save - length($w); # set last match position at the beginning of the modification
- $line =~ /(\w+)/g unless @ret; # next one if no correction
+ @ret ? pos $line = $save - length($w) : # set last match position at the beginning of the modification
+ pos $line = $save; # restore last match position if no change
+ #$line =~ /(\w+)/g unless @ret; # next one if no correction
next;
}
# common rules
rule = "status|statut"
hint = "« état » en français, cf. FAQ § 2.13.4"
fix = "état"
rule = "plateforme"
hint = "Trait d'union manquant"
fix = "plate-forme"
rule = "entete|entête"
hint = "Trait d'union manquant"
fix = "en-tête"
rule = "digital"
hint = "Angliscisme"
fix = "numérique"
rule = "complétion"
hint = "Franglisme, cf. FAQ § 2.13.4"
fix = "complètement"
rule = "(?<=\s)(e-?)?mail"
hint = "courrier, courriel ou courrier électronique : en français, cf. FAQ § 2.13.3"
fix 0 = "courriel"
fix 1 = "courrier"
fix 2 = "courrier électronique"
rule = "maintainer|mainteneur"
hint = "« Responsable [d'un paquet] » en français, cf. FAQ § 2.13.1"
fix = "responsable"
rule = "package"
hint = "« paquet » en français, cf. FAQ § 4.1"
fix = "paquet"
rule = "paquetage"
pre_valid = "em|dé"
pré_hint = "« paquet » en français, cf. FAQ § 4.1"
pré_fix = "paquet"
rule = "patch"
hint = "« rustine » en français, cf. FAQ § 2.13.3"
fix = "rustine"
rule = "ROMs"
hint = "Les sigles de prennent pas la marque du pluriel en français"
fix = "ROM"
rule = "GNU/Linux"
hint = "Trait d'union en français, cf. FAQ § 5.1.2.7"
fix = "GNU-Linux"
rule = "GNU/Hurd"
hint = "Trait d'union en français, cf. FAQ § 5.1.2.7"
fix = "GNU-Hurd"
rule = "\"(?=\S)"
hint = "Guillemet français, cf. FAQ § 5.1.2.2"
fix = "« "
rule = "(?<=\S)\""
hint = "Guillemet français, cf. FAQ § 5.1.2.2"
fix = " »"
rule = "(?<=\s)'(?=\S)"
hint = "Guillemet français, cf. FAQ § 5.1.2.2"
fix = "« "
rule = "(?<=\S)'(?=(\s|$))"
hint = "Guillemet français, cf. FAQ § 5.1.2.2"
fix = " »"
rule = "plate-?formes"
hint = "Pluriel du nom composé"
fix = "plates-formes"
rule = "etc"
post_valid = "\."
post_hint = "Point abréviatif manquant"
post_insert = "."
Reply to: