Example #1
0
        private void Dump(int tot)
        {
            StreamWriter SW = new StreamWriter("Vruttas2Jati.txt", false, Encoding.UTF8);

            SW.WriteLine("<Total Vrutta's Considered :" + tot + ">");
            SW.WriteLine("<Total Vrutta's Found which can be translated as  Jati :" + Dict.Count + ">");
            SW.WriteLine("Percentage :" + ((Dict.Count * 100) / tot).ToString("0.0"));
            SW.WriteLine("");


            int cnt = 1;

            foreach (KeyValuePair <string, V2R> KVP in Dict)
            {
                V2R  V = KVP.Value;
                Rule R = V.Rule;
                SW.WriteLine((cnt++) + " " + R.Name + " : [" + R.ChandamName + (R.ChandamNumber > 0 ? "(" + R.CharLength + ")" : "") + " " + R.Identifier + "] >> " + R.Sequence);
                for (int i = 0; i < V.Sequences.Count; i++)
                {
                    SW.WriteLine("\t" + V.Mode[i] + " >> " + V.Sequences[i] + " >> " + V.GSequences[i]);
                }
                SW.WriteLine(" ");
            }

            SW.Close();
        }
Example #2
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
            }
        }