<?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, see <http://www.gnu.org/licenses/>. -->
<!--Author of this style sheet: Ralf Herzog
    Date of creation: August 2010 
    License of this style-sheet: GPLv3 
    Usage: ubuntu@ubuntu-desktop:~$ saxonb-xslt -ext:on -s:/home/ubuntu/Documents/201006/audacity/xad-folder/lexicon-xad.xml -xsl:/home/ubuntu/Documents/201006/audacity/xab-folder/copy-flac.xsl -o:/home/ubuntu/Documents/201006/audacity/xfa-folder/cp-dummy -->
    <xsl:output method="text" omit-xml-declaration="yes"></xsl:output>
<xsl:template match="lexicon">

<xsl:variable name="traindir">xmb</xsl:variable>
 <xsl:variable name="current-traindir-path" select="concat('/home/ubuntu/Documents/201006/audacity/', $traindir, '-folder')"/>
<xsl:variable name="sections" 
            select="normalize-space('xaa xab xac xad xba xca xda xdb xea xeb xfa xfb xga xgb xgx xha xia xja xka xla xma xna xoa xpa xpb xhb xib xjb xpw xkb xlb xbm xmb')"></xsl:variable>
             
<xsl:variable name="current-dictionary" select="document('/home/ubuntu/Documents/201006/audacity/{$traindir}-folder/lexicon-{$traindir}.xml')/lexicon"/>
<!--<xsl:value-of select="current-dictionary/lexicon/lexeme/grapheme"></xsl:value-of>-->
<xsl:result-document href="/home/ubuntu/Documents/201006/audacity/{$traindir}-folder/cp-{$traindir}">

-- mkdir cp specific flac files --
<xsl:value-of select="concat('mkdir /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/flac-', $traindir, '-reduced/')"/><xsl:text>
</xsl:text>
<xsl:text>cp</xsl:text>
<xsl:for-each-group select="lexeme" group-by="grapheme">
   <xsl:variable name="first-phoneme-element">
    <xsl:call-template name="improve-german-phoneme-element"/> 
   </xsl:variable> 
  <xsl:value-of select="concat(' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/flac-', $traindir, '/', $first-phoneme-element, '.flac')"></xsl:value-of>
</xsl:for-each-group>
<xsl:value-of select="concat(' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/flac-', $traindir, '-reduced')"></xsl:value-of>
<xsl:text>
--
</xsl:text>
<xsl:value-of select="concat('mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/hmmdefs', 
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/hmmdefs-', $traindir, ' &amp;&amp; ',
                             'mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/tiedlist', 
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/tiedlist-', $traindir, ' &amp;&amp; ',
                             'mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/macros', 
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/macros-', $traindir, ' &amp;&amp; ',
                             'mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/stats', 
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/stats-', $traindir)"></xsl:value-of>
                             <xsl:text>
</xsl:text>
<xsl:value-of select="concat('mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/', $traindir, '-scenario.xml', 
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/scenario-', $traindir, '.xml')"/>
                             <xsl:text>
-- 20100814 --
</xsl:text>
<xsl:value-of select="concat('mkdir /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/wav-', $traindir)"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cd /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/flac-', $traindir)"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('for f in *.flac; do sox &quot;$f&quot; /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/wav-', $traindir , '/${f%.flac}.wav; done')"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/hmm24/hmmdefs /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/hmmdefs-', $traindir)"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/tiedlist /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/tiedlist-', $traindir)"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/hmm24/macros /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/macros-', $traindir)"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/stats /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/stats-', $traindir)"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/xab-folder/german-speech-model-xab/GPL_License /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/german-speech-model-', $traindir, '/GPL_License')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('mv /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/', $traindir, '-flac-reduced',
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/', 'flac-', $traindir)"/><xsl:text>
<!--</xsl:text>
<xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/', $traindir, '/prompts-', $traindir,
                             ' /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/)"></xsl:value-of>-->
