Beispiel #1
0
    private bool PrasaCheck(string s1, string s2)
    {
        YatiPrasaChecker2 Y = new YatiPrasaChecker2( );
        bool f = Y.IsPrasaMatched(s1, s2);

        return(f);
    }
Beispiel #2
0
    private bool YatiCheck(string s1, string s2, bool Sandhi)
    {
        YatiPrasaChecker2 Y = new YatiPrasaChecker2( );

        Y.SoundexSandhi = Sandhi;
        bool f = Y.IsYatiMatched(s1, s2);

        return(f);
    }
Beispiel #3
0
        private string Write(Rule Rule)
        {
            R = new Random();
            Y = new YatiPrasaChecker2();

            string s = Rule.Identifier == "kandam" ? GenerateKandam() : GenerateVruttam(Rule);

            return(s);
        }
Beispiel #4
0
        //private List<Range> GetList (string tag , string s)
        //{
        //    List<Range> R= new List<Range> ( );
        //    int last=0;
        //    while ( last < s.Length && s.IndexOf ( "<" + tag + ">" , last ) != -1 )
        //    {
        //        int from =s.IndexOf ( "<" + tag + ">" , last );
        //        int to=s.IndexOf ( "</" + tag + ">" , last );

        //        Range _R= new Range ( );
        //        _R.From = from+1;
        //        _R.Length = to - from;

        //        R.Add ( _R );
        //        last = to + 4;
        //    }
        //    return R;
        //}



        internal void VerifyYati()
        {
            Console.WriteLine("Yati Check...");

            int               s         = 0;
            int               fa        = 0;
            char              seperator = '\t';
            StreamReader      SR        = new StreamReader("Yati.txt");
            StreamWriter      SS        = new StreamWriter("Yati_Pass.txt");
            StreamWriter      SF        = new StreamWriter("Yati_Fail.txt");
            YatiPrasaChecker2 Y         = new YatiPrasaChecker2( );

            while (!SR.EndOfStream)
            {
                string   line = SR.ReadLine( );
                string[] j    = line.Split(seperator);
                if (j.Length > 2)
                {
                    string y1 = j[0];
                    string y2 = j[1];
                    string y3 = j[2];


                    bool f = Y.IsYatiMatched(y1, y2);
                    if (f)
                    {
                        SS.WriteLine(y1 + "|" + y2 + "");
                        SS.Flush( );
                        s++;
                    }
                    else
                    {
                        SF.WriteLine(y1 + "|" + y2 + "|" + y3);
                        SF.Flush( );
                        fa++;
                    }
                }
            }
            SS.Close( );
            SF.Close( );
            Console.WriteLine("Pass: "******"Fail: " + fa.ToString( ));
            Console.WriteLine("Tot: " + (s + fa).ToString( ));
        }
Beispiel #5
0
        private Errors CheckPrasaPoorva2(YatiPrasaChecker2 Y, Prasa p1, Prasa p2)
        {
            char SUNNA   = 'ం';
            char VISARGA = 'ః';

            if (StringPlus.CharAt(p1.Poorva, p1.Poorva.Length - 1) == SUNNA)
            {
                if (StringPlus.CharAt(p2.Poorva, p2.Poorva.Length - 1) == SUNNA)
                {
                    Y.LastName = (Y.LastName == null) ? "బిందుపూర్వక ప్రాసము" : Y.LastName + "(విసర్గపూర్వక ప్రాసము)";
                    return(null);
                }
                else
                {
                    Errors E = new Errors();
                    E.Actual   = p1.Value;
                    E.Expected = "'" + SUNNA + "'  తో కూడిన అక్షరం";
                    E.Mismatch = p1.IsAnthyaPrasa ? Mismatch.AnthyaPrasaPoorvaBindu : Mismatch.PrasaPoorvaBindu;
                    return(E);
                }
            }
            else
            {
                if (StringPlus.CharAt(p1.Poorva, p1.Poorva.Length - 1) == VISARGA)
                {
                    if (StringPlus.CharAt(p2.Poorva, p2.Poorva.Length - 1) == VISARGA)
                    {
                        Y.LastName = (Y.LastName == null) ? "విసర్గపూర్వక ప్రాసము" : Y.LastName + "(విసర్గపూర్వక ప్రాసము)";
                        return(null);
                    }
                    else
                    {
                        Errors E = new Errors();
                        E.Actual   = p1.Value;
                        E.Expected = "'" + VISARGA + "'  తో కూడిన అక్షరం";
                        E.Mismatch = p1.IsAnthyaPrasa ? Mismatch.AnthyaPrasaPoorvaVisarga : Mismatch.PrasaPoorvaVisarga;
                        return(E);
                    }
                }
            }
            return(null);
        }
