NAME

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

SYNOPSIS

use v5.12.1;
use strict;
use charnames ':full';
use open qw( :encoding(UTF-8) :std );
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() };

DESCRIPTION

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, with no distinction between upper and lower case.

Methods

new()

Constructor. Can take optional initial data as its argument.

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

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.

vowel()

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

final()

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

get_rhyme()

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.

is_valid()

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.

If the maps have been modified in the Lingua::Deva instance, a reference to that instance can be passed along and the modified maps will be used.

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

An aksara constructed through Lingua::Deva's public interface is already well-formed and no validity check is necessary.