示例#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 DoesNotMovePercentIfNoNumberInFront()
    {
      var sentence = new Sentence
      {
        Texts = new List<Text>()
        {
          new Text() {pe_tag = "", pe_text = "unemployment"},
          new Text() {pe_tag = "PAST", pe_text = "was"},
          new Text() {pe_tag = "", pe_text = " a few "},
          new Text() {pe_tag = "", pe_text = " percent "},
          new Text() {pe_tag = "BKP", pe_text = "."},
        }
      };

      var percentUnitStrategy = new PercentUnitStrategy();
      sentence = percentUnitStrategy.ShuffleSentence(sentence);

      Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("unemployment"));
      Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("was"));
      Assert.That(sentence.Texts[2].pe_text, Is.EqualTo(" a few "));
      Assert.That(sentence.Texts[3].pe_text, Is.EqualTo(" percent "));
      Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("."));
    }
    public void MovesPercentSymbolBeforeDIG()
    {
      var sentence = new Sentence
      {
        Texts = new List<Text>()
        {
          new Text() {pe_tag = "", pe_text = "unemployment"},
          new Text() {pe_tag = "PAST", pe_text = "was"},
          new Text() {pe_tag = "DIG", pe_text = " 8.2 "},
          new Text() {pe_tag = "", pe_text = " % "},
          new Text() {pe_tag = "BKP", pe_text = "."},
        }
      };

      var percentUnitStrategy = new PercentUnitStrategy();
      sentence = percentUnitStrategy.ShuffleSentence(sentence);

      Assert.That(sentence.Texts[0].pe_text, Is.EqualTo("unemployment"));
      Assert.That(sentence.Texts[1].pe_text, Is.EqualTo("was"));
      Assert.That(sentence.Texts[2].pe_text, Is.EqualTo(" % "));
      Assert.That(sentence.Texts[3].pe_text, Is.EqualTo(" 8.2 "));
      Assert.That(sentence.Texts[4].pe_text, Is.EqualTo("."));
    }
示例#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(" . "));
        }