Пример #1
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);
        }
        public void When_PrenAndMDNulThat_Move_MDNul_To_AfterPren()
        {
            var sentence = new Sentence()
            {
                //Bef: Some of PRENthe factors MDNULthat have restrained the recovery PYde persist.
                //Aft: Some of PRENthe MDNULthat have restrained the recovery PYde factors persist.

                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_text = "Some", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = "of", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = "the", pe_tag = "PREN"
                    },
                    new Text()
                    {
                        pe_text = "factors", pe_tag = "NN"
                    },
                    new Text()
                    {
                        pe_text = " that ", pe_tag = "MDNUL"
                    },
                    new Text()
                    {
                        pe_text = "have restrained", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = "the", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = "recovery", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = " de ", pe_tag = "PY"
                    },
                    new Text()
                    {
                        pe_text = "persist", pe_tag = ""
                    },
                    new Text()
                    {
                        pe_text = " . ", pe_tag = "BKP"
                    }
                }
            };
            MdNulThatUnitStrategy mdNulThatUnitStrategy = new MdNulThatUnitStrategy();

            sentence = mdNulThatUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("Some"));
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("of"));
            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("the"));    //PREN
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo(" that ")); //MDNUL
            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("have restrained"));
            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("the"));
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo("recovery"));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo(" de "));    //PY
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("factors")); //NN
            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("persist"));
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo(" . "));
        }
Пример #3
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(" . "));
        }