-- terminal-voxforge --
</xsl:text>
  <xsl:value-of select="concat('mkdir /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/', 'ralfs-german-ipa-flac-files-', $traindir, '-201008')"></xsl:value-of><xsl:text>
</xsl:text>
  <xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/xab-folder/german-speech-model-xab/GPL_License /home/ubuntu/Documents/201006/audacity/', 
                               $traindir, '-folder/ralfs-german-ipa-flac-files-', $traindir, '-201008')"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/prompts-', $traindir, ' /home/ubuntu/Documents/201006/audacity/', 
                               $traindir, '-folder/ralfs-german-ipa-flac-files-', $traindir, '-201008')"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp ', $current-traindir-path, '/lexicon-', $traindir, 
                             '.xml ', $current-traindir-path, '/ralfs-german-ipa-flac-files-', $traindir, '-201008')"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/xca-folder/ralfs-german-ipa-flac-files-xca-20100815/readme.txt ', $current-traindir-path, '/ralfs-german-ipa-flac-files-', $traindir, '-201008')"/><xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp -r /home/ubuntu/Documents/201006/audacity/', $traindir, '-folder/flac-', $traindir,
                             ' ', $current-traindir-path, '/ralfs-german-ipa-flac-files-', $traindir, '-201008')"></xsl:value-of><xsl:text>
</xsl:text>
-- labels --
<xsl:value-of select="concat('paste ', $current-traindir-path, '/labels.txt ', 
                             '/home/ubuntu/Documents/201006/audacity/', $traindir, ' &gt; ', 
                             $current-traindir-path, '/', $traindir, '-pasted.txt')"/><xsl:text>
</xsl:text>


-- convert all flac to wav-all --
<xsl:for-each select="tokenize($sections, ' ')">
 <xsl:value-of select="concat('cd /home/ubuntu/Documents/201006/audacity/', ., '-folder/flac-', .)"/><xsl:text> &amp;&amp; \
</xsl:text> <xsl:value-of select="concat('for f in *.flac; do sox &quot;$f&quot; /home/ubuntu/Documents/201008/wav-all', '/${f%.flac}.wav; done')"/><xsl:text> &amp;&amp; \
</xsl:text>
</xsl:for-each>
-- concatenate all prompts --
<xsl:text>cat</xsl:text>
<xsl:for-each select="tokenize($sections, ' ')">
 <xsl:value-of select="concat(' /home/ubuntu/Documents/201006/audacity/', ., '-folder/prompts-', .)"/><xsl:text> \
</xsl:text>
                             
</xsl:for-each>

<xsl:text> &gt; /home/ubuntu/Documents/201008/prompts-all 
</xsl:text>

-- ralfs german speech model 0.1.4 --
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/hmm24/hmmdefs', 
                             ' /home/ubuntu/Documents/201007/german-speech-model-0.1.4/hmmdefs-0.1.4')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/tiedlist',
                             ' /home/ubuntu/Documents/201007/german-speech-model-0.1.4/tiedlist-0.1.4')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/hmm24/macros',' /home/ubuntu/Documents/201007/german-speech-model-0.1.4/macros-0.1.4')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /tmp/kde-ubuntuJPP9Sy/simond/default/compile/stats', ' /home/ubuntu/Documents/201007/german-speech-model-0.1.4/stats-0.1.4')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('cp /home/ubuntu/Documents/201006/audacity/xab-folder/german-speech-model-xab/GPL_License', ' /home/ubuntu/Documents/201007/german-speech-model-0.1.4/')"/>
<xsl:text>
</xsl:text>

-- remove folder and files --
rm -r /home/ubuntu/.kde/share/apps/simon
rm -r /home/ubuntu/.kde/share/apps/simond
rm /home/ubuntu/.kde/share/config/sscrc
rm /home/ubuntu/.kde/share/config/speechmodelmanagementrc
rm /home/ubuntu/.kde/share/config/simonsoundrc
rm /home/ubuntu/.kde/share/config/simonscenariosrc
rm /home/ubuntu/.kde/share/config/simonrecognitionrc
rm /home/ubuntu/.kde/share/config/simonrc
rm /home/ubuntu/.kde/share/config/simoncommandrc
rm /home/ubuntu/.kde/share/config/samrc
rm /home/ubuntu/.kde/share/config/ksimondrc

