コード例 #1
0
        public void MdbkWithoutPrenorAdj__ThenMoveMdbkBeforeNN()
        {
            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "There's"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "issues"
                    },
                    new Text()
                    {
                        pe_tag = "MDBK", pe_text = "related"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "seasonal"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "adjustment"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            MdbkUnitStrategy mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text == "There's");
            Assert.That(sentence.Texts[1].pe_text == "related"); // MDBK
            Assert.That(sentence.Texts[1].pe_merge_ahead == 4);
            Assert.That(sentence.Texts[2].pe_text == "to");
            Assert.That(sentence.Texts[3].pe_text == "seasonal");
            Assert.That(sentence.Texts[4].pe_text == "adjustment");
            Assert.That(sentence.Texts[5].pe_text == " de ");    // new particle
            Assert.That(sentence.Texts[6].pe_text == "issues");  // NN
            Assert.That(sentence.Texts[7].pe_text == " . ");
        }
コード例 #2
0
        public void When_NoNnInMdbkSentence_DoesNotError()
        {
            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "There's"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "issues"
                    },
                    new Text()
                    {
                        pe_tag = "MDBK", pe_text = "related"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "seasonal"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "adjustment"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            MdbkUnitStrategy mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text == "There's");
            Assert.That(sentence.Texts[1].pe_text == "issues");
            Assert.That(sentence.Texts[2].pe_text == "related"); // MDBK
            Assert.That(sentence.Texts[3].pe_text == "to");
            Assert.That(sentence.Texts[4].pe_text == "seasonal");
            Assert.That(sentence.Texts[5].pe_text == "adjustment");
            Assert.That(sentence.Texts[6].pe_text == " . ");
        }
コード例 #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);
        }
コード例 #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(" . "));
        }
コード例 #5
0
        public void MdbkWithMultiMdUnit_AddDeBeforeMdbkAndMoveMDAfterMdbk()
        {
            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "It's"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "a"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "matter"
                    },
                    new Text()
                    {
                        pe_tag = "MDBK", pe_text = "related", pe_merge_ahead = 1
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "PREN", pe_text = "the"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "integrity"
                    },
                    new Text()
                    {
                        pe_tag = "MD2", pe_text = "of"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "this"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "committee"
                    },
                    new Text()
                    {
                        pe_tag = "MD1", pe_text = "at"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "this"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "place"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            MdbkUnitStrategy mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text == "It's");
            Assert.That(sentence.Texts[1].pe_text == "a");
            Assert.That(sentence.Texts[2].pe_text == "matter");

            Assert.That(sentence.Texts[3].pe_text == "related");
            Assert.That(sentence.Texts[3].pe_merge_ahead == 10);

            Assert.That(sentence.Texts[4].pe_text == "to");
            Assert.That(sentence.Texts[5].pe_text == "of"); //MD2
            Assert.That(sentence.Texts[6].pe_text == "this");
            Assert.That(sentence.Texts[7].pe_text == "committee");
            Assert.That(sentence.Texts[8].pe_text == "at"); //MD1
            Assert.That(sentence.Texts[9].pe_text == "this");
            Assert.That(sentence.Texts[10].pe_text == "place");
            Assert.That(sentence.Texts[11].pe_text == "the");       //PREN
            Assert.That(sentence.Texts[12].pe_text == "integrity"); //NN
            Assert.That(sentence.Texts[13].pe_text == " de ");      // new particle
            Assert.That(sentence.Texts[14].pe_text == " . ");
        }
コード例 #6
0
        public void MdbkWithADJ_moveMdbkBeforeADJ()
        {
            //Bef: This is ADJreal NNemotion MDBKrelated to ADJreal NNpeople de.
            //Aft: This is MDBKrelated to ADJreal NNpeople de ADJreal NNemotion.

            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "This"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "is"
                    },
                    new Text()
                    {
                        pe_tag = "ADJ", pe_text = "real"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "emotion"
                    },
                    new Text()
                    {
                        pe_tag = "MDBK", pe_text = "related", pe_merge_ahead = 1
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "ADJ", pe_text = "real"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "people"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            MdbkUnitStrategy mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            //Aft: This is MDBKrelated to ADJreal NNpeople de ADJreal NNemotion.
            Assert.That(sentence.Texts[0].pe_text == "This");
            Assert.That(sentence.Texts[1].pe_text == "is");

            Assert.That(sentence.Texts[2].pe_text == "related"); //MDBK unit up to de
            Assert.That(sentence.Texts[2].pe_merge_ahead == 4);

            Assert.That(sentence.Texts[3].pe_text == "to");
            Assert.That(sentence.Texts[4].pe_text == "real"); //ADJ
            Assert.That(sentence.Texts[5].pe_text == "people");
            Assert.That(sentence.Texts[6].pe_text == " de "); //new particle
            Assert.That(sentence.Texts[7].pe_text == "real"); //ADJ
            Assert.That(sentence.Texts[8].pe_text == "emotion");

            Assert.That(sentence.Texts[9].pe_text == " . ");
        }
コード例 #7
0
        public void MdbkWithMoMdUnit_AddDeAfterLastNnAfterMdbk()
        {
            var sentence = new Sentence()
            {
                //…exaggerated by issues MDBKrelated to ADJseasonal NNadjustment deBKP.
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "It's"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "exaggerated"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "by"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "issues"
                    },
                    new Text()
                    {
                        pe_tag = "MDBK", pe_text = "related"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "ADJ", pe_text = "seasonal"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "adjustment"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "things"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            MdbkUnitStrategy mdbkUnitStrategy = new MdbkUnitStrategy();

            sentence = mdbkUnitStrategy.ShuffleSentence(sentence);

            Assert.That(sentence.Texts[0].pe_text == "It's");
            Assert.That(sentence.Texts[1].pe_text == "exaggerated");
            Assert.That(sentence.Texts[2].pe_text == "by");

            Assert.That(sentence.Texts[3].pe_text == "issues");

            Assert.That(sentence.Texts[4].pe_text == "related");
            Assert.That(sentence.Texts[4].pe_merge_ahead == 5);

            Assert.That(sentence.Texts[5].pe_text == "to");
            Assert.That(sentence.Texts[6].pe_text == "seasonal");
            Assert.That(sentence.Texts[7].pe_text == "adjustment");
            Assert.That(sentence.Texts[8].pe_text == "things");
            Assert.That(sentence.Texts[9].pe_text == " de "); // new particle
            Assert.That(sentence.Texts[10].pe_text == " . ");
        }