Exemple #1
0
        public void When_Clauser_With_NBKP_WithoutNulThat_MoveToBeginningOfSentence()
        {
            // TMIn April and May NBKP, CShowever NBKP, PRENthe NNreport VBwasn’t ADJgood BKP.
            _shufflerPhraseRepository
                = new ShufflerPhraseRepository(new ShufflerDataAccess());

            _document = _shufflerPhraseRepository.GetShufflerDocument(2016);

            var clauserUnitStrategy =
                new ClauserUnitStrategy();

            // act
            var sentenceReturned = clauserUnitStrategy.ShuffleSentence(
                _document.Paragraphs[0].Sentences[0]);

            // CShowever NBKP, TMIn April and May NBKP, PRENthe NNreport VBwasn’t ADJgood BKP.
            Assert.That(sentenceReturned.Texts.Count == 12);
            Assert.That(sentenceReturned.Texts[0].pe_text, Is.EqualTo(" however "));
            Assert.That(sentenceReturned.Texts[1].pe_text, Is.EqualTo(" , "));
            Assert.That(sentenceReturned.Texts[2].pe_text, Is.EqualTo(" In "));
            Assert.That(sentenceReturned.Texts[3].pe_text, Is.EqualTo(" April "));
            Assert.That(sentenceReturned.Texts[4].pe_text, Is.EqualTo(" and "));
            Assert.That(sentenceReturned.Texts[5].pe_text, Is.EqualTo(" May "));
            Assert.That(sentenceReturned.Texts[6].pe_text, Is.EqualTo(" , "));
            Assert.That(sentenceReturned.Texts[7].pe_text, Is.EqualTo(" the "));
            Assert.That(sentenceReturned.Texts[8].pe_text, Is.EqualTo(" report "));
            Assert.That(sentenceReturned.Texts[9].pe_text, Is.EqualTo(" wasn’t "));
            Assert.That(sentenceReturned.Texts[10].pe_text, Is.EqualTo(" good "));
            Assert.That(sentenceReturned.Texts[11].pe_text, Is.EqualTo(" . "));
        }
Exemple #2
0
        public void When_Clauser_And_NulThat_WithoutNBKP_MoveToAfterNulThat()
        {
            // We were for PRENthe NNplan NULthat VBwas ADVwell PASTstructured CShowever long BKP.
            _shufflerPhraseRepository
                = new ShufflerPhraseRepository(new ShufflerDataAccess());

            _document = _shufflerPhraseRepository.GetShufflerDocument(2016);

            var clauserUnitStrategy =
                new ClauserUnitStrategy();

            // act
            var sentenceReturned = clauserUnitStrategy.ShuffleSentence(
                _document.Paragraphs[1].Sentences[0]);

            // We were for PRENthe NNplan NULthat CShowever long, VBwas ADVwell PASTstructured BKP.
            Assert.That(sentenceReturned.Texts.Count == 13);
            Assert.That(sentenceReturned.Texts[0].pe_text, Is.EqualTo(" We "));
            Assert.That(sentenceReturned.Texts[1].pe_text, Is.EqualTo(" were "));
            Assert.That(sentenceReturned.Texts[2].pe_text, Is.EqualTo(" for "));
            Assert.That(sentenceReturned.Texts[3].pe_text, Is.EqualTo(" the "));
            Assert.That(sentenceReturned.Texts[4].pe_text, Is.EqualTo(" plan "));
            Assert.That(sentenceReturned.Texts[5].pe_text, Is.EqualTo(" that "));
            Assert.That(sentenceReturned.Texts[6].pe_text, Is.EqualTo(" however "));
            Assert.That(sentenceReturned.Texts[7].pe_text, Is.EqualTo(" long "));
            Assert.That(sentenceReturned.Texts[8].pe_text, Is.EqualTo(" , "));
            Assert.That(sentenceReturned.Texts[9].pe_text, Is.EqualTo(" was "));
            Assert.That(sentenceReturned.Texts[10].pe_text, Is.EqualTo(" well "));
            Assert.That(sentenceReturned.Texts[11].pe_text, Is.EqualTo(" structured "));
            Assert.That(sentenceReturned.Texts[12].pe_text, Is.EqualTo(" . "));
        }
