Meter-identification

A Computer Program To Identify Sanskrit Metres

By

G S S Murthy

murthygss@gmail.com

Synopsis: The methodology of a program in Java which identifies the name of the Metre when a quarter of a Sanskrit stanza is input in Roman script as per a defined transliteration scheme is briefly described after introducing the basic concepts of Sanskrit prosody.

Key words: computational linguistics, Sanskrit metres, prosody, java, chandas, vrutta

[Note: All Sanskrit words are in italics.]

  1. This paper describes a program in Java which identifies the Metre of a Sanskrit verse. When a quarter of a Sanskrit stanza is input in Roman script as per a specified transliteration scheme, this program, called MAATRAA, scans the input, identifies the vrutta (metre) and outputs the name of the vrutta. The self-executable version of the program called Maatraa5d, is available at http://www.mediafire.com/?p21y045io80il5o. The source code is available at https://github.com/vvasuki/sanskritnlp/tree/master/src/main/java/gssmurthy

The transliteration scheme, as per devanaagaree alphabetical order, as accepted by the program, is as follows

    _svara_: a, aa or A, i, ee or I, u, uu or U, Ru, RU, lRu, e, ai, o, ou

    _anusvaara_: m, visarga: h

    _vyanjana_: ka varga: k, kh or K, g, gh or G, ~G

           _ca varga_: c, ch or C, j, jh or J, ~J

           _Ta varga_: T, Th, D, Dh, N

           _ta varga_: t, th, d, dh, n

           _pa varga_: p, ph or P, b, bh or B, M

           _antasTha_: y, r, l,v

           _uuShma_: S, Sh, s, 

           _anunaasika_: ~M
  1. Before we describe the methodology of the program, a brief introduction to basics of Sanskrit prosody would be in order: A padya (=a stanza) consists of four paada’s (=quarters) each paada having a fixed number of akshara’s (=syllable) and/or a fixed number of maatraa’s (=a unit of syllabic duration). A single svara (=vowel) or one or more vyanjana’s (=consonant) followed by a svara constitute an akshara. A short svara has a duration of one maatraa, called laghu and a long vowel has a duration of two maatraa’s, called guru. When a short svara is followed by an anusvaara, a visarga or a samyuktaakshara (conjunct consonant), it is treated as a guru (two maatraa’s).

In what is called the gana-based system, each paada of a padya is divided into groups of three akshara’s each. An age-old cyclic mnemonic that helps in remembering and characterizing the gana’s is as follows:

_Ya-maa-taa-raa-ja-bhaa-na-sa _

A sequence of 3 adjacent _akshara’_s in this mnemonic characterizes a gana and the first _akshara _of a sequence is the name of that gana. For example, the first sequence of 3 _akshara’_s _ya-maa-taa, _whose 3 _akshara’_s are respectively laghu, guru, guru specifies that ya gana consists of a sequence _laghu, guru, guru. _Similarly _sa gana _ is specified by sa-ya-maa, a sequence of _laghu, laghu and guru. _It may be noted that what characterizes a vrutta is the specific string of laghu’s and guru’s that forms a paada and the system of gana’s only helps in memorizing the string and composing a verse or identifying the metre of a given verse.

Broadly there are 3 types of metres in classical Sanskrit.

i. Each paada of a sloka consists of a specified number of maatraa’s, with some

constraints.

ii. Each paada consists of a specified sequence of _gana_s, which may be

followed by one or two _akshara_s, each being either guru or laghu. The last

_akshara _of a _paada _ is generally considered a guru. Such stanzas are called

_vrutta_s or vrutta- sloka’s.

iii. Each _paada _consists of a specified number of akshara’s with some constraints.

Among metres employed in classical Sanskrit literature, anushtup ( often called

_sloka) _appears to be the only one which belongs to the third type. Whereas

_maatraa-_based metres like aaryaa and _vaitaaleeya _ have only a defined number of _maatraa_s in a paada subject to a few other constraints, gana- based _vrutta_s like mandaakraantaa, shaarduulavikreedita etc have a defined number of _akshara_s and _maatraa_s in a paada. For _anushtup _category, the number of akshara’s in a paada is specified as eight, with some constraints on the use of certain gana’s at certain positions of the paada.

