Exemplo n.º 1
0
        Parse(string s)
        {
            var lst = new List <AltMSyl> ();
            int idx = 0;
            int noiseStart = -1, noiseCount = 0;

            while (idx < s.Length)
            {
                MSyl syl = MunchSyllable(s, ref idx);
                if (syl == MSyl.Default)
                {
                    if (noiseStart < 0)
                    {
                        noiseStart = idx;
                        noiseCount = 0;
                    }
                    idx++;
                    noiseCount++;
                }
                else
                {
                    if (noiseStart >= 0)
                    {
                        lst.Add(new AltMSyl(s.Substring(noiseStart, noiseCount)));
                        noiseStart = -1;
                    }
                    lst.Add(new AltMSyl(syl));
                }
            }
            if (noiseStart >= 0)
            {
                lst.Add(new AltMSyl(s.Substring(noiseStart)));
            }
            return(lst);
        }
Exemplo n.º 2
0
        Transcribe(MSyl syl)
        {
            string t = _tTrans[syl.Tone];

            syl.Tone = TONE.NEUTRAL;
            string s = base.Transcribe(syl);

            return(s + t);
        }
Exemplo n.º 3
0
        MunchSyllable(string s, ref int idx)
        {
            MSyl syl = base.MunchSyllable(s, ref idx);
            TONE t;

            if (_tDict.TryMatchStart(s, ref idx, out t))
            {
                syl.Tone = t;
            }
            return(syl);
        }
Exemplo n.º 4
0
        Transcribe(MSyl syl)
        {
            string init = "";
            INIT   i    = syl.Initial;
            TONE   t    = syl.Tone;

            if (t == TONE.NEUTRAL)
            {
                init = ".";
                t    = TONE.CLEAR;
            }

            try {
                if (i == INIT.Void)
                {
                    if (syl.Medial > MED._)
                    {
                        if (t > TONE.MUDDY && t < TONE.NEUTRAL || syl.Rime == RIME.ONG)                  //oblique forms
                        {
                            return(init + _ywObliqueTrans [new MRt(syl.Rime, t)]);
                        }
                    }
                }
                else
                {
                    if (syl.InitialGroup == INITGROUP.GGRP && syl.IsPalatized)                      //gi ki hi gni
                    {
                        init += i == INIT.G ? "j" : i == INIT.K ? "ch" : i == INIT.H ? "sh" : "gn";
                    }
                    else
                    {
                        init += _iTrans [i];
                        if (i.IsSonorant())
                        {
                            if (syl.Tone == TONE.CLEAR)
                            {
                                init += "h";
                            }
                            else if (syl.Tone == TONE.MUDDY)
                            {
                                t = TONE.CLEAR;
                            }
                        }
                    }
                }

                return(init + _rTrans [new MRt(syl.Rime, t)]);
            } catch (Exception) {
                throw new ArgumentException(
                          string.Format("Try to transcribe a invalid mandarin syllable:{0} into GwoyeuRomatzyh!", syl));
            }
        }
Exemplo n.º 5
0
        Transcribe(MSyl syl)
        {
            var bpmf = new System.Text.StringBuilder();

            bpmf.Append((syl.IsPalatized && syl.InitialGroup == INITGROUP.GGRP) ?
                        _giGrp [syl.Initial] : _iTrans [syl.Initial]
                        );
            bpmf.Append(_mTrans [syl.Medial]);
            bpmf.Append(_fTrans [syl.Final]);
            bpmf.Append(_tTrans [syl.Tone]);

            return(bpmf.ToString());
        }
Exemplo n.º 6
0
        Transcribe(MSyl syl)
        {
            string start, end = "";
            INIT   i = syl.Initial;
            TONE   t = syl.Tone;
            MED    m = syl.Medial;
            RIME   r = syl.Rime;


            //initial
            if (i == INIT.Void && m != MED._)           //y w yu
            {
                return(_m0Trans[new MRt(r, t)]);
            }
            else if (syl.InitialGroup == INITGROUP.GGRP && syl.IsPalatized)           //j q x
            {
                start = _specInit[i];
                if (m == MED.IU && syl.Final != FIN.ENG)                //ü -> u but not iong
                {
                    r = (RIME)((byte)MED.U | (byte)syl.Final);          //ju qu xu
                }
            }
            else if (syl.InitialGroup == INITGROUP.TZGRP && m == MED.I && syl.Final == FIN.ZERO)            //zyi cyi syi
            {
                start = _specInit[i];
            }
            else
            {
                start = _miTrans[i];
            }

            //final
            _mfTrans.TryGetValue(new MRt(r, t), out end);

            return(start + end);
        }
Exemplo n.º 7
0
 public MImt(INIT i, MED m = MED._, TONE t = TONE.NEUTRAL)
 {
     _syl = new MSyl(i, m, FIN.ZERO, t);
 }
Exemplo n.º 8
0
 public MImt(MSyl syl)
 {
     _syl = syl;
 }
Exemplo n.º 9
0
 public AltMSyl(MSyl syl)
 {
     MSyl = syl; Noise = null;
 }
Exemplo n.º 10
0
 public AltMSyl(string noise)
 {
     Noise = noise; MSyl = MSyl.Default;
 }
Exemplo n.º 11
0
 public MRt(RIME rime, TONE tone)
 {
     _syl = new MSyl((byte)tone, (byte)rime);
 }
Exemplo n.º 12
0
 public MRt(FIN fin, MED med = MED._, TONE tone = TONE.NEUTRAL)
 {
     _syl = new MSyl(INIT.Void, med, fin, tone);
 }