private static string EvaluateAllRulesInternal(string title, string auth) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<ol class='ol'>"); int cnt = 1; int cnt2 = 1; foreach (Rule R in RuleHelper.GetAllRules(true)) { Console.WriteLine((cnt++) + ". " + R.Identifier); sb.AppendLine("<ol class='ol'>"); foreach (string s in R.Examples) { cnt2++; sb.AppendLine("<li>"); Padyam P = new Padyam(); P.MatchYati = false; P.MatchPrasa = true; MatchResult MR = P.Match(s, R); sb.Append(Build(MR, R, P)); sb.AppendLine("<li>"); } sb.AppendLine("</ol>"); } Console.WriteLine("Total Poems evaluated: " + cnt2); return(BuildFile(title, title, "", sb.ToString(), null)); }
public string Test3() { StringBuilder Sb = new StringBuilder(); List <Rule> L = RuleHelper.GetAllRules(true); { Type R = typeof(Rule); Type[] Types = GetTypes(); int count = 0; foreach (Type T in Types) { if (T.BaseType == R) { Rule R2 = (Rule)Activator.CreateInstance(T); if (R2.Identifier.ToLower() == "genricvruttam") { continue; } //Debug2.AppendLine ( R2.Name + "," + R2.PadyamType + "," + R2.PadyamSubType + "," + R2.CharLength ); count++; if (T.Namespace == "Library.Chandam.Sans") { if (R2.Yati.Length >= 1) { Debug2.AppendLine(R2.Name); continue; } //Sb.AppendLine ( "case "+R2.Identifier+": return new " + R2.Identifier + "();" ); Sb.AppendLine("new " + R2.Identifier + "(),"); } } } return(Sb.ToString()); } }
private string ListMissingData() { string s1 = ""; string s2 = ""; string s3 = ""; foreach (Rule R in RuleHelper.GetAllRules(true)) { bool f2 = R.Yati.Length > 0 || (R.PadyamType == PadyamType.Vruttam && R.CharLength <= 10); bool f1 = R.Examples.Length == 0; f2 = !f2; string h = "<li>" + R.Name + (R.ChandamName == "" ? "" : "(" + R.ChandamName + ")") + "</li>"; if (f1) { s1 = s1 + h; } if (f2) { s2 = s2 + h; } if (f1 && f2) { s3 = s3 + h; } } return("<h2>యతి+ఉదాహరణలు లేనివి</h2><ol>" + s3 + "</ol>" + "<h2>ఉదాహరణలు లేనివి</h2><ol>" + s1 + "</ol>" + "<h2>యతి లేనివి</h2><ol>" + s2 + "</ol>"); }
public static void InitRandomPoems() { foreach (Rule R in RuleHelper.GetAllRules(true)) { SamplePoems.Append(R.Examples); } }
private void EvaluateSampels() { List <string> Poems = new List <string>(); foreach (Rule R in RuleHelper.GetAllRules(true)) { foreach (Example s in R.Examples2) { Poems.Add(s.Text); } } Go(Poems.ToArray(), "ఛందం", "ఎందరో", "Chandassu"); }
public static void SetSortedList(bool includeRare) { int cnt = 0; Element E = Window.Document.GetElementById("list"); E.InnerHTML = ""; foreach (Rule R in SortHelper.SortByName(RuleHelper.GetAllRules(includeRare))) { Element O = Util.AddOptionItem(R.Name, R.Identifier, false); E.AppendChild(O); cnt++; } Document.GetElementById("totItems").InnerHTML = cnt.ToString() + "+"; }
private int[] GetYatiData() { //Debug.AppendLine ( "Missing Yati Data." ); int[] Examples = new int[] { 0, 0 }; foreach (Rule R in RuleHelper.GetAllRules(true)) { tot++; bool f = R.Yati.Length > 0 || (R.PadyamType == PadyamType.Vruttam && R.CharLength <= 10); if (f) { Examples[1]++; continue; } //Debug.AppendLine ( R.Name ); Examples[0]++; } return(Examples); }
private void IdentifyDuplicates(List <Rule> Rules) { Debug.WriteLine("New" + "-" + "CharLength" + "-" + "ChandamNumber" + "-" + "Old"); foreach (Rule R in Rules) { foreach (Rule R1 in RuleHelper.GetAllRules(true)) { if (R1.PadyamType != R.PadyamType || R.RowWiseRules || R1.RowWiseRules) { continue; } //if ( AreEqual ( R1.Rules , R.Rules ) ) if (R.CharLength == R1.CharLength && R.ChandamNumber == R1.ChandamNumber) { Debug.WriteLine(R.Name + "-" + R.CharLength + "-" + R.ChandamNumber + "-" + R1.Name); } } } }
private int[] GetExamplesData() { int[] Examples = new int[] { 0, 0, 0, 0, 0, 0, 0 }; //Debug.AppendLine ( "Missing Examples Data" ); foreach (Rule R in RuleHelper.GetAllRules(true)) { tot++; if (R.Examples.Length > 5) { Examples[6]++; continue; } if (R.Examples.Length == 0) { //Debug.AppendLine ( R.Name ); } Examples[R.Examples.Length]++; } return(Examples); }
public string Test2() { StringBuilder Sb = new StringBuilder(); StringBuilder Sb2 = new StringBuilder(); StringBuilder Sb3 = new StringBuilder(); StringBuilder Sb4 = new StringBuilder(); List <Rule> L = RuleHelper.GetAllRules(true); { Type R = typeof(Rule); Type[] Types = GetTypes(); int count = 0; foreach (Type T in Types) { if (T.BaseType == R) { Rule R2 = (Rule)Activator.CreateInstance(T); if (R2.Identifier.ToLower() == "genricvruttam") { continue; } Debug2.AppendLine(R2.Name + "," + R2.PadyamType + "," + R2.PadyamSubType + "," + R2.CharLength); count++; int expected = Helper.CalcThreshold(R2); int actual = R2.Threshold; if (actual != expected) { Sb.AppendLine(R2.Name + "- Wrong Thresold- Expected: " + expected + "-Actual:" + actual); } foreach (string s in R2.Examples) { if (string.IsNullOrEmpty(s)) { Sb.AppendLine(R2.Name + "- Has Blank Example.. " + R2.Identifier); } } if (R2.Identifier != T.Name) { Sb.AppendLine(T.Name + "- Wrong Identifier Actaul: " + R2.Identifier); } //if ( R2.ShortName != R2.Name ) //{ // Sb.AppendLine ( R2.Name + "- Wrong Short Name Actaul: " + R2.ShortName ); //} bool found = false; foreach (Rule R4 in L) { if (R2.GetType() == R4.GetType()) { found = true; } } if (!found) { Sb.AppendLine(T.Name + "- Not found "); Sb3.Append("new " + T.Name + "(),"); } Rule R3 = Manager.FetchRule(R2.Identifier); if (R3 == null) { Sb.AppendLine(T.Name + "- Get Item Not Exists"); Sb2.AppendLine("case \"" + T.Name + "\": return new " + T.Name + "();"); } else { if (R2.GetType() != R3.GetType()) { Sb.AppendLine(T.Name + "- Wrong Get Item"); Sb2.AppendLine("case \"" + T.Name + "\": return new " + T.Name + "();"); } } } } if (count != L.Count) { Sb.AppendLine("No. of Items are not matching..."); } if (Sb.ToString() == "") { Sb.AppendLine("Perfect and Total Items are " + count); } } Sb.Append(Sb2.ToString()); Sb.Append(Sb3.ToString()); return(Sb.ToString()); }
public static string Scores(string s, MatchOptions Options) { GanaVibhajana G = new GanaVibhajana(s, Options.Language); bool includeRare = Options.IncludeRare; int min = G.Min; int max = G.Max; includeRare = true; List <Rule> Rules = Options.QuickMatch ? RuleHelper.GetAllRules2(min, max, G.PreLines) : RuleHelper.GetAllRules(includeRare); List <MatchResult> L = new List <MatchResult>(); foreach (Rule R in Rules) { Padyam P = new Padyam(); P.MatchYati = Options.MatchYati; P.MatchPrasa = Options.MatchPrasa; P.AllowSantiPrasa = Options.AllowSantiPrasa; P.SandiMatch = Options.ExperimenatalSandhi; MatchResult MR = P.Match(s, R); L.Add(MR); P = null; } string s2 = BuildAllScores(L); { L = null; } return(s2); }