Example #1
0
        public void When_VB_VBA_PAST_Found_Move_TimerUnit_InFront(
            string unShuffledSentence, string output)
        {
            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            //  act
            var shufflerParagraph =
                timerUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            output));
        }
Example #2
0
        public void TimerUnits_Are_ShuffledInDescendingOrderOfTheirSerialNumber()
        {
            const string unShuffledSentence =
                "TM1this time TM2last year BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            //  act
            var shufflerParagraph =
                timerUnitStrategy.ShuffleSentenceUnit(paragraph);

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "TM2last year TM1this time BKP."));
        }
Example #3
0
        public void Shuffler_Routines_maintain_FullStop_At_end_of_sentences()
        {
            var sentence = LargeSentence;

            var clauserUnitStrategy = new ClauserUnitStrategy();

            sentence = clauserUnitStrategy.ShuffleSentence(sentence);

            var adverbUnitStrategy = new AdverbUnitStrategy();

            sentence = adverbUnitStrategy.ShuffleSentence(sentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            sentence = timerUnitStrategy.ShuffleSentence(sentence);

            var mDUnitStrategy = new MdUnitStrategy();

            sentence = mDUnitStrategy.ShuffleSentence(sentence);

            var mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            var mdNulThatUnitStrategy = new MdNulThatUnitStrategy();

            sentence = mdNulThatUnitStrategy.ShuffleSentence(sentence);

            var ddlUnitStrategy = new DdlUnitStrategy();

            sentence = ddlUnitStrategy.ShuffleSentence(sentence);

            var pyYoUnitStrategy = new PyYoUnitStrategy();

            sentence = pyYoUnitStrategy.ShuffleSentence(sentence);

            var percentUnitStrategy = new PercentUnitStrategy();

            sentence = percentUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts.Last().IsSentenceEnd);
        }
Example #4
0
        public void When_EconomicGrowth_Sentence_Shuffled_provides_Correct_Output()
        {
            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text {
                        pe_tag = "ADJ", pe_text = "Economic", pe_order = 10
                    },
                    new Text {
                        pe_tag = "NN", pe_text = "growth", pe_order = 20
                    },
                    new Text {
                        pe_tag = "DYN9", pe_tag_revised = "VBA", pe_text = "has", pe_order = 30
                    },
                    new Text {
                        pe_tag = "PAST", pe_text = "continued", pe_order = 40
                    },
                    new Text {
                        pe_tag = "MD", pe_tag_revised = "MD1", pe_text = "at", pe_order = 50, pe_merge_ahead = 3
                    },
                    new Text {
                        pe_tag = "PREN", pe_text = "a", pe_order = 60, pe_merge_ahead = 2
                    },
                    new Text {
                        pe_tag = "ADJ", pe_text = "moderate", pe_order = 70
                    },
                    new Text {
                        pe_tag = "NN", pe_text = "rate", pe_order = 80
                    },
                    new Text {
                        pe_tag = "TM", pe_tag_revised = "TM1", pe_text = "so far", pe_order = 90
                    },
                    new Text {
                        pe_tag = "TM", pe_tag_revised = "TM2", pe_text = "this year", pe_order = 100
                    },
                    new Text {
                        pe_tag = "BKP", pe_text = " . ", pe_order = 110
                    },
                }
            };

            var adverbUnitStrategy = new AdverbUnitStrategy();

            sentence = adverbUnitStrategy.ShuffleSentence(sentence);

            var timerUnitStrategy = new TimerUnitStrategy();

            sentence = timerUnitStrategy.ShuffleSentence(sentence);


            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("Economic"));
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("growth"));    //NN

            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("this year")); //TM
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo("so far"));
            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("has"));       //VBA
            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("continued")); //PAST
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo("at"));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo("a"));
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("moderate"));
            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("rate"));
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo(" . "));

            var mDUnitStrategy = new MdUnitStrategy();

            sentence = mDUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("Economic"));
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("growth"));

            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("this year")); //TM 2 & 1
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo("so far"));

            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("has"));  //VBA

            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("at"));   //MD1
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo("a"));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo("moderate"));
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("rate"));

            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("continued")); //PAST
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo(" . "));

            var mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            var mdNulThatUnitStrategy = new MdNulThatUnitStrategy();

            sentence = mdNulThatUnitStrategy.ShuffleSentence(sentence);

            var ddlUnitStrategy = new DdlUnitStrategy();

            sentence = ddlUnitStrategy.ShuffleSentence(sentence);

            var pyYoUnitStrategy = new PyYoUnitStrategy();

            sentence = pyYoUnitStrategy.ShuffleSentence(sentence);

            var percentUnitStrategy = new PercentUnitStrategy();

            sentence = percentUnitStrategy.ShuffleSentence(sentence);

            var clauserUnitStrategy = new ClauserUnitStrategy();

            sentence = clauserUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("Economic"));
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("growth"));

            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("this year")); //TM 2 & 1
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo("so far"));

            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("has"));  //VBA

            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("at"));   //MD1
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo("a"));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo("moderate"));
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("rate"));

            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("continued")); //PAST
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo(" . "));
        }
