Esempio n. 1
0
        public void WriteToDocument(IDocument document, float integrity = 1.0f)
        {
            var unigram = Pick();

            while (unigram != null && unigram != Terminator)
            {
                DocumentStructure structure = unigram.data;

                document.AppendDebug(structure.type.ToString());

                if (Chance(structure.chance))
                {
                    switch (structure.type)
                    {
                    case DocumentStructureType.Paragraph:
                    {
                        if (Chance(structure.headingChance))
                        {
                            document.AppendHeading(integrity);
                        }

                        int length = random.Next(structure.min, structure.max);

                        for (int i = 0; i < length; i++)
                        {
                            document.AppendParagraph(integrity);
                        }
                    }
                    break;

                    case DocumentStructureType.Title:
                    {
                        document.AppendTitle(integrity);
                    }
                    break;

                    case DocumentStructureType.Heading:
                    {
                        document.AppendHeading(integrity);
                    }
                    break;

                    case DocumentStructureType.Quote:
                    {
                        // @TODO
                    }
                    break;

                    case DocumentStructureType.Citation:
                    {
                        // @TODO
                    }
                    break;

                    case DocumentStructureType.Image:
                    {
                        // @TODO
                    }
                    break;

                    case DocumentStructureType.Table:
                    {
                        // @TODO
                    }
                    break;
                    }
                }

                unigram = unigram.Pick(random);
            }

            if (unigram == Terminator)
            {
                document.AppendDebug("TERMINATOR");
            }


            /*
             *
             * DocumentMarkov structure = Submissions.Essay.Structure.Duplicate(seed);
             *
             * DocXDocument doc = new DocXDocument();
             * doc.BeginWriting(0, path, seed, seed);
             *
             * DocumentUnigram unigram = structure.Pick();
             *
             * while(unigram != null && unigram != structure.Terminator)
             * {
             * doc.Para(unigram.data.ToString(), "Debug");
             *
             * if (unigram.data == DocumentStructure.Paragraph)
             * {
             *  doc.AppendParagraph();
             * }
             * else if (unigram.data == DocumentStructure.Title)
             * {
             *  doc.AppendHeading();
             * }
             * else
             * {
             *  break;
             * }
             *
             * unigram = unigram.Pick(structure.random);
             * }
             *
             * if (unigram == structure.Terminator)
             * {
             *  doc.Para("TERMINATOR", "Debug");
             * }
             *
             * doc.EndWriting();
             */
        }