</xsl:result-document>
-- merge several dictionaries --
<xsl:result-document href="/home/ubuntu/Documents/201008/lexicon-all.xml">
&lt;lexicon&gt;
 <xsl:for-each select="tokenize($sections, ' ')">
  <xsl:for-each select="document(concat('/home/ubuntu/Documents/201006/audacity/',.,'-folder/lexicon-',.,'.xml'))/lexicon/lexeme">
 <xsl:if test="not(grapheme eq 'Arbeitslose')">
 &lt;lexeme&gt;
  &lt;grapheme&gt;<xsl:value-of select="grapheme"/>&lt;/grapheme&gt;
   &lt;phoneme&gt;<xsl:value-of select="phoneme"/>&lt;/phoneme&gt;
 &lt;/lexeme&gt;  </xsl:if></xsl:for-each>

  <!--<xsl:variable name="currentdic" name="multidic" select=concat($currentdic, -->
 </xsl:for-each>&lt;/lexicon&gt;
</xsl:result-document>


</xsl:template>

<!-- June 2010 -->
<xsl:template name="improve-german-phoneme-element">
 <xsl:variable name="sierra"><xsl:value-of select="phoneme"/></xsl:variable>
 <xsl:variable name="sierra">
    <xsl:variable name="sierra" select='replace($sierra, "Z", "ʒ")'/>
    <xsl:variable name="sierra" select='replace($sierra, "T", "θ")'/>
    <xsl:variable name="sierra" select='replace($sierra, "Q", "ʔ")'/>
    <xsl:variable name="sierra" select='replace($sierra, "_", "")'/>
    <xsl:variable name="sierra" select='replace($sierra, "C", "ç")'/>
    <xsl:variable name="sierra" select='replace($sierra, "&apos;", "")'/>
    <xsl:variable name="sierra" select="replace($sierra, 'aʊ̯ktsɪoːn', 'aʊ̯kt͡si̯on')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'N', 'ŋ')"/> 
    <xsl:variable name="sierra" select="replace($sierra, '2', 'ø')"/>
    <xsl:variable name="sierra" select="replace($sierra, '9', 'œ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'U', 'ʊ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'R', 'ʀ')"/>
    <xsl:variable name="sierra" select="replace($sierra, '6', 'ɐ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'O', 'ɔ')"/>
    <xsl:variable name="sierra" select="replace($sierra, '@', 'ə')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'Y', 'ʏ')"/>
    <xsl:variable name="sierra" select="replace($sierra, ':', 'ː')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'I', 'ɪ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'i:', 'iː')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'S', 'ʃ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'gyltɪg', 'gʏltɪg')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'E', 'ɛ')"/>
    <xsl:variable name="sierra" select="replace($sierra, 'o:', 'oː')"/>
    <xsl:sequence select="$sierra"/>
 </xsl:variable>
 
 <xsl:variable name="sierra">
  <xsl:choose><!--
  <xsl:when test=""><xsl:value-of select="replace($sierra, '','')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '','')"/></xsl:when>-->
  <xsl:when test="contains(lower-case(../grapheme), 'zeug')"><xsl:value-of select="replace($sierra, 't͡sɔʏg','t͡sɔɪ̯g')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'maschine')"><xsl:value-of select="replace($sierra, 'maʃɪnə','maʃiːnə')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'system')"><xsl:value-of select="replace($sierra, 'zystəm','zysteːm')"/></xsl:when>
<!--  <xsl:when test="contains(lower-case(../grapheme), 'bürg')"><xsl:value-of select="replace($sierra, 'byʀg','bʏʀg')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'ventil')"><xsl:value-of select="replace($sierra, 'vəntiːl','vɛntiːl')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'technik')"><xsl:value-of select="replace($sierra, 'tɛçniːk','tɛçnɪk')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'verzeichnis')"><xsl:value-of select="replace($sierra, 'vɐt͡saɪ̯çnɪs','fɐt͡saɪ̯çnɪs')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'winkel')"><xsl:value-of select="replace($sierra, 'vɪnkəl','vɪŋkəl')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'fremd')"><xsl:value-of select="replace($sierra, 'fʀəmd','fʀɛmd')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'möglich')"><xsl:value-of select="replace($sierra, 'mœglɪç','møːglɪç')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'anstalt')"><xsl:value-of select="replace($sierra, 'anstalt','anʃtalt')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), 'bücher')"><xsl:value-of select="replace($sierra, 'byçɐ','byːçɐ')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'vertrag')"><xsl:value-of select="replace($sierra, 'vɐtʀaːk','fɐtʀaːk')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'verein')"><xsl:value-of select="replace($sierra, 'veːʀaɪ̯n','fɛʀaɪ̯n')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'speiche')
                  and not(contains(lower-case(../grapheme), 'sspeiche')
                  and not(contains($sierra, 't͡spaɪ̯ç'))"><xsl:value-of select="replace($sierra, 'spaɪ̯ç','ʃpaɪ̯ç')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), 'benzin')"><xsl:value-of select="replace($sierra, 'bɛnt͡sɪn','bɛnt͡siːn')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'versorgung')"><xsl:value-of select="replace($sierra, 'vɐzɔʀg','fɐzɔʀg')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), 'möglichkeit')"><xsl:value-of select="replace($sierra, 'mœglɪçkaɪ̯t','møːglɪçkaɪ̯t')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'koeffizient')"><xsl:value-of select="replace($sierra, 'køːfiːt͡sɪɛnt','koʔɛfiːtsɪɛnt')"/></xsl:when>-->
    <!--
    <xsl:when test="contains(lower-case(../grapheme), 'niveau')"><xsl:value-of select="replace($sierra, 'niːveːaʊ̯','niːvoː')"/></xsl:when>
    <xsl:when test="contains(lower-case(../grapheme), 'beständ')"><xsl:value-of select="replace($sierra, 'bɛstɛnd','bɛʃtɛnd')"/></xsl:when>
    <xsl:when test="contains(lower-case(../grapheme), 'eingang')"><xsl:value-of select="replace($sierra, 'aɪ̯ŋaŋ','aɪ̯ŋgaŋ')"/></xsl:when>
    <xsl:when test="contains(lower-case(../grapheme), 'versuch')"><xsl:value-of select="replace($sierra, 'vɐzuːx','fɐzuːx')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'spiel')
  and not(contains(lower-case(../grapheme), 'sspiel'))"><xsl:value-of select="replace($sierra, 'spiːl','ʃpiːl')"/></xsl:when>

  
  <xsl:when test="contains(lower-case(../grapheme), 'sschwäche')"><xsl:value-of select="replace($sierra, 'çvɛçə','ʃvɛçə')"/></xsl:when>