Two well known works on Sanskrit prosody are Chandas-shaastram of Pingala and Vruttaratnaakara of Kedaarabhatta. While Pingala adopts the method of Sutra’s like Panini for defining the characteristics of a stanza, Kedaarabhatta interestingly uses a paada of a vrutta to define the vrutta. This program has adopted the names of _vrutta_s as given by Kedarabhatta.

  1. We shall now briefly describe the steps involved in the program, by taking a specific input string, namely the first paada of the first sloka of Kumaarasambhavam of Kaalidaasa. -> string1= ”astyuttarasyaam diSi dEvataatmaa”.
  • compute length of string1=32

  • create an array (varNa[ ]) of characters that form the input: varNa[1]=a, varNa[2]=s, etc.

  • remove all spaces in the input: string1=“astyuttarasyaamdiSidEvataatmaa”

  • replace all 2-letter representations by single letter representation internally in a unique manner: string1=“astyuttarasyAmdiSidEvatAtmA”

  • implement the algorithm for determining the maatraa of each akShara:

  • If varNa[m]=a,i,u

      maatraa[m]=1 
    
  • If varNa[m]=svara other than a,i,u

    maatraa[m]=2

  • If varNa[m]= not a svara

    maaatraa[m]=0

  • If maatraa[m]=1& maatraa[m+1]=0& maatraa[m+2]=0

    maatraa[m]=2

  • Treat the maatraa of last varna in a quarter as 2.

  • Convert the result into a string after determining the _maatraa_s of all _varna_s in the input and removing “zero”s(which correspond to _vyanjana_s):

    22122112122, where 1 represents a laghu and 2 represents a guru.

The program has a built in data base of scans of most frequently occurring _vrutta_s (about forty) and their corresponding names in two arrays.

  • Compare the derived scan with the scan data base and when a match occurs, output the corresponding name from the name array.
  • Keep count of akshara’s in the input and output it.
  • For this particular input, the output would be as follows:

“Result of scan is 221-221-121-22

Total maatraas = 18, Total akshara’s = 11

Name of vrutta is Indravajraa”

If the number of akshara’s in the input is 8, it checks if it meets the requirements of _anushtup _ metre. Despite being widely used in Sanskrit classical literature and scriptures, it was found that anushtup was poorly defined. This led the author into an entirely new area of study which resulted in defining the characteristics of anushtup afresh. This study has been published as a paper in Annals of Bhandarkar Oriental Research Institute, Pune, Vol.LXXXIV, 2004. It would be out of place to delve into that research here. Suffice it to say that this program makes use of the results of that research work for recognizing anushtup. As the odd paada of anushtup differs from the even paada of anushtup, the program indicates if the input is as per odd paada or even paada.

Similarly the program also checks if the input is first half or the second half of aaryaa metre. The input has to be half of a stanza instead of a quarter of a stanza, in case of aaryaa. When a quarter of a vishamavrutta which is defined as one having unequal quarters in length and structure is input, the program can only check if the quarter input is recognizable as one among the scans scored.

If the scan of the input does not match with any of the scans in its embedded database, the program outputs, “I do not know this vrutta. It may not be a vrutta.”

  1. As a sequel to this program another learning program has also been developed which builds out a data base of _vrutta_s as the user keeps on using the program. This program is not in the public domain. After the user inputs a quarter of a verse, the program asks the user to indicate the name of the vrutta also. After getting confirmation from the user that the input of the text and name of vrutta are both free from error, it stores the scan of the text and the name of the vrutta in two parallel files. In a subsequent interaction with the user, when a text is input it checks if its scan matches with any scan already stored and if there is no match, the program outputs, “I do not know the name of the vrutta. If you want me to learn it, please input the name of the vrutta” and proceeds to update its database.

  2. The program essentially demonstrates how computer programming is possible in the area of Sanskrit prosody. It could certainly be improved in many ways. One could augment the program to accept devanaagaree input and output in devanaagaree. One could also develop a program that is web-based, so that the user can interact with the program over the internet.