示例#1
0
 private void EvalTextFile(string fromFile, string toFile)
 {
     {
         SatakamData S = Library.Chandam.Samples.Satakam.ExtractSatakamFromFile(fromFile);
         string      s = Library.Chandam.Samples.Satakam.Build(S, MatchOptions.QucikMatchSettings);
         f.InnerHtml = s;
         head.Title  = S.Title;
         File.WriteAllText(toFile, s, Encoding.UTF8);
     }
 }
示例#2
0
        public void Start(string config)
        {
            Extractor E  = new Extractor(config);
            FileInfo  FI = new FileInfo(E.Data);

            if (!FI.Exists)
            {
                Console.WriteLine("Skipping as not found - " + FI.FullName);
                return;
            }
            SatakamData SD = E.Extract();

            string data = Satakam.Build(SD, E.Options, E.OO);

            File.WriteAllText(E.Output, data, Encoding.UTF8);
        }
示例#3
0
    private void BuildTextFile(string[] Poems, string title, string author, string file)
    {
        SatakamData S = new SatakamData();

        S.Poems = new List <Poem>();
        foreach (string s in Poems)
        {
            Poem P = new Poem();
            P.Text = s;
            S.Poems.Add(P);
        }
        S.Header = new List <string> {
            author
        };
        S.Footer = new List <string>
        {
        };
        S.Format = Format.Format1;
        S.Title  = title;
        Library.Chandam.Samples.Satakam.Write2File(file, S);
    }
示例#4
0
        public SatakamData Extract()
        {
            string[] Lines = File.ReadAllLines(Data);

            List <string> Header = new List <string>();
            List <string> Footer = new List <string>();

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

            Poem Curr = new Poem {
                Text = "", Identifier = null
            };

            for (int i = 0; i < Lines.Length; i++)
            {
                string line = Lines[i];

                if (line.StartsWith("#"))
                {
                    continue;
                }

                if (line.Trim().Replace("\t", "") == "")
                {
                    Curr.Text = Curr.Text.Trim('\n');
                    Poems.Add(Curr);
                    Curr            = new Poem();
                    Curr.Text       = "";
                    Curr.Identifier = null;
                    continue;
                }

                if (KnownChandam && Curr.Identifier == null)
                {
                    int space = line.IndexOf(" ");
                    int tab   = line.IndexOf("\t");
                    int min   = -1;
                    if (space == -1 && tab == -1)
                    {
                        Curr.Identifier = MapValue(line);
                    }
                    else
                    {
                        if (space == -1 || tab == -1)
                        {
                            min = Math.Max(space, tab);
                        }
                        else
                        {
                            min = Math.Min(space, tab);
                        }
                    }

                    if (min != -1)
                    {
                        Curr.Identifier = MapValue(line.Substring(0, min));
                        Curr.Text       = line.Substring(min + 1);
                        continue;
                    }
                    else
                    {
                        Curr.Identifier = MapValue(line.Trim());
                        continue;
                    }
                }

                if (Curr.Text == "")
                {
                    Curr.Text = line;
                }
                else
                {
                    Curr.Text = Curr.Text + "\n" + line;
                }
            }

            S.Title = DictValue("Title");
            S.Title = S.Title.Trim() == "" ? "ఛందం ©  ఫలితాలు" : S.Title;

            S.Header = new List <string>()
            {
                DictValue("Author")
            };
            S.Footer = new List <string>()
            {
                "ఛందం <sup>©</sup> తో పద్య సాహిత్యం మరింత రసమయం..!!", "Courtesy: http://chandam.apphb.com"
            };

            S.Poems = Poems;
            return(S);
        }