示例#1
0
        private static string RuleText(RuleType ruleType, object o)
        {
            switch (ruleType)
            {
            case RuleType.Name:
            {
                return(GDefinition.GAlias(( string )o));
            }

            case RuleType.Type:
            {
                Category Cat = ( Category )o;
                return(Helper.CategoryString(Cat));
            }

            case RuleType.SubType:
            {
                SubCategory Cat = ( SubCategory )o;
                return(Helper.SubCategoryString(Cat));
            }

            case RuleType.Weight:
            {
                int Cat = ( int )o;
                return(Cat.ToString( ) + " మాత్రలు");
            }

            default:
            {
                return("తెలియదు");
            }
            }
        }
示例#2
0
        private bool CanFound(string seq, Mode mode, ref Category gType, ref int i, ref string curr)
        {
            bool found = false;

            switch (mode)
            {
            case Mode.SuryaIndra:
                if (gType == Category.Indra || gType == Category.Surya)
                {
                    found = true;
                }
                break;

            case Mode.OnlyIndra:
                if (gType == Category.Indra)
                {
                    found = true;
                }
                break;

            case Mode.OnlySurya:
                if (gType == Category.Surya)
                {
                    found = true;
                }
                break;

            case Mode.IndraSurya:
                if (gType == Category.Surya && i + 1 < seq.Length)
                {
                    curr  = curr + seq[i + 1];
                    gType = GDefinition.GetType(curr);
                    i++;
                    found = true;
                }
                else if (gType == Category.Indra || gType == Category.Surya)
                {
                    found = true;
                }
                break;

            case Mode.Any:
                //Surya: UI  III
                //Indra: Surya+I,Surya+U
                //Indra: UUI,IIUI
                if (gType == Category.Surya && i + 1 < seq.Length)
                {
                    curr  = curr + seq[i + 1];
                    gType = GDefinition.GetType(curr);
                    i++;
                    found = true;
                }
                else if (gType == Category.Indra)
                {
                    found = true;
                }
                break;
            }
            return(found);
        }
示例#3
0
        private void Go(int pos, string preFix)
        {
            foreach (int item in items)
            {
                string s = SubString(_input, pos, item);

                if (s == "")
                {
                    if (preFix.Replace("-", "").Length == _input.Length && !Patterns.Contains(preFix))
                    {
                        Patterns.Add(preFix);
                        Debug.WriteLine(preFix);
                    }
                }
                else
                {
                    Category2 gType = GDefinition.GetType2(s);
                    //if (gType == Category.Indra || gType == Category.Surya)
                    if (gType == Category2.Brahma || gType == Category2.Vishnu)
                    {
                        string next = Next(preFix, s);
                        Go(pos + item, next);
                    }
                }
            }
        }
示例#4
0
        private string GetSequenceName(string seq)
        {
            string g = "";

            foreach (string s in seq.Split('-'))
            {
                Category2 gType = GDefinition.GetType2(s);
                g = (g + "-" + gType.ToString());
            }
            return(g.TrimStart('-').TrimEnd('-'));
        }
示例#5
0
        private string StringWithList(int w, List <string> whiteList)
        {
            string s  = "";
            string nm = "";

            while (!whiteList.Contains(nm))
            {
                s = StringWith_i(w);
                GanaVibhajana G = new GanaVibhajana(s, lang);
                nm = GDefinition.GName(G.SymbolsStream.Replace(" ", "")).Trim();
            }
            return(s);
        }
示例#6
0
        private string StringWith2(int w, string blackList)
        {
            string s  = "";
            string nm = blackList;

            while (nm == blackList)
            {
                s = StringWith_i(w);
                GanaVibhajana G = new GanaVibhajana(s, lang);
                nm = GDefinition.GName(G.SymbolsStream.Replace(" ", "")).Trim();
            }
            return(s);
        }
示例#7
0
        private string PrasaString3(int w, string prasa, string blackList)
        {
            string s  = "";
            string nm = blackList;

            while (nm == blackList)
            {
                s = PrasaString(w, prasa);
                GanaVibhajana G = new GanaVibhajana(s, lang);
                nm = GDefinition.GName(G.SymbolsStream.Replace(" ", "")).Trim();
            }
            return(s);
        }
示例#8
0
        private string YatiString3(int w, string yati, string blackList)
        {
            string s  = "";
            string nm = blackList;

            while (nm == blackList)
            {
                s = YatiString2(w, yati);
                GanaVibhajana G = new GanaVibhajana(s, lang);
                nm = GDefinition.GName(G.SymbolsStream.Replace(" ", "")).Trim();
            }
            return(s);
        }
示例#9
0
        private string StringWith1(string nm)
        {
            int    thresold = GDefinition.Threshold2(nm);
            string curr     = nm;
            string s        = "";     //Can be done in a very Better way
            string sym      = GDefinition.GetSymbols(nm);

            s = "";
            for (int i = 0; i < thresold; i++)
            {
                int      index    = sym[i] == '|' ? 0 : 1;
                string[] Selected = W[index];
                string   t        = Selected[R.Next(Selected.Length)];
                s = s + (i == 0 ? "" : ",") + t;
            }

            return(s + " ");
        }
示例#10
0
        private void Eval(List <Rule> Rules, Mode mode)
        {
            #region Init..
            string curr    = "";
            string ns      = "";
            string gs      = "";
            string lastSeq = "";
            int    len     = 0;
            bool   found   = false;
            #endregion
            foreach (Rule R in Rules)
            {
                #region Init..
                string seq = R.Sequence.Replace("-", "");
                curr    = "";
                ns      = "";
                gs      = "";
                len     = 0;
                lastSeq = "";
                found   = false;
                #endregion

                for (int i = 0; i < seq.Length; i++)
                {
                    curr = curr + seq[i];
                    Category gType = GDefinition.GetType(curr);
                    found = CanFound(seq, mode, ref gType, ref i, ref curr);
                    if (found)
                    {
                        lastSeq = curr;
                        ns      = ns + curr + "-";
                        gs      = gs + gType.ToString() + "-";
                        len     = len + curr.Length;
                        curr    = "";
                    }
                }

                if (!found)
                {
                    Category gType2 = GDefinition.GetType(lastSeq + curr);
                    if (gType2 == Category.Surya || gType2 == Category.Indra)
                    {
                        ns = ns.TrimEnd('-').TrimStart('-') + curr;
                        int li = gs.TrimEnd('-').TrimStart('-').LastIndexOf('-');
                        gs  = li == -1 ? gType2.ToString() : gs.Substring(0, li) + gType2.ToString();
                        len = len + curr.Length;
                    }
                }

                #region Wrap
                ns = ns.TrimEnd('-').TrimStart('-');
                gs = gs.TrimEnd('-').TrimStart('-');
                if (!string.IsNullOrEmpty(ns) && !string.IsNullOrEmpty(gs) && len == seq.Length)
                {
                    if (Dict.ContainsKey(R.Identifier))
                    {
                        V2R V = Dict[R.Identifier];
                        if (!V.Sequences.Contains(ns))
                        {
                            V.Mode.Add(mode);
                            V.Sequences.Add(ns);
                            V.GSequences.Add(gs);
                            Dict[R.Identifier] = V;
                        }
                    }
                    else
                    {
                        V2R V = new V2R();
                        V.Rule = R;
                        V.Mode.Add(mode);
                        V.Sequences.Add(ns);
                        V.GSequences.Add(gs);
                        Dict[R.Identifier] = V;
                    }
                }
                #endregion
            }
        }