<xsl:when test="contains(lower-case(../grapheme), 'gedanken')"><xsl:value-of select="replace($sierra, 'gədankən','gədaŋkən')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'zeitungs')"><xsl:value-of select="replace($sierra, 't͡saɪ̯tʔʊng','t͡saɪ̯tʔʊŋ')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'graphik')"><xsl:value-of select="replace($sierra, 'gʀafiːk','gʀafɪk')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'angabe')"><xsl:value-of select="replace($sierra, 'aŋaːb','aŋgaːb')"/></xsl:when> 
  <xsl:when test="contains(../grapheme, 'spezifisch')
  and not(contains(../grapheme, 'sspezifisch'))
  and not(contains(../grapheme, 'tspezifisch'))"><xsl:value-of select="replace($sierra, 'speːt͡siːfɪʃ','ʃpeːt͡siːfɪʃ')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'berg')
  and not(contains(../grapheme, 'darüber'))"><xsl:value-of select="replace($sierra, 'bəʀg', 'bɛʀg')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'verfolgung')"><xsl:value-of select="replace($sierra, 'vɐfɔlgʊŋ', 'fɐfɔlgʊŋ')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'gehäuse')"><xsl:value-of select="replace($sierra, 'geːɔɪ̯zə', 'gəhɔɪ̯zə')"/></xsl:when>
  <xsl:when test="starts-with(../grapheme, 'vorz')
  and starts-with($sierra, 'foːʀt͡s')"><xsl:value-of select="replace($sierra, 'foːʀt͡s', 'foːɐ̯t͡s')"/></xsl:when>
  <xsl:when test="contains(lower-case(../grapheme), 'stöcke')"><xsl:value-of select="replace($sierra, 'stœk', 'ʃtœk')"/></xsl:when> 
  <xsl:when test="contains(../grapheme, 'angebot')"><xsl:value-of select="replace($sierra, 'aŋeːboːt', 'aŋgeːboːt')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'spiel')
  and not(contains($sierra, 't͡spiːl'))"><xsl:value-of select="replace($sierra, 'spiːl', 'ʃpiːl')"/></xsl:when>
  <xsl:when test="contains(../grapheme, 'vertrag')"><xsl:value-of select="replace($sierra, 'vɐtʀaːg', 'fɛʀtʀaːg')"/></xsl:when>
    <xsl:when test="ends-with(../grapheme, 'ständen')"><xsl:value-of select="replace($sierra, 'stɛnd', 'ʃtɛnd')"/></xsl:when>
  <xsl:when test="ends-with(../grapheme, 'zustand') 
  or ends-with (../grapheme, 'zustands')"><xsl:value-of select="replace($sierra, 't͡sʊstant', 't͡suːʃtant')"/></xsl:when>
  
    <xsl:when test="contains(lower-case(../grapheme), 'verwandt')"><xsl:value-of select="replace($sierra, 'vɐvant', 'fɐvant')"/></xsl:when>

  <xsl:when test="ends-with(lower-case(../grapheme), 'elnder')
   and ends-with($sierra, 'ntɐ')"><xsl:value-of select="replace($sierra, 'ntɐ', 'əlndɐ')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elndes')
   and ends-with($sierra, 'ntəs')"><xsl:value-of select="replace($sierra, 'ntəs', 'əlndəs')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elnden')
   and ends-with($sierra, 'ntən')"><xsl:value-of select="replace($sierra, 'ntən', 'əlndən')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elndem')
   and ends-with($sierra, 'ntəm')"><xsl:value-of select="replace($sierra, 'ntəm', 'əlndəm')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'elnde')
   and ends-with($sierra, 'ntə')"><xsl:value-of select="replace($sierra, 'ntə', 'əlndə')"/></xsl:when> 
  <xsl:when test="contains(lower-case(../grapheme), 'magazin')"><xsl:value-of select="replace($sierra, 'magat͡sɪn', 'magat͡siːn')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'vermögen')"><xsl:value-of select="replace($sierra, 'vɐmøːgən', 'fɛʀmøːgən')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'verhalten')"><xsl:value-of select="replace($sierra, 'vɐhalt', 'fɐhalt')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'verlauf')"><xsl:value-of select="replace($sierra, 'vɐlaʊ̯f', 'fɐlaʊ̯f')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'strom')"><xsl:value-of select="replace($sierra, 'stʀoːm', 'ʃtʀoːm')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'staat')"><xsl:value-of select="replace($sierra, 'staːt', 'ʃtaːt')"/></xsl:when>-->
   <xsl:otherwise><xsl:sequence select="$sierra"/></xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 

 <xsl:sequence select="$sierra"/>