Beispiel #6
0
    private string Build(string[][] M)
    {
        string            S = " ";
        YatiPrasaChecker2 Y = new YatiPrasaChecker2( );

        foreach (string[] s in M)
        {
            {
                bool f = Y.IsYatiMatched(s[2], s[3]);
                if (!f)
                {
                    S = S + "<tr" + (f ? " " : " style='color:red;'") + "><td>" + s[0] + "</td><td>" + s[1] + "</td><td>" + s[2] + "</td><td>" + s[3] + "</td><td>" + f.ToString( ) + "</td></tr>";
                }
            }
            {
                bool f = Y.IsYatiMatched(s[3], s[2]);
                if (!f)
                {
                    S = S + "<tr" + (f ? " " : " style='color:red;'") + "><td>" + s[0] + "</td><td>" + s[1] + "</td><td>" + s[3] + "</td><td>" + s[2] + "</td><td>" + f.ToString( ) + "</td></tr>";
                }
            }
        }
        return(S == " " ? "<h2>Perfect</h2>" : "<table>" + S + "</table>");
    }
Beispiel #7
0
        public string CheckPrasa(string s1, string s2, bool allowSantiPrasa)
        {
            YatiPrasaChecker2 Y = new YatiPrasaChecker2();

            s1 = s1.Replace(" ", "");
            s2 = s2.Replace(" ", "");

            Y.AllowSantiPrasa = allowSantiPrasa;
            Y.SoundexSandhi   = false;
            GanaVibhajana G1 = new GanaVibhajana(s1, lang);
            GanaVibhajana G2 = new GanaVibhajana(s2, lang);

            if (G1.GWiseString.Count == 0)
            {
                return("<span class='gName'>Group-1 is not valid</span>");
            }
            if (G2.GWiseString.Count == 0)
            {
                return("<span class='gName'>Group-2 is not valid</span>");
            }

            bool f = false;

            if (G1.GWiseString.Count > 1 && G2.GWiseString.Count > 1)
            {
                p1 = G1.GWiseString[0] + "<u>" + G1.GWiseString[1] + "</u>";
                p2 = G2.GWiseString[0] + "<u>" + G2.GWiseString[1] + "</u>";

                Prasa P1 = new Prasa(StringPlus.CharAt(G1.SymbolsStream, 0).ToString(), false, G1.GWiseString[1], G1.GWiseString[0]);
                Prasa P2 = new Prasa(StringPlus.CharAt(G2.SymbolsStream, 0).ToString(), false, G2.GWiseString[1], G2.GWiseString[0]);

                f = Y.IsPrasaMatched3(P1, P2);

                if (f && Y.NoMoreChecks)
                {
                    return(Success(p1, p2, PRASA, Y.LastName));
                }

                if (f)
                {
                    if (P1.Symbol == Symbols.LAGHUVU)
                    {
                        //Nothing to do..
                    }
                    else
                    {
                        f = (P1.Symbol == P2.Symbol);
                    }
                }


                if (f)
                {
                    Errors E = CheckPrasaPoorva2(Y, P1, P2);
                    if (E == null)
                    {
                        return(Success(p1, p2, PRASA, Y.LastName));
                    }
                    return(FailWith(p1, p2, E, PRASA));
                }
                else
                {
                    return(FailWith(p1, p2, null, PRASA));
                }
            }
            else
            {
                p1 = G1.GWiseString[0];
                p2 = G2.GWiseString[0];
                f  = Y.IsPrasaMatched(p1, p2);
                if (f)
                {
                    return(Success(p1, p2, PRASA, Y.LastName));
                }
            }
            return(FailWith(p1, p2, null, PRASA));
        }
