keyboard: match transliterated letters
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 21 Feb 2018 08:59:34 +0000 (09:59 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 5 Mar 2018 22:51:17 +0000 (23:51 +0100)
keyboard.plp

index 1ad9324..2fe9c07 100644 (file)
@@ -15,6 +15,7 @@ Html({
 <:
 use Shiar_Sheet::Keyboard 2.07;
 use Unicode::Normalize qw( NFKD );
+use Text::Unidecode qw( unidecode );
 
 my @usintrows = (
        [  'a' ..                                            'z'],
@@ -38,9 +39,10 @@ my $keys = Shiar_Sheet::Keyboard->new({
                                my $class = (
                                          !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
                                        : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
-                                       : $row[2] =~ /^\p{Latin}/ ? 3 # latin script
-                                       : $row[2] =~ /^\p{Mn}/ ? 5 # combining accent
-                                       : 4
+                                       : $row[2] =~ /^\p{Latin}/ ? 4 # latin script
+                                       : unidecode($row[2]) =~ /^\W*\Q$row[0]/ ? 5 # transliterated
+                                       : $row[2] =~ /^\p{Mn}/ ? 8 # combining accent
+                                       : 7
                                );
                                $row[0] => "g$class"
                        } @usint
@@ -54,9 +56,9 @@ my $keys = Shiar_Sheet::Keyboard->new({
        flag => {
                g1 => ['unaltered'],
                g2 => ['accented'],
-               g3 => ['latin'],
-               g4 => ['other'],
-               g5 => ['combining'],
+               g4 => ['latin'],
+               g7 => ['other'],
+               g8 => ['combining'],
        },
 });
 $keys->map($get{map}) or undef $get{map};