Exemple #3
0
        public void When_Clauser_WithoutNBKP_WithoutNulThat_ShuffleClauserAndRestOfSentence_To_BeginningOfSentence()
        {
            //The meeting was over CSbefore he had a chance lai speak zhiqian BKP.
            _shufflerPhraseRepository
                = new ShufflerPhraseRepository(new ShufflerDataAccess());

            _document = _shufflerPhraseRepository.GetShufflerDocument(2016);

            var clauserUnitStrategy =
                new ClauserUnitStrategy();

            // act
            var sentenceReturned = clauserUnitStrategy.ShuffleSentence(
                _document.Paragraphs[2].Sentences[0]);

            //CSbefore he had a chance lai speak zhiqian NBKP, The meeting was over
            Assert.That(sentenceReturned.Texts[0].pe_text, Is.EqualTo(" before "));
            Assert.That(sentenceReturned.Texts[1].pe_text, Is.EqualTo(" he "));
            Assert.That(sentenceReturned.Texts[2].pe_text, Is.EqualTo(" had "));
            Assert.That(sentenceReturned.Texts[3].pe_text, Is.EqualTo(" a "));
            Assert.That(sentenceReturned.Texts[4].pe_text, Is.EqualTo(" chance "));
            Assert.That(sentenceReturned.Texts[5].pe_text, Is.EqualTo("lai"));
            Assert.That(sentenceReturned.Texts[6].pe_text, Is.EqualTo(" speak "));
            Assert.That(sentenceReturned.Texts[7].pe_text, Is.EqualTo(" zhiqian "));
            Assert.That(sentenceReturned.Texts[8].pe_text, Is.EqualTo(" , "));
            Assert.That(sentenceReturned.Texts[9].pe_text, Is.EqualTo(" The "));
            Assert.That(sentenceReturned.Texts[10].pe_text, Is.EqualTo(" meeting "));
            Assert.That(sentenceReturned.Texts[11].pe_text, Is.EqualTo(" was "));
            Assert.That(sentenceReturned.Texts[12].pe_text, Is.EqualTo(" over "));
            Assert.That(sentenceReturned.Texts[13].pe_text, Is.EqualTo(" . "));
        }
Exemple #4
0
        public void WhenClauser_WithNBKP_WithNulThat_MoveToAfterNulThat()
        {
            //The meeting that was over CSbefore he had a chance lai speak zhiqian, I think BKP.
            _shufflerPhraseRepository
                = new ShufflerPhraseRepository(new ShufflerDataAccess());

            _document = _shufflerPhraseRepository.GetShufflerDocument(2016);

            var clauserUnitStrategy =
                new ClauserUnitStrategy();

            var sentence = _document.Paragraphs[2].Sentences[0];

            sentence.Texts.Insert(2, new Text
            {
                pe_text        = " that ",
                pe_tag_revised = "MDNUL"
            });
            sentence.Texts[13].pe_tag_revised = "BKP";
            sentence.Texts[13].pe_text        = " , ";
            sentence.Texts.Add(new Text {
                pe_text = " I "
            });
            sentence.Texts.Add(new Text {
                pe_text = " think "
            });
            sentence.Texts.Add(new Text {
                pe_text = " . ", pe_tag = "BKP"
            });
            sentence.pe_para_no = 123;

            // act
            var sentenceReturned = clauserUnitStrategy.ShuffleSentence(
                sentence);

            //The meeting that CSbefore he had a chance lai speak zhiqian, was over I think BKP.
            Assert.That(sentenceReturned.Texts[0].pe_text, Is.EqualTo(" The "));
            Assert.That(sentenceReturned.Texts[1].pe_text, Is.EqualTo(" meeting "));
            Assert.That(sentenceReturned.Texts[2].pe_text, Is.EqualTo(" that "));
            Assert.That(sentenceReturned.Texts[3].pe_text, Is.EqualTo(" before "));
            Assert.That(sentenceReturned.Texts[4].pe_text, Is.EqualTo(" he "));
            Assert.That(sentenceReturned.Texts[5].pe_text, Is.EqualTo(" had "));
            Assert.That(sentenceReturned.Texts[6].pe_text, Is.EqualTo(" a "));
            Assert.That(sentenceReturned.Texts[7].pe_text, Is.EqualTo(" chance "));
            Assert.That(sentenceReturned.Texts[8].pe_text, Is.EqualTo("lai"));
            Assert.That(sentenceReturned.Texts[9].pe_text, Is.EqualTo(" speak "));
            Assert.That(sentenceReturned.Texts[10].pe_text, Is.EqualTo(" zhiqian "));
            Assert.That(sentenceReturned.Texts[11].pe_text, Is.EqualTo(" , "));
            Assert.That(sentenceReturned.Texts[12].pe_text, Is.EqualTo(" was "));
            Assert.That(sentenceReturned.Texts[13].pe_text, Is.EqualTo(" over "));
            Assert.That(sentenceReturned.Texts[14].pe_text, Is.EqualTo(" I "));
            Assert.That(sentenceReturned.Texts[15].pe_text, Is.EqualTo(" think "));
            Assert.That(sentenceReturned.Texts[16].pe_text, Is.EqualTo(" . "));

            Assert.That(sentenceReturned.pe_para_no, Is.EqualTo(123));
        }
