keyboard/altgr: classify lookalike symbols as transliterated
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 27 Jan 2024 20:30:41 +0000 (21:30 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 29 Jan 2024 17:17:48 +0000 (18:17 +0100)
Character type distinction (spacing diacritic or punctuation) deemed less
significant.

Shiar_Sheet/KeyboardChars.pm
keyboard/altgr/olpc.eng.inc.pl

index 6afd7dce4cf1b7619d9aff5b9ab0e784692fc812..77be1209c6f5078125b6d65abe09296883f0b6b1 100644 (file)
@@ -8,7 +8,7 @@ use Unicode::Normalize qw( NFKD );
 use Text::Unidecode qw( unidecode );
 use Shiar_Sheet::FormatChar;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 our @EXPORT = qw( kbchars kbmodes );
 
 my $uc = Shiar_Sheet::FormatChar->new;
@@ -36,10 +36,10 @@ sub kbmodes ($modes) {
                        my $class = 'g'.(
                                  !defined $v || $c eq $v ? 1 # identical
                                : $v =~ /\A\p{Mn}+\z/ ? 9 # combining accent
-                               : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
-                               : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
                                : NFKD($v) =~ /\Q$c/ ? 2 # decomposed equivalent
                                : unidecode($v) =~ /\Q$c\E+/i ? 4 # transliterated
+                               : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
+                               : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
                                : $v =~ /^\p{Latin}/ ? 5 # latin script
                                : 6
                        );
index 3884b9aaafcd0759aba2fc2482ab45a53a31e0c3..2cd99e2399fa2f528fb69802a14afd63a8b5a15f 100644 (file)
@@ -1,6 +1,7 @@
 use utf8;
 use strict;
 use warnings;
+no warnings 'qw';
 use Shiar_Sheet::KeyboardChars 'kbchars';
 
 my %rows = (
@@ -63,15 +64,11 @@ my %shift = (
        qw( { [  } ]  " '  | \  < ,  > .  ? /  ` 3  ~ = ),
        (map {uc, lc} qw[ r t y u i o p  h j  m  ]),
 );
+$rows{$_} = $rows{ $shift{$_} } for keys %shift; # alias shifted
 
 my $groups = kbchars(\%rows);
 $groups->{flag}{ext} = ['alias', 'identical results from unshifted key'];
-while (my ($alias, $target) = each %shift) {
-       # copy alias to shifted
-       $groups->{key}{$alias} = $groups->{key}{$target};
-       $groups->{def}{''}{$alias} = $groups->{def}{''}{$target}.' ext';
-}
-$groups->{def}{''}{$_} =~ s/g7/g4/ for qw( ! < > ? ); # similar punctuation
+$groups->{def}{''}{$_} .= ' ext' for keys %shift; # mark aliases
 
 +{
        %{ $groups },