| 1 | package Lingua::Deva::Maps; | ||
| 2 | |||
| 3 | 6 | ▶ | use v5.12.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 6 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 6 | ▶ | use charnames ':full'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 6 | ▶ | use Lingua::Deva::Maps::IAST; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | =encoding UTF-8 | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Lingua::Deva::Maps - Default maps setup for Lingua::Deva | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | 6 | ▶ | use Exporter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 6 | ▶ | use parent 'Exporter'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 6 | our @EXPORT_OK = qw( %Consonants %Vowels %Diacritics %Finals | |
| 22 | $Inherent $Virama $Avagraha ); | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | use Lingua::Deva::Maps::IAST; # or | ||
| 27 | use Lingua::Deva::Maps::ISO15919; # or | ||
| 28 | use Lingua::Deva::Maps::HK; # or | ||
| 29 | use Lingua::Deva::Maps::ITRANS; | ||
| 30 | |||
| 31 | my $d = Lingua::Deva->new(map => 'HK'); | ||
| 32 | say $d->to_deva('gaNezaH'); # prints 'गणेशः' | ||
| 33 | |||
| 34 | =head1 DESCRIPTION | ||
| 35 | |||
| 36 | This module defines the default transliteration mappings for L<Lingua::Deva> | ||
| 37 | and is intended for internal use. | ||
| 38 | |||
| 39 | It does, however, provide the namespace for the ready-made transliteration | ||
| 40 | schemes, | ||
| 41 | |||
| 42 | =over 4 | ||
| 43 | |||
| 44 | =item C<Lingua::Deva::Maps::IAST> | ||
| 45 | |||
| 46 | International Alphabet of Sanskrit Transliteration (I<kṛṣṇa>), | ||
| 47 | |||
| 48 | =item C<Lingua::Deva::Maps::ISO15919> | ||
| 49 | |||
| 50 | Simplified ISO 15919 (I<kr̥ṣṇa>), | ||
| 51 | |||
| 52 | =item C<Lingua::Deva::Maps::HK> | ||
| 53 | |||
| 54 | Harvard-Kyoto (I<kRSNa>), and | ||
| 55 | |||
| 56 | =item C<Lingua::Deva::Maps::ITRANS> | ||
| 57 | |||
| 58 | ITRANS (I<kRRiShNa>). | ||
| 59 | |||
| 60 | =back | ||
| 61 | |||
| 62 | Users can also furnish their own transliteration schemes, but these must | ||
| 63 | follow the layout of the existing schemes which is described in the following. | ||
| 64 | |||
| 65 | Every transliteration scheme provides four hashes, C<%Consonants>, C<%Vowels>, | ||
| 66 | C<%Diacritics> (diacritic vowel signs), and C<%Finals> (I<anusvāra>, | ||
| 67 | I<candrabindu>, I<visarga>). The L<Lingua::Deva> module relies on this | ||
| 68 | subdivision for its parsing and aksarization process. | ||
| 69 | |||
| 70 | Inside these hashes the keys are Latin script tokens and the values are the | ||
| 71 | corresponding Devanagari characters: | ||
| 72 | |||
| 73 | "bh" => "\N{DEVANAGARI LETTER BHA}" # in %Consonants | ||
| 74 | |||
| 75 | The hash keys ("tokens") must be in canonically decomposed form | ||
| 76 | (L<NFD|Unicode::Normalize>). For example a key "ç" ("c" with cedilla) needs | ||
| 77 | to be entered as C<"c\x{0327}">, ie. a "c" with combining cedilla. If the | ||
| 78 | transliteration scheme is case-insensitive, the keys must be lowercase. | ||
| 79 | |||
| 80 | In addition to the required four hash maps, a boolean variable C<$CASE> may be | ||
| 81 | present. If it is, it specifies whether case distinctions by default do have | ||
| 82 | significance (S<I<A> ≠ I<a>>) or not (S<I<A> = I<a>>) in the scheme. | ||
| 83 | |||
| 84 | The default mappings of a L<Lingua::Deva> object can be completely customized | ||
| 85 | through the optional constructor arguments | ||
| 86 | |||
| 87 | =over 4 | ||
| 88 | |||
| 89 | =item * | ||
| 90 | |||
| 91 | L<C|Lingua::Deva/new>, L<V|Lingua::Deva/new>, L<D|Lingua::Deva/new>, | ||
| 92 | L<F|Lingua::Deva/new>, Latin to Devanagari maps, | ||
| 93 | |||
| 94 | =item * | ||
| 95 | |||
| 96 | L<DC|Lingua::Deva/new>, L<DV|Lingua::Deva/new>, L<DD|Lingua::Deva/new>, | ||
| 97 | L<DF|Lingua::Deva/new>, Devanagari to Latin maps, and | ||
| 98 | |||
| 99 | =item * | ||
| 100 | |||
| 101 | L<casesensitive|Lingua::Deva/new>, case-sensitivity. | ||
| 102 | |||
| 103 | =back | ||
| 104 | |||
| 105 | The first eight of these serve to override the default transliteration | ||
| 106 | mappings (or the one passed through the L<map|Lingua::Deva/new> option). It | ||
| 107 | is easiest to start by copying and modifying one of the existing maps. | ||
| 108 | |||
| 109 | # Include the relevant module | ||
| 110 | use Lingua::Deva::Maps::IAST; | ||
| 111 | |||
| 112 | # Copy map, modify, then pass to the constructor | ||
| 113 | my %c = %Lingua::Deva::Maps::IAST::Consonants; | ||
| 114 | $c{"c\x{0327}"} = delete $c{"s\x{0301}"}; | ||
| 115 | my $d = Lingua::Deva->new( C => \%c ); | ||
| 116 | |||
| 117 | It is the user's responsibility to make reasonable customizations; eg. the | ||
| 118 | vowels (C<V>) and diacritics (C<D>) maps normally need to be customized in | ||
| 119 | unison. | ||
| 120 | |||
| 121 | Aside from all this, C<Lingua::Deva::Maps> also defines the global variables | ||
| 122 | |||
| 123 | =over 4 | ||
| 124 | |||
| 125 | =item C<$Inherent> | ||
| 126 | |||
| 127 | the inherent vowel I<a>, | ||
| 128 | |||
| 129 | =item C<$Virama> | ||
| 130 | |||
| 131 | I<virāma> ( ्), and | ||
| 132 | |||
| 133 | =item C<$Avagraha> | ||
| 134 | |||
| 135 | I<avagraha> (ऽ), | ||
| 136 | |||
| 137 | =back | ||
| 138 | |||
| 139 | which are unlikely to need configurability. | ||
| 140 | |||
| 141 | =cut | ||
| 142 | |||
| 143 | # Setup default maps | ||
| 144 | 6 | *Consonants = \%Lingua::Deva::Maps::IAST::Consonants; | |
| 145 | 6 | *Vowels = \%Lingua::Deva::Maps::IAST::Vowels; | |
| 146 | 6 | *Diacritics = \%Lingua::Deva::Maps::IAST::Diacritics; | |
| 147 | 6 | *Finals = \%Lingua::Deva::Maps::IAST::Finals; | |
| 148 | |||
| 149 | # Global variables | ||
| 150 | 6 | our $Inherent = "a"; | |
| 151 | 6 | our $Virama = "\N{DEVANAGARI SIGN VIRAMA}"; | |
| 152 | 6 | our $Avagraha = "\N{DEVANAGARI SIGN AVAGRAHA}"; | |
| 153 | |||
| 154 | 6 | 1; | |