Exemple #5
0
        public void When_Clauser_At_Start_Of_sentence_dont_shuffle()
        {
            var sentence = new Sentence();

            sentence.Texts.Add(
                new Text()
            {
                pe_tag_revised = "CS",
                pe_text        = "Before"
            });
            sentence.Texts.Add(new Text()
            {
                pe_text = "today"
            });
            sentence.Texts.Add(new Text()
            {
                pe_tag_revised = "BKP",
                pe_text        = " , "
            });
            sentence.Texts.Add(new Text()
            {
                pe_tag_revised = "PAST",
                pe_text        = " was "
            });
            sentence.Texts.Add(new Text()
            {
                pe_tag_revised = "ADJ",
                pe_text        = " great "
            });
            sentence.Texts.Add(new Text()
            {
                pe_tag_revised = "BKP",
                pe_text        = " . "
            });

            var clauserUnitStrategy =
                new ClauserUnitStrategy();

            // act
            var sentenceReturned = clauserUnitStrategy.ShuffleSentence(
                sentence);

            Assert.That(sentenceReturned.Texts[0].pe_text == "Before");
            Assert.That(sentenceReturned.Texts[1].pe_text == "today");
            Assert.That(sentenceReturned.Texts[2].pe_text == " , ");
            Assert.That(sentenceReturned.Texts[3].pe_text == " was ");
            Assert.That(sentenceReturned.Texts[4].pe_text == " great ");
            Assert.That(sentenceReturned.Texts[5].pe_text == " . ");
        }
        public void ShuffleClauserUnits_when_clauserAtStartOfSentence_DontMoveIt()
        {
            const string unShuffledSentence =
                "CSbefore he VBhad a chance VBto speak BKP, PRENThe meeting VBwas over BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

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

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "CSbefore he VBhad a chance VBto speak BKP, PRENThe meeting VBwas over BKP."));
        }
        public void ShuffleClauserUnits_ToTheBeginningOfTheSentenceAndAddComma()
        {
            const string unShuffledSentence =
                "TMIn April and May BKP, CShowever BKP, PRENthe NNreport VBwasn’t ADJgood BKP.";

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

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

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            "CShowever BKP, TMIn April and May BKP, PRENthe NNreport VBwasn’t ADJgood BKP."));
        }
Exemple #8
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 ShuffleClauserUnits_ToTheBeginningOfTheSentenceAndAddsComma_WhenSpaceElementBeforeComma(
            string sentenceFile, string expectation)
        {
            string unShuffledSentence = sentenceFile;

            Paragraph paragraph =
                DocumentContentHelper.GetParagraphFromWordDocument(unShuffledSentence);

            var clauserUnitStrategy = new ClauserUnitStrategy(new ClauserUnitChecker());

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

            // assert
            Assert.That(shufflerParagraph.InnerText, Is.EqualTo(
                            expectation));

            // multiple clauser units?

            // what if the bkp is a ? or !
        }
