Exemple #1
0
        public IndicAkshar[] Split(string s)
        {
            IndicAkshar[] IA = null;
            try
            {
                string[] retVal = new string[s.Length];
                int      cnt    = 0;

                string lockedString = "";

                char   lastChar       = ' ';
                string lastCharNature = "a";
                bool   released       = false;
                for (int i = 0; i < s.Length; i++)
                {
                    released = false;
                    char currChar = StringPlus.CharAt(s, i);

                    IndicChar I = _ic.NewChar;
                    I.CharSet  = CharSet;
                    I.BaseChar = currChar;

                    if (currChar == this.CharSet.Special2)
                    {
                        if (cnt >= 1)
                        {
                            retVal[cnt - 1] = retVal[cnt - 1] + currChar;
                            continue;
                        }
                    }


                    string currCharNature = I.CharNature;
                    bool   CanIRelase     = CanRelease(currCharNature, lastCharNature);

                    if (CanIRelase)
                    {
                        bool CanImmRelase = IsImmRelease(currCharNature);
                        if (CanImmRelase)
                        {
                            if (lockedString != "")
                            {
                                retVal[cnt++] = lockedString;
                            }
                            lockedString = currChar.ToString();
                            released     = false;
                        }
                        else
                        {
                            #region NotImmRElease
                            if (I.IsSpecialFinishing || I.IsNeutral)
                            {
                                #region SpecialCharFinishing
                                if (lockedString == "")
                                {
                                    try
                                    {
                                        retVal[cnt - 1] = retVal[cnt - 1] + lockedString + currChar;
                                    }
                                    catch
                                    {
                                        throw new Exception("Invalid Lang Char ");
                                    }
                                }
                                else
                                {
                                    retVal[cnt++] = lockedString + currChar;
                                }
                                #endregion
                            }
                            else
                            {
                                if (!I.CanIgonre)
                                {
                                    lockedString = lockedString + currChar;
                                    if (lockedString != "")
                                    {
                                        retVal[cnt++] = lockedString;
                                    }
                                }
                                else
                                {
                                    if (lockedString != "")
                                    {
                                        retVal[cnt++] = lockedString;
                                    }
                                    retVal[cnt++] = currChar.ToString();
                                }
                            }
                            lockedString = "";
                            released     = true;
                            #endregion
                        }
                        lastChar       = ' ';
                        lastCharNature = currCharNature;
                    }

                    else
                    {
                        lastChar       = currChar;
                        lockedString   = lockedString + currChar;
                        lastCharNature = currCharNature;
                    }
                }
                if (!released)
                {
                    retVal[cnt++] = lockedString;
                }

                IA = new IndicAkshar[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    IA[i] = new IndicAkshar();
                    IA[i].SetChars(retVal[i], this.CharSet);
                }
            }
            catch
            {
            }
            return(IA);
        }
Exemple #2
0
        public string GetSymbol()
        {
            try
            {
                //To be modified...
                int    c      = 0;
                string Symbol = "";
                #region When No items Return Balnk Symbol
                if (_ic.Length == 0)
                {
                    Symbol = "";
                    return(Symbol);
                }
                #endregion

                #region Handle Single Achchu & Hallu.. Number, Stranger
                if (_ic.Length == 1)
                {
                    if (_ic[0].IsNewLine)
                    {
                        return("\n");
                    }
                    if (_ic[0].IsSmallAchchu)
                    {
                        return(Symbols.LAGHUVU);
                    }
                    if (_ic[0].IsLongAchchu)
                    {
                        return(Symbols.GURUVU);
                    }

                    if (_ic[0].IsHallu)
                    {
                        return(Symbols.LAGHUVU);
                    }

                    if (_ic[0].IsStranger || _ic[0].IsNumber)
                    {
                        Symbol = "?";
                        return(Symbol);
                    }
                }
                #endregion

                #region More than One and  Has Special or Long Finishhing Return GURUVU  Can't determine whether it can change prec or not..
                if (_ic.Length == 2)
                {
                    IndicChar Chr = _ic[1];
                    if (Chr.IsSpecialFinishing || Chr.IsLongFinishing || Chr.IsLongAchchu)
                    {
                        AlwaysGuruvu = true;
                        Symbol       = Symbols.GURUVU;
                        return(Symbol);
                    }
                }
                #endregion


                int p         = 0;
                int lastPollu = -1;
                for (int i = 0; i < _ic.Length; i++)
                {
                    IndicChar Chr = _ic[i];

                    #region If Neutral Continue
                    if (Chr.IsNeutral)
                    {
                        continue;
                    }
                    #endregion

                    #region if Has Pollu Probable is GURUVU
                    if (Chr.IsPollu)
                    {
                        Symbol = Symbols.GURUVU;
                        p++;
                        lastPollu = i;
                        //return Symbol;
                    }
                    #endregion

                    #region Count How many Hallu are there?
                    if (Chr.IsHallu)
                    {
                        c++;
                    }
                    #endregion

                    #region May be not part of Code Path Can be Removed later.
                    if (Chr.IsStranger || Chr.IsNumber)
                    {
                        Symbol = "?";
                        return(Symbol);
                    }
                    if (Chr.IsSpecialFinishing)
                    {
                        ChangePrev   = true;
                        AlwaysGuruvu = true;
                        if (RephEnable && lastPollu != -1 && this.Chars.Length > lastPollu + 1 && Chars[lastPollu + 1].BaseChar == Chr.CharSet.Reph)
                        {
                            ChangePrev = false;                            //Don't override if it's  'Reph'
                        }
                        Symbol = Symbols.GURUVU;
                        return(Symbol);
                    }
                    #endregion

                    if (Chr.IsLongFinishing)
                    {
                        ChangePrev   = true;
                        AlwaysGuruvu = true;
                        if (RephEnable && lastPollu != -1 && this.Chars.Length > lastPollu + 1 && Chars[lastPollu + 1].BaseChar == Chr.CharSet.Reph)
                        {
                            ChangePrev = false;                            //Don't override if it's  'Reph'
                        }
                        Symbol = Symbols.GURUVU;
                        return(Symbol);
                    }

                    if (Chr.IsLongAchchu)
                    {
                        ChangePrev   = true;
                        AlwaysGuruvu = true;
                        if (RephEnable && lastPollu != -1 && this.Chars.Length > lastPollu + 1 && Chars[lastPollu + 1].BaseChar == Chr.CharSet.Reph)
                        {
                            ChangePrev = false;                            //Don't override if it's  'Reph'
                        }
                        Symbol = Symbols.GURUVU;
                        return(Symbol);
                    }

                    if (Chr.CanIgonre)
                    {
                        if (Chr.IsSpace)
                        {
                            Symbol = " ";
                            return(Symbol);
                        }
                        Symbol = "";
                    }
                }

                #region if There are more than one Hallu then return LAGHUVU  Prev to be modified
                if (c > 1)
                {
                    ChangePrev = true;                    //PrevChar Symbol will be overided
                    if (RephEnable && lastPollu != -1 && this.Chars.Length > lastPollu + 1 && Chars[lastPollu + 1].BaseChar == Chars[lastPollu + 1].CharSet.Reph)
                    {
                        ChangePrev = false;                        //Don't override if it's  'Reph'
                    }
                    Symbol = Symbols.LAGHUVU;
                    return(Symbol);
                }
                #endregion

                if (!AlwaysGuruvu)
                {
                    Symbol = Symbols.LAGHUVU;
                    return(Symbol);
                }
            }
            catch
            {
                return("?");
            }
            return(Symbols.LAGHUVU);
        }