Beispiel #1
0
        public static string Build(Poem Poem, MatchOptions Options, OutputOptions OO)
        {
            if (Poem == null)
            {
                return("");
            }
            if (Poem.Text.Trim().Length == 0)
            {
                return("");
            }

            List <Rule> Rules = new List <Rule>();

            if (OO.Rules == null || OO.Rules.Count == 0)
            {
                if (Poem.Identifier == null)
                {
                    Rules.AddRange(Manager.Rules());
                }
                else
                {
                    Rule R2 = Manager.FetchRule(Poem.Identifier);
                    if (R2 == null)
                    {
                        Rules.AddRange(Manager.Rules());
                    }
                    else
                    {
                        Rules.Add(R2);
                    }
                }
            }
            else
            {
                Rules.AddRange(OO.Rules);
            }

            Probable Pr = Padyam.MostProbable2(Poem.Text, Options, Rules);

            if (Pr.MatchResult == null)
            {
                Debugger.Break();
            }
            MatchResult MR = Pr.MatchResult;
            Rule        R  = Pr.Rule;
            Padyam      P  = Pr.Padyam;

            return(Build(MR, R, P, OO));
        }
Beispiel #2
0
        public static string Build(Poem[] Poems, string title, string header, string footer, MatchOptions Options, OutputOptions OO)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<ol  class='ol'>");
            for (int i = 0; i < Poems.Length; i++)
            {
                Console.WriteLine("Processing Padyam: " + (i + 1));

                Poem poem = Poems[i];

                string x = Build(poem, Options, OO);
                if (x != "")
                {
                    sb.AppendLine("<li>");
                    sb.AppendLine(x);
                    sb.AppendLine("</li>");
                }
            }
            sb.AppendLine("</ol>");
            return(BuildFile(title, header, footer, sb.ToString(), OO.EmbedValue));
        }
Beispiel #3
0
 public static string Build(Poem Poem, MatchOptions Options)
 {
     return(Build(Poem, Options, new OutputOptions {
         UseFullName = false, ErrorsOnly = false
     }));
 }
Beispiel #4
0
        public static SatakamData ExtractSatakam(string[] Lines)
        {
            List <string> Header = new List <string>();
            List <string> Footer = new List <string>();

            bool        dueFooter = false;
            SatakamData S         = new SatakamData();
            List <Poem> Poems     = new List <Poem>();

            for (int i = 0; i < Lines.Length; i++)
            {
                string line = Lines[i];
                #region FirstLine-Format
                if (i == 0)
                {
                    switch (line)
                    {
                    case "#FORMAT-1":
                        S.Format = Format.Format1;
                        continue;

                    case "#FORMAT-2":
                        S.Format = Format.Format2;
                        continue;

                    default:
                        S.Format = Format.Unknown;
                        continue;
                    }
                }
                #endregion
                #region SecondLine-Title
                if (i == 1)
                {
                    S.Title = line.Replace("#", "");
                    continue;
                }
                #endregion


                if (line.StartsWith("#"))
                {
                    if (dueFooter)
                    {
                        Footer.Add(line.Replace("#", ""));
                    }
                    else
                    {
                        Header.Add(line.Replace("#", ""));
                    }
                }
                else
                {
                    dueFooter = true;
                    switch (S.Format)
                    {
                    case Format.Format1:
                        Poem P = new Poem();
                        P.Text = line.Replace("\\n", "\n");
                        Poems.Add(P);
                        break;

                    default:
                        break;
                    }
                }
            }
            S.Header = Header;
            S.Footer = Footer;
            S.Poems  = Poems;
            return(S);
        }