// ***************************************************************************/ 
// *   Kyrgyz Language ky ky_rules                                           *
// *   Original Author Joshua Meyer 7-1-2016                                 *
// *   Contact info: joshua.richard.meyer@gmail.com                          *
// ***************************************************************************/
// *   This program is free software; you can redistribute it and/or modify  *
// *   it under the terms of the GNU General Public License as published by  *
// *   the Free Software Foundation; either version 3 of the License, or     *
// *   (at your option) any later version.                                   *
// *                                                                         *
// *   This program is distributed in the hope that it will be useful,       *
// *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
// *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
// *   GNU General Public License for more details.                          *
// *                                                                         *
// *   You should have received a copy of the GNU General Public License     *
// *   along with this program; if not, see:                                 *
// *               <http://www.gnu.org/licenses/>.                           *
// ***************************************************************************/

// Stress rule: Right-most vowel

// Letter groups:                                                      // are these getting defined?
// A any vowel:        а о у ы э е ё и ю я ө ү                               // all vowels
// B back vowels:      а о у ы ё ю я                                 // back vowels
// C any consonant:    п б д т к г х ш щ ж з с ц ч й л м н ң ф в р ъ ь      // all consonants  
// F front vowels:     э е и ө ү                                       // front vowels

.replace 
         ё      йо // replace the glide+vowel characters
         ю      йу
         я      йа

.L01 а о у ы ё ю я   // back vowels
.L02 э е и ө ү       // front vowels
.L03 п б д т к г х ш щ ж з с ц ч й л м н ң ф в р ъ ь // any consonant
.L04 а о у ы ё ю я э е и ө ү       // all vowels

.group а
       а (_  'a   // word final syllable gets stressed
       аа (_  'a:   // word final syllable gets stressed
       а (L03_  'a   // word final syllable gets stressed
       аа (L03_  'a:   // word final syllable gets stressed
       а (L03L03_  'a   // word final syllable gets stressed
       аа (L03L03_  'a:   // word final syllable gets stressed
       а        a
       аа       a:

.group о
       о (_  'o   // word final syllable gets stressed
       оо (_  'o:   // word final syllable gets stressed
       о (L03_  'o   // word final syllable gets stressed
       оо (L03_  'o:   // word final syllable gets stressed
       о (L03L03_  'o   // word final syllable gets stressed
       оо (L03L03_  'o:   // word final syllable gets stressed
       о        o
       оо       o:

.group у
       у (_  'u   // word final syllable gets stressed
       уу (_  'u:   // word final syllable gets stressed 
       у (L03_  'u   // word final syllable gets stressed
       уу (L03_  'u:   // word final syllable gets stressed 
       у (L03L03_  'u   // word final syllable gets stressed
       уу (L03L03_  'u:   // word final syllable gets stressed 
       у        u
       уу       u:

.group ы
       ы (_  'I   // word final syllable gets stressed
       ыы (_  'I:   // word final syllable gets stressed
       ы (L03_  'I   // word final syllable gets stressed
       ыы (L03_  'I:   // word final syllable gets stressed
       ы (L03L03_  'I   // word final syllable gets stressed
       ыы (L03L03_  'I:   // word final syllable gets stressed
       ы        I
       ыы       I:

.group и
       и (_  'i   // word final syllable gets stressed
       ии (_  'i:   // word final syllable gets stressed
       и (L03_  'i   // word final syllable gets stressed
       ии (L03_  'i:   // word final syllable gets stressed
       и (L03L03_  'i   // word final syllable gets stressed
       ии (L03L03_  'i:   // word final syllable gets stressed
       и        i
       ии       i:

.group ө
       ө (_  'O   // word final syllable gets stressed
       өө (_  'O:   // word final syllable gets stressed
       ө (L03_  'O   // word final syllable gets stressed
       өө (L03_  'O:   // word final syllable gets stressed
       ө (L03L03_  'O   // word final syllable gets stressed
       өө (L03L03_  'O:   // word final syllable gets stressed
       ө        O
       өө       O:

.group ү
       ү (_  'y   // word final syllable gets stressed
       үү (_  'y:   // word final syllable gets stressed
       ү (L03_  'y   // word final syllable gets stressed
       үү (L03_  'y:   // word final syllable gets stressed
       ү (L03L03_  'y   // word final syllable gets stressed
       үү (L03L03_  'y:   // word final syllable gets stressed
       ү        y
       үү       y:

.group е
       е (_  'e   // word final syllable gets stressed
       ее (_  'e:   // word final syllable gets stressed
       е (L03_  'e   // word final syllable gets stressed
       ее (L03_  'e:   // word final syllable gets stressed
       е (L03L03_  'e   // word final syllable gets stressed
       ее (L03L03_  'e:   // word final syllable gets stressed
       е        e
       ее       e:

.group э
       э (_  'e   // word final syllable gets stressed
       ээ (_  'e:   // word final syllable gets stressed
       э (L03_  'e   // word final syllable gets stressed
       ээ (L03_  'e:   // word final syllable gets stressed
       э (L03L03_  'e   // word final syllable gets stressed
       ээ (L03L03_  'e:   // word final syllable gets stressed
       э        e
       ээ       e:

.group к
       к (L01   q        // syllable onset /k/ followed by back vowel (MAX-ONSET)
       к (L02   k        // syllable onset /k/ followed by back vowel (MAX-ONSET)
       L01) к (L03       q   // syllable final /k/ preceded by back vowel
       L02) к (L03       k   // syllable final /k/ preceded by front vowel
       L01) к (_         q   // word final /k/ preceded by back vowel
       L02) к (_         k   // word final /k/ preceded by front vowel

.group г
       г (L01   G        // syllable onset /g/ followed by back vowel (MAX-ONSET)
       г (L02   g        // syllable onset /g/ followed by back vowel (MAX-ONSET)
       L01) г (L03       G   // syllable final /g/ preceded by back vowel
       L02) г (L03       g   // syllable final /g/ preceded by front vowel
       L01) г (_         G   // word final /g/ preceded by back vowel
       L02) г (_         g   // word final /g/ preceded by front vowel

.group л
       л (L01   L        // syllable onset /l/ followed by back vowel (MAX-ONSET)
       л (L02   l        // syllable onset /l/ followed by back vowel (MAX-ONSET)
       L01) л (L03       L   // syllable final /l/ preceded by back vowel
       L02) л (L03     l   // syllable final /l/ preceded by front vowel
       L01) л (_       L   // word final /l/ preceded by back vowel
       L02) л (_       l   // word final /l/ preceded by front vowel

.group р
       р (_     r       // word final /r/ gets trilled
       L04) р (L03  r   // syllable final /r/ gets trilled
       р r              // all r get trilled (the flap sounded wrong syllable initial)
     

.group п
       п        p

.group б
       б        b

.group д
       д        d

.group т
       т        t

.group х
       х        X

.group ш
       ш        S

.group щ
       щ        S

.group ж
       ж        dZ

.group з
       з        z

.group с
       с        s

.group ц
       ц        ts

.group ч
       ч        tS

.group й
       й        j

.group м
       м        m

.group н
       н        n

.group ң
       ң        N

.group ф
       ф        f

.group в
       в        v

.group ъ
       ъ        j

.group ь
       ь        j