</xsl:template>

<!-- June 2010 -->
<xsl:template name="display-value-of-role-attribute">
 <xsl:variable name="terminal">
  <xsl:value-of select="@role"/>
 </xsl:variable>
 <xsl:variable name="terminal">
 <xsl:choose>
  <xsl:when test="$terminal=''">
  <xsl:if test="ends-with(grapheme, 'ender')">
    <xsl:text>Adjektiv</xsl:text>
   </xsl:if><!---->
          <xsl:if test="ends-with(grapheme, 'ern')">
    <xsl:text>Verb</xsl:text>
   </xsl:if>
     <xsl:if test="ends-with(grapheme, 'gehst')">
    <xsl:text>Verb Singular Gegenwart Indikativ</xsl:text>
   </xsl:if><!--
   <xsl:if test="ends-with(grapheme, 'endem')">
    <xsl:text>Adjektiv Dativ Singular</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'enden')">
    <xsl:text>Adjektiv Akkusativ</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'endes')">
    <xsl:text>Adjektiv Neutrum</xsl:text>
   </xsl:if>
   <xsl:if test="ends-with(grapheme, 'test')">
    <xsl:text>Verb Singular Imperfekt KonjunktivII</xsl:text>
   </xsl:if>
    <xsl:if test="ends-with(grapheme, 'endes')">
    <xsl:text>Adjektiv Neutrum</xsl:text>
   </xsl:if>-->
   
  </xsl:when><!--
  <xsl:when test="$terminal='vi'"><xsl:text>Verb</xsl:text></xsl:when>-->
  <xsl:when test="$terminal='v'"><xsl:text>Verb</xsl:text></xsl:when>
  <xsl:when test="$terminal='a'"><xsl:text>Adjektiv</xsl:text></xsl:when>
  <xsl:when test="$terminal='z'"><xsl:text>Zahlwort</xsl:text></xsl:when><!--
  <xsl:when test="$terminal='vs'"><xsl:text>Verb Singular</xsl:text></xsl:when>
  <xsl:when test="$terminal='vp'"><xsl:text>Verb Plural</xsl:text></xsl:when>-->
    <xsl:when test="$terminal='s'"><xsl:text>Substantiv</xsl:text></xsl:when>
  <xsl:when test="contains($terminal, ' ')"><xsl:sequence select="substring-before($terminal, ' ')"/></xsl:when>
  <xsl:otherwise><xsl:value-of select="@role"/></xsl:otherwise>
 </xsl:choose>
 </xsl:variable>
 <xsl:sequence select="$terminal"/><!---->
