<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--    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, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA. -->
<!--	This file is licensed under the GPLv3.
	    Read the full license text: http://script.blau.in/etc/GPL_License -->
<!--    201004 -->


<xsl:template match="lexicon"><xsl:text>
</xsl:text><!-- 201004 <xsl:comment>    Ralf's Hungarian dictionary (version 0.1; April 14, 2010)
        You can import this dictionary into 'simon'.
        This PLS dictionary serves as a first draft. </xsl:comment><xsl:text>
</xsl:text>-->
<xsl:comment>	This file is licensed under the GPLv3.
        Read the full license text: http://script.blau.in/etc/GPL_License </xsl:comment><xsl:text>
</xsl:text><xsl:comment>    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, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA. </xsl:comment><xsl:text>
</xsl:text>

<speak version="1.0" xml:lang="hu">

<xsl:for-each-group select="lexeme" group-by="grapheme">
 <xsl:sort select="grapheme" order="ascending"/>
 <xsl:call-template name="create-latin-lexeme-element"/>
</xsl:for-each-group><!--<xsl:text>
</xsl:text>-->
</speak>
</xsl:template>

<xsl:template name="create-latin-lexeme-element">
 <xsl:variable name="current-latin-lexeme">  
 <xsl:choose>
   <xsl:when test="ends-with(grapheme, 'que')"/>
 <!--  <xsl:when test="ends-with(grapheme, 've')"/>
   <xsl:when test="ends-with(grapheme, 'ne')"/>-->
   <xsl:otherwise>
 <!--<xsl:text>
 </xsl:text>
 <xsl:element name="lexeme">-->
  <xsl:call-template name="create-latin-grapheme-element"/><!--
  <xsl:call-template name="create-assamese-phoneme-element"/><xsl:text>
 </xsl:text>--><!--
 </xsl:element>-->
 </xsl:otherwise>
 </xsl:choose>
 </xsl:variable>
 <xsl:sequence select="$current-latin-lexeme"/>
</xsl:template>

<xsl:template name="create-latin-grapheme-element">
 <xsl:variable name="current-grapheme">   
 <xsl:choose>
    <xsl:when test="contains(grapheme, ' ')"/>
    <xsl:when test="contains(grapheme, '&#9;')"/>
    <xsl:when test="contains(grapheme, '-')"/>
    <xsl:otherwise><xsl:text>
  </xsl:text>
  <xsl:element name="audio">

     <xsl:value-of select="grapheme"/>

  </xsl:element>    
</xsl:otherwise>
   </xsl:choose>
 </xsl:variable>
 <xsl:sequence select="$current-grapheme"/>
</xsl:template>

<xsl:template name="create-assamese-phoneme-element">
 <xsl:variable name="current-grapheme">
  <xsl:value-of select="lower-case(grapheme)"/>
 </xsl:variable>
<!-- <xsl:call-template name="convert-assamese-letters-into-ipa"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'এ', 'ɛ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ই', 'i')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'উ', 'u')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ও', 'ʊ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'অ', 'ɔ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'আ', 'a')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'প', 'p')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ফ', 'p')"/>
 
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ব', 'b')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ভ', 'b')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ম', 'm')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ৱ', 'w')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ত', 't')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ট', 't')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'থ', 't')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ঠ', 't')"/>
 
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'দ', 'd')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ড', 'd')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ধ', 'd')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ঢ', 'd')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'চ', 's')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ছ', 's')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'জ', 'z')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ঝ', 'z')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'য', 'z')"/>
 
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ন', 'n')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ণ', 'n')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ল', 'l')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ৰ', 'r')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ক', 'k')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'খ', 'k')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'গ', 'g')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ঘ', 'g')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'শ', 'x')"/>

 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ষ', 'x')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'স', 'x')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ঙ', 'ŋ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ং', 'ŋ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'হ', 'h')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'ñ', 'ɲ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'tx', 'tʃ')"/>
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, '-', '')"/>
 
 <xsl:variable name="current-grapheme" select="replace($current-grapheme, 'x', 'ʃ')"/>-->

<xsl:text>
   </xsl:text> <xsl:element name="phoneme"> 
  <xsl:sequence select="$current-grapheme"/>
 </xsl:element>
</xsl:template>
<!--
<xsl:template name="convert-assamese-letters-into-ipa">
 <xsl:variable name="current-grapheme" select="replace($sierra, 'এ', 'ɛ')"/>
</xsl:template>-->

</xsl:stylesheet>