Example #5
0
        public void EachStrategyInTurnMaintainsTheSentenceEnding()
        {
            var realGdpSentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag_revised = "ADJ", pe_text = "Real"
                    },
                    new Text()
                    {
                        pe_tag_revised = "NN", pe_text = "gdp"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PAST", pe_text = "rose"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD2", pe_text = "at"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PREN1", pe_text = "an"
                    },
                    new Text()
                    {
                        pe_tag_revised = "NN", pe_text = "annual rate"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD2", pe_text = "of "
                    },
                    new Text()
                    {
                        pe_tag_revised = "PREN2", pe_text = "about"
                    },
                    new Text()
                    {
                        pe_tag_revised = "DG", pe_text = "2"
                    },
                    new Text()
                    {
                        pe_tag_revised = "NN", pe_text = "percent"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD3", pe_text = "in"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PREN3", pe_text = "the"
                    },
                    new Text()
                    {
                        pe_tag_revised = "TM1", pe_text = "first qtr"
                    },
                    new Text()
                    {
                        pe_tag_revised = "CS", pe_text = "after"
                    },                                                          //CS 13
                    new Text()
                    {
                        pe_tag_revised = "PRES", pe_text = "increasing"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD4", pe_text = "at"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PREN4", pe_text = "a"
                    },
                    new Text()
                    {
                        pe_tag_revised = "DG", pe_text = "3"
                    },
                    new Text()
                    {
                        pe_tag_revised = "NN", pe_text = "percent"
                    },
                    new Text()
                    {
                        pe_tag_revised = "NN", pe_text = "pace"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD5", pe_text = "in"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PREN5", pe_text = "the"
                    },
                    new Text()
                    {
                        pe_tag_revised = "TM2", pe_text = "4th qtr"
                    },
                    new Text()
                    {
                        pe_tag_revised = "MD6", pe_text = " of "
                    },
                    new Text()
                    {
                        pe_tag_revised = "TMY", pe_text = "2011"
                    },
                    new Text()
                    {
                        pe_tag_revised = "PY", pe_text = "zhihou"
                    },
                    new Text()
                    {
                        pe_tag_revised = "BKP", pe_text = " . "
                    }
                }
            };

            ClauserUnitStrategy clauserUnitStrategy = new ClauserUnitStrategy();

            realGdpSentence = clauserUnitStrategy.ShuffleSentence(realGdpSentence);

            Assert.That(realGdpSentence.Texts[0].pe_tag_revised == "CS");
            Assert.That(realGdpSentence.Texts[realGdpSentence.TextCount - 1].pe_text == " . ");

            AdverbUnitStrategy adverbUnitStrategy = new AdverbUnitStrategy();

            realGdpSentence = adverbUnitStrategy.ShuffleSentence(realGdpSentence);

            Assert.That(realGdpSentence.Texts[realGdpSentence.TextCount - 1].pe_text == " . ");

            TimerUnitStrategy timerUnitStrategy = new TimerUnitStrategy();

            realGdpSentence = timerUnitStrategy.ShuffleSentence(realGdpSentence);

            Assert.That(realGdpSentence.Texts[realGdpSentence.TextCount - 1].pe_text == " . ");
        }