</xsl:template>

<!--  -->

 <!-- June 2010 ADDITIONAL -->
<xsl:template name="generate-additional-phoneme-element">
 <xsl:param name="improved-phoneme-element"></xsl:param><!---->

  <xsl:variable name="sierra"><xsl:sequence select="$improved-phoneme-element"/></xsl:variable>
  <xsl:variable name="sierra">
   <xsl:choose><!--
   <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '', '')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '', '')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '', '')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '', '')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), '')"><xsl:value-of select="replace($sierra, '', '')"/></xsl:when> -->
   <xsl:when test="contains(lower-case(../grapheme), 'angabe')"><xsl:value-of select="replace($sierra, 'aŋgaːb', 'angaːb')"/></xsl:when> 
   <xsl:when test="contains(lower-case(../grapheme), 'eingabe')"><xsl:value-of select="replace($sierra, 'aɪ̯ŋgaːb', 'aɪ̯ngaːb')"/></xsl:when> 
 
   <xsl:when test="contains(lower-case(../grapheme), 'konkurs')"><xsl:value-of select="replace($sierra, 'kɔnkʊʀ', 'kɔŋkʊʀ')"/></xsl:when>
   <xsl:when test="contains(../grapheme, 'angebot')"><xsl:value-of select="replace($sierra, 'aŋgeːboːt', 'angeːboːt')"/></xsl:when>
   <xsl:when test="ends-with(lower-case(../grapheme), 'ar')"><xsl:value-of select="replace($sierra, 'aːʀ', 'aːɐ̯')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ars')"><xsl:value-of select="replace($sierra, 'aːʀs', 'aːɐ̯s')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'aren')"><xsl:value-of select="replace($sierra, 'aːʀən', 'aːɐ̯n')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierendes')"><xsl:value-of select="replace($sierra, 'iːʀəndəs', 'iːɐ̯ndəs')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierender')"><xsl:value-of select="replace($sierra, 'iːʀəndɐ', 'iːɐ̯ndɐ')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierendem')"><xsl:value-of select="replace($sierra, 'iːʀəndəm', 'iːɐ̯ndəm')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierende')"><xsl:value-of select="replace($sierra, 'iːʀəndə', 'iːɐ̯ndə')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'uren')
   and not(ends-with(../grapheme, 'äuren'))"><xsl:value-of select="replace($sierra, 'uːʀən', 'uːɐ̯n')"/></xsl:when>  
   <xsl:when test="ends-with(lower-case(../grapheme), 'üren')"><xsl:value-of select="replace($sierra, 'yːʀən', 'yːɐ̯n')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'ür')"><xsl:value-of select="replace($sierra, 'yːʀ', 'yːɐ̯')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'schen')"><xsl:value-of select="replace($sierra, 'ʃən', 'ʃn̩')"/></xsl:when> 
   <xsl:when test="ends-with(lower-case(../grapheme), 'ur')
   and not(ends-with(../grapheme, 'eur'))"><xsl:value-of select="replace($sierra, 'uːʀ', 'uːɐ̯')"/></xsl:when> 
                  
   <xsl:when test="ends-with(lower-case(../grapheme), 'ben')"><xsl:value-of select="replace($sierra, 'bən', 'bm̩')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'bens')"><xsl:value-of select="replace($sierra, 'bəns', 'bm̩s')"/></xsl:when>
   <xsl:when test="ends-with(../grapheme, 'gens') and
   not(ends-with(../grapheme, 'ngens'))"><xsl:value-of select="replace($sierra, 'gəns', 'gŋ̩s')"/></xsl:when>
   
   <xsl:when test="ends-with(../grapheme, 'gen') and
   not(ends-with(../grapheme, 'ngen'))"><xsl:value-of select="replace($sierra, 'gən', 'gŋ̩')"/></xsl:when>
   <xsl:when test="ends-with(lower-case(../grapheme), 'ier') and
   ends-with(., 'iːʀ') and
   not(ends-with(../grapheme, 'eier'))"><xsl:value-of select="replace($sierra, 'iːʀ', 'iːɐ̯')"/></xsl:when>
   <xsl:when test="ends-with(lower-case(../grapheme), 'ierens')"><xsl:value-of select="replace($sierra, 'iːʀəns', 'iːɐ̯n̩s')"/></xsl:when>
   <xsl:when test="contains(lower-case(../grapheme), 'augenblick') or 
   contains(lower-case(../grapheme), 'augenbraue') or
   starts-with((../grapheme), 'Augen')"><xsl:value-of select="replace($sierra, 'aʊ̯gən', 'aʊ̯gŋ̩')"/></xsl:when>
   <xsl:otherwise><xsl:sequence select="$sierra"/></xsl:otherwise>
   </xsl:choose>
  </xsl:variable>

  <xsl:if test="not($improved-phoneme-element eq $sierra)">
   <xsl:sequence select="$sierra"/>
  </xsl:if>
</xsl:template>

<!-- May 2010 not used any more -->


<!-- June 2010 not used any more -->


<!-- May 2010 -->
<xsl:template name="create-german-grapheme-element">
 <xsl:variable name="current-grapheme">
 <xsl:text>
  </xsl:text>
  <xsl:element name="grapheme">
   <xsl:value-of select="."/>
  </xsl:element>
 </xsl:variable>
 <xsl:sequence select="$current-grapheme"/>
</xsl:template>

</xsl:stylesheet>
<!--	This style-sheet is licensed under the GPLv3.
	    Read the full license text: http://script.blau.in/etc/GPL_License -->

