1f372e32c2cf1c8e253e743a3f80dabc1d36247c
[sheet.git] / keyboard.eng.inc.pl
1 use Unicode::Normalize qw( NFKD );
2 use Text::Unidecode qw( unidecode );
3
4 {
5         rows => [0, 1],
6         def => {
7                 '' => {
8                         map {
9                                 my $v = $rows{$_};
10                                 my $class = (
11                                           !defined $v || $_ eq $v ? 1 # identical
12                                         : $v =~ /\A\p{Mn}+\z/ ? 9 # combining accent
13                                         : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 8 # modifier symbol
14                                         : $v =~ /\A[\pM\pP]+\z/ ? 7 # mark
15                                         : NFKD($v) =~ /\Q$_/ ? 2 # decomposed equivalent
16                                         : unidecode($v) =~ /\Q$_\E+/i ? 4 # transliterated
17                                         : $v =~ /^\p{Latin}/ ? 5 # latin script
18                                         : 6
19                                 );
20                                 $_ => "g$class"
21                         } keys %rows
22                 },
23         },
24         key => \%rows,
25         flag => {
26                 g1 => ['unaltered', "same results as without modifier"],
27                 g2 => ['accented', "decomposes to the original letter with a combining accent"],
28                 g4 => ['similar', "transliterates (mostly) into the unmodified letter"],
29                 g5 => ['latin', "a different (accented) latin letter"],
30                 g6 => ['symbol', "other character not directly deducible from key"],
31                 g7 => ['punctuation', "(punctuation) mark"],
32                 g8 => ['mark', "modifier letter or mark (spacing diacritic)"],
33                 g9 => ['combining', "diacritical mark to be combined with a following character"],
34         },
35 }