Beispiel #8
0
        public string CheckYati(string s1, string s2, bool Sandhi)
        {
            GanaVibhajana G1 = new GanaVibhajana(s1, lang);
            GanaVibhajana G2 = new GanaVibhajana(s2, lang);


            if (G1.GWiseString.Count == 0)
            {
                return("<span class='gName'>Group-1 is not valid</span>");
            }
            if (G2.GWiseString.Count == 0)
            {
                return("<span class='gName'>Group-2 is not valid</span>");
            }

            string c1  = null;
            string y1  = null;
            string py1 = null;

            string c2  = null;
            string y2  = null;
            string py2 = null;

            YatiPrasaChecker2 YPC = new YatiPrasaChecker2();

            YPC.SoundexSandhi = Sandhi;

            #region ...
            if (G1.GWiseString.Count == 3)
            {
                c1  = StringPlus.EndsWith(G1.GWiseString[0], 'ం') ? "ం" : null;
                y1  = G1.GWiseString[1];
                py1 = G1.GWiseString[2];
                p1  = (c1 != null) ? G1.GWiseString[0] + G1.GWiseString[1] : G1.GWiseString[1];
                p1  = p1 + G1.GWiseString[2];
            }

            if (G1.GWiseString.Count == 2)
            {
                c1 = StringPlus.EndsWith(G1.GWiseString[0], 'ం') ? "ం" : null;
                y1 = G1.GWiseString[1];
                p1 = (c1 != null) ? G1.GWiseString[0] + G1.GWiseString[1] : G1.GWiseString[1];
            }

            if (G2.GWiseString.Count == 3)
            {
                c2  = StringPlus.EndsWith(G2.GWiseString[0], 'ం') ? "ం" : null;
                y2  = G2.GWiseString[1];
                py2 = G2.GWiseString[2];
                p2  = (c2 != null) ? G2.GWiseString[0] + G2.GWiseString[1] : G2.GWiseString[1];
                p2  = p2 + G2.GWiseString[2];
            }
            if (G1.GWiseString.Count == 1)
            {
                y1 = G1.GWiseString[0];
                p1 = G1.GWiseString[0];
            }

            if (G2.GWiseString.Count == 2)
            {
                c2 = StringPlus.EndsWith(G2.GWiseString[0], 'ం') ? "ం" : null;
                y2 = G2.GWiseString[1];
                p2 = (c2 != null) ? G2.GWiseString[0] + G2.GWiseString[1] : G2.GWiseString[1];
            }
            if (G2.GWiseString.Count == 1)
            {
                y2 = G2.GWiseString[0];
                p2 = G2.GWiseString[0];
            }
            #endregion

            bool res = YPC.IsYatiMatched(p1, p2);
            if (res)
            {
                return(Success(p1, p2, YATI, YPC.LastName));
            }
            else
            {
                //Context not matched  so prepare for Prasa Yati

                if (G1.GWiseString.Count == 2)
                {
                    y1  = G1.GWiseString[0];
                    py1 = G1.GWiseString[1];
                }

                if (G2.GWiseString.Count == 2)
                {
                    y2  = G2.GWiseString[0];
                    py2 = G2.GWiseString[1];
                }

                res = YPC.IsYatiMatched(y1, y2);
                if (res)
                {
                    return(Success(y1, y2, YATI, YPC.LastName));
                }
                else
                {
                    string s = FailWith(p1, p2, null, YATI);
                    if (G1.GWiseString.Count > 1 && G2.GWiseString.Count > 1)
                    {
                        s = s + "<br/>అందువల్ల ప్రాస యతి సరి పోతుందేమో చూస్తున్నా<br/>";
                        s = s + CheckPrasa(py1, py2, false);
                    }
                    return(s);
                }
            }
        }