Exemple #10
0
        public void WhenThatFound_MoveCSandNBKPToAfterThat()
        {
            //1.1.	If ‘that’ is found, move from CS to and including NBKP to after ‘that’:
            //Bef: We VBbelieve NULthat we VBneed NNit, CShowever NNlong NNit VBtakes, to succeed BKP.

            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "", pe_text = "We"
                    },
                    new Text()
                    {
                        pe_tag = "VB", pe_text = "believe"
                    },
                    new Text()
                    {
                        pe_tag = "MDNUL", pe_text = "that"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "we"
                    },
                    new Text()
                    {
                        pe_tag = "VB", pe_text = "need"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "it"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " , "
                    },
                    new Text()
                    {
                        pe_tag = "CS", pe_text = "however"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "long"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "it"
                    },
                    new Text()
                    {
                        pe_tag = "VB", pe_text = "takes"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " , "
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "to"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "succeed"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            ClauserUnitStrategy clauserUnitStrategy = new ClauserUnitStrategy();

            sentence = clauserUnitStrategy.ShuffleSentence(sentence);

            //Aft: We VBbelieve NULthat CShowever NNlong NNit VBtakesNBKP, we VBneed NNit to succeed BKP.
            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("We"));
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("believe"));
            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("that"));
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo("however"));
            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("long"));
            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("it"));
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo("takes"));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo(" , "));
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("we"));
            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("need"));
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo("it"));
            Assert.That(sentence.Texts[11].pe_text, Is.EqualTo(" , "));

            Assert.That(sentence.Texts[12].pe_text, Is.EqualTo("to"));
            Assert.That(sentence.Texts[13].pe_text, Is.EqualTo("succeed"));
            Assert.That(sentence.Texts[14].pe_text, Is.EqualTo(" . "));
        }
Exemple #11
0
        public void IfThatNotFound_MoveCsUpToNbkpToBeginningOfSentence()
        {
            // 1.1.	If ‘that’ is NOT found, move from CS to and including NBKP to the beginning of the sentence:

            //Bef: TMIn April and May NBKP, CShowever NBKP, PRENthe NNreport VBwasn’t ADJgood BKP.
            var sentence = new Sentence()
            {
                Texts = new List <Text>()
                {
                    new Text()
                    {
                        pe_tag = "TM", pe_text = "In"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "April"
                    },
                    new Text()
                    {
                        pe_tag = "MDNUL", pe_text = "and"
                    },
                    new Text()
                    {
                        pe_tag = "", pe_text = "May"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " , "
                    },
                    new Text()
                    {
                        pe_tag = "CS", pe_text = "however"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " , "
                    },
                    new Text()
                    {
                        pe_tag = "PREN", pe_text = "the"
                    },
                    new Text()
                    {
                        pe_tag = "NN", pe_text = "report"
                    },
                    new Text()
                    {
                        pe_tag = "VB", pe_text = "wasn't"
                    },
                    new Text()
                    {
                        pe_tag = "ADJ", pe_text = "good"
                    },
                    new Text()
                    {
                        pe_tag = "BKP", pe_text = " . "
                    }
                }
            };

            ClauserUnitStrategy clauserUnitStrategy = new ClauserUnitStrategy();

            sentence = clauserUnitStrategy.ShuffleSentence(sentence);


            //Aft: CShowever NBKP, TMIn April and May NBKP, PRENthe NNreport VBwasn’t ADJgood BKP.
            Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("however")); //CS
            Assert.That(sentence.Texts[1].pe_text, Is.EqualTo(" , "));
            Assert.That(sentence.Texts[2].pe_text, Is.EqualTo("In"));
            Assert.That(sentence.Texts[3].pe_text, Is.EqualTo("April"));
            Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("and"));
            Assert.That(sentence.Texts[5].pe_text, Is.EqualTo("May"));
            Assert.That(sentence.Texts[6].pe_text, Is.EqualTo(" , "));
            Assert.That(sentence.Texts[7].pe_text, Is.EqualTo("the"));
            Assert.That(sentence.Texts[8].pe_text, Is.EqualTo("report"));
            Assert.That(sentence.Texts[9].pe_text, Is.EqualTo("wasn't"));
            Assert.That(sentence.Texts[10].pe_text, Is.EqualTo("good"));
            Assert.That(sentence.Texts[11].pe_text, Is.EqualTo(" . "));
        }
Exemple #12
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(" . "));
        }
Exemple #13
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 == " . ");
        }