Author image David Bürgin
and 1 contributors


Lingua::Deva::Aksara - Object representation of a Devanagari "syllable"


    use v5.12.1;
    use strict;
    use charnames ':full';
    use Lingua::Deva::Aksara;

    my $a = Lingua::Deva::Aksara->new(
        onset => ['dh', 'r'],
        vowel => 'au',
        final => "h\N{COMBINING DOT BELOW}",
    $a->vowel( 'ai' );
    say 'valid' if $a->is_valid();
    say @{ $a->get_rhyme() }; # prints 'aiḥ'


Akṣara is the Sanskrit term for the basic unit above the character level in the Devanagari script. A Lingua::Deva::Aksara object is a Perl representation of such a unit.

Lingua::Deva::Aksara objects serve as an intermediate format for the conversion facilities in Lingua::Deva. Onset, vowel, and final tokens are stored in separate fields. Tokens are in Latin script; if the Aksara in question was created through the l_to_aksaras() or d_to_aksaras() method of a Lingua::Deva object, then the tokens are in the transliteration format associated with that object.



Constructor. Can take optional initial data as its argument.

    use Lingua::Deva::Aksara;
    Lingua::Deva::Aksara->new( onset => ['gh', 'r'] );

Accessor method for the array of onset tokens of this Aksara.

    my $a = Lingua::Deva::Aksara->new();
    $a->onset( ['d', 'r'] ); # sets onset tokens to ['d', 'r']
    $a->onset(); # returns a reference to ['d', 'r']

Returns undefined when there is no onset.


Accessor method for the vowel token of this Aksara. Returns undefined when there is no vowel.


Accessor method for the final token of this Aksara. Returns undefined when there is no final.


Returns the rhyme of this Aksara. This is a reference to an array consisting of vowel and final. Undefined if there is no rhyme.

The Aksara is assumed to be well-formed.


Checks the formal validity of this Aksara. This method first checks if the Aksara conforms to the structure (C+(VF?)?)|(VF?), where the letters represent onset consonants, vowel, and final. Then it checks whether the onset, vowel, and final fields contain only appropriate tokens.

In order to do validation against a different transliteration scheme than the default one, a reference to a customized Lingua::Deva instance can be passed along.

    $d; # Lingua::Deva object with custom transliteration
    say $a->is_valid($d);

An Aksara constructed through Lingua::Deva's public interface is already well-formed (ie. in accordance with the particular transliteration used) and no validity check is necessary.