public virtual void testNoDoubledCommas()
        {
            NPPhraseSpec subject = phraseFactory.createNounPhrase("I");
            NPPhraseSpec @object = phraseFactory.createNounPhrase("a bag");

            SPhraseSpec _s1 = phraseFactory.createClause(subject, "carry", @object);

            PPPhraseSpec pp1 =
                phraseFactory.createPrepositionPhrase("on", phraseFactory.createNounPhrase("most", "Tuesdays"));

            _s1.addFrontModifier(pp1);

            PPPhraseSpec pp2 = phraseFactory.createPrepositionPhrase("since", phraseFactory.createNounPhrase("1991"));
            PPPhraseSpec pp3 =
                phraseFactory.createPrepositionPhrase("except", phraseFactory.createNounPhrase("yesterday"));

            pp2.setFeature(Feature.APPOSITIVE, true);
            pp3.setFeature(Feature.APPOSITIVE, true);

            pp1.addPostModifier(pp2);
            pp1.addPostModifier(pp3);

            realiser.CommaSepCuephrase = true;

            Assert.AreEqual("on most Tuesdays, since 1991, except yesterday, I carry a bag",
                            realiser.realise(_s1).Realisation);

            // without my fix (that we're testing here), you'd end up with
            // "on most Tuesdays, since 1991,, except yesterday, I carry a bag"
        }
예제 #2
0
        public virtual void testCuePhrase()
        {
            NPPhraseSpec subject = phraseFactory.createNounPhrase("wave");

            subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
            NPPhraseSpec @object = phraseFactory.createNounPhrase("surfer");

            @object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);

            SPhraseSpec
                _s1 = phraseFactory.createClause(subject, "carry", @object); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$


            // add a PP complement
            PPPhraseSpec pp =
                phraseFactory.createPrepositionPhrase("to", phraseFactory.createNounPhrase("the", "shore"));

            _s1.addPostModifier(pp);

            _s1.setFeature(Feature.PASSIVE, true);

            _s1.addFrontModifier("however");


            //without comma separation of cue phrase
            Assert.AreEqual("however surfers are carried to the shore by waves",
                            realiser.realise(_s1).Realisation); //$NON-NLS-1$


            realiser.CommaSepCuephrase = true;
            Assert.AreEqual("however, surfers are carried to the shore by waves",
                            realiser.realise(_s1).Realisation); //$NON-NLS-1$
        }
        public virtual void testCommaSeparatedFrontModifiers()
        {
            NPPhraseSpec subject = phraseFactory.createNounPhrase("I");
            NPPhraseSpec @object = phraseFactory.createNounPhrase("a bag");

            SPhraseSpec _s1 = phraseFactory.createClause(subject, "carry", @object);


            // add a PP complement
            PPPhraseSpec pp1 =
                phraseFactory.createPrepositionPhrase("on", phraseFactory.createNounPhrase("most", "Tuesdays"));

            _s1.addFrontModifier(pp1);

            PPPhraseSpec pp2 = phraseFactory.createPrepositionPhrase("since", phraseFactory.createNounPhrase("1991"));

            _s1.addFrontModifier(pp2);
            pp1.setFeature(Feature.APPOSITIVE, true);
            pp2.setFeature(Feature.APPOSITIVE, true);

            //without setCommaSepCuephrase
            Assert.AreEqual("on most Tuesdays since 1991 I carry a bag", realiser.realise(_s1).Realisation);


            //with setCommaSepCuephrase
            realiser.CommaSepCuephrase = true;
            Assert.AreEqual("on most Tuesdays, since 1991, I carry a bag", realiser.realise(_s1).Realisation);
        }
예제 #4
0
        public virtual void testPassiveWithPPMod()
        {
            // passive with just complement
            NPPhraseSpec subject = phraseFactory.createNounPhrase("wave");

            subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
            NPPhraseSpec @object = phraseFactory.createNounPhrase("surfer");

            @object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);

            SPhraseSpec
                _s1 = phraseFactory.createClause(subject, "carry", @object); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$


            // add a PP complement
            PPPhraseSpec pp =
                phraseFactory.createPrepositionPhrase("to", phraseFactory.createNounPhrase("the", "shore"));

            _s1.addPostModifier(pp);

            _s1.setFeature(Feature.PASSIVE, true);

            Assert.AreEqual("surfers are carried to the shore by waves",
                            realiser.realise(_s1).Realisation); //$NON-NLS-1$
        }
예제 #5
0
        public virtual void testPassiveWithPPCompl()
        {
            // passive with just complement
            NPPhraseSpec subject = phraseFactory.createNounPhrase("wave");

            subject.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
            NPPhraseSpec @object = phraseFactory.createNounPhrase("surfer");

            @object.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);

            SPhraseSpec
                _s1 = phraseFactory.createClause(subject, "carry", @object); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$


            // add a PP complement
            PPPhraseSpec pp =
                phraseFactory.createPrepositionPhrase("to", phraseFactory.createNounPhrase("the", "shore"));

            pp.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.INDIRECT_OBJECT);
            _s1.addComplement(pp);

            _s1.setFeature(Feature.PASSIVE, true);

            Assert.AreEqual("surfers are carried to the shore by waves",
                            realiser.realise(_s1).Realisation); //$NON-NLS-1$
        }
예제 #6
0
        public virtual void testComplexSentence3()
        {
            setUp();

            s1 = phraseFactory.createClause();
            s1.setSubject(woman);
            s1.setVerb("kiss");
            s1.setObject(man);

            PhraseElement _man = phraseFactory.createNounPhrase("the", "man"); //$NON-NLS-1$ //$NON-NLS-2$

            s3 = phraseFactory.createClause();
            s3.setSubject(_man);
            s3.setVerb("give");

            NPPhraseSpec flower = phraseFactory.createNounPhrase("flower"); //$NON-NLS-1$
            NPPhraseSpec john   = phraseFactory.createNounPhrase("John");   //$NON-NLS-1$

            john.setFeature(Feature.POSSESSIVE, true);
            flower.setSpecifier(john);
            s3.setObject(flower);

            PhraseElement _woman = phraseFactory.createNounPhrase("the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$

            s3.setIndirectObject(_woman);

            // the coordinate sentence allows us to raise and lower complementiser
            CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(s1, s3);

            coord2.setFeature(Feature.TENSE, Tense.PAST);

            realiser.DebugMode = true;
            Assert.AreEqual("the woman kissed the man and the man gave the woman John's flower",
                            realiser.realise(coord2).Realisation); //$NON-NLS-1$
        }
예제 #7
0
        public virtual void xmlLexiconImmutabilityTest()
        {
            NLGFactory factory  = new NLGFactory(lexicon);
            Realiser   realiser = new Realiser(lexicon);

            // "wall" is singular.
            NPPhraseSpec wall = factory.createNounPhrase("the", "wall");

            Assert.AreEqual(NumberAgreement.SINGULAR, wall.getFeature(Feature.NUMBER));

            // Realise a sentence with plural form of "wall"
            wall.Plural = true;
            SPhraseSpec sentence = factory.createClause("motion", "observe");

            sentence.setFeature(Feature.TENSE, Tense.PAST);
            PPPhraseSpec pp = factory.createPrepositionPhrase("in", wall);

            sentence.addPostModifier(pp);
            realiser.realiseSentence(sentence);

            // Create a new 'the wall' NP and check to make sure that the syntax processor has
            // not propagated plurality to the canonical XMLLexicon WordElement object.
            wall = factory.createNounPhrase("the", "wall");
            Assert.AreEqual(NumberAgreement.SINGULAR, wall.getFeature(Feature.NUMBER));
        }
예제 #8
0
        public void correctPluralizationWithPossessives()
        {
            NPPhraseSpec sisterNP = SetupForRealiserTest.phraseFactory.createNounPhrase("sister");
            INLGElement  word     = SetupForRealiserTest.phraseFactory.createInflectedWord("Albert Einstein",
                                                                                           new LexicalCategory_NOUN());

            word.setFeature(LexicalFeature.PROPER, true);
            NPPhraseSpec possNP = SetupForRealiserTest.phraseFactory.createNounPhrase(word);

            possNP.setFeature(Feature.POSSESSIVE.ToString(), true);
            sisterNP.setSpecifier(possNP);


            Assert.AreEqual("Albert Einstein's sister",
                            SetupForRealiserTest.realiser.realise(sisterNP).getRealisation());

            sisterNP.setPlural(true);

            SetupForRealiserTest.realiser.setDebugMode(true);
            Assert.AreEqual("Albert Einstein's sisters",
                            SetupForRealiserTest.realiser.realise(sisterNP).getRealisation());

            sisterNP.setPlural(false);

            possNP.setFeature(LexicalFeature.GENDER, Gender.MASCULINE);
            possNP.setFeature(Feature.PRONOMINAL.ToString(), true);
            Assert.AreEqual("his sister",
                            SetupForRealiserTest.realiser.realise(sisterNP).getRealisation());
            sisterNP.setPlural(true);
            Assert.AreEqual("his sisters",
                            SetupForRealiserTest.realiser.realise(sisterNP).getRealisation());
        }
예제 #9
0
        public void dwightTest()
        {
            // Rachel Dwight's test
            SetupForExternalTest.phraseFactory.setLexicon(SetupForExternalTest.lexicon);

            NPPhraseSpec noun4 = SetupForExternalTest.phraseFactory
                                 .createNounPhrase("FGFR3 gene in every cell");

            noun4.setSpecifier("the");

            PPPhraseSpec prep1 = SetupForExternalTest.phraseFactory.createPrepositionPhrase(
                "of", noun4);

            NPPhraseSpec noun1 = SetupForExternalTest.phraseFactory.createNounPhrase(
                "the", "patient's mother");

            NPPhraseSpec noun2 = SetupForExternalTest.phraseFactory.createNounPhrase(
                "the", "patient's father");

            NPPhraseSpec noun3 = SetupForExternalTest.phraseFactory
                                 .createNounPhrase("changed copy");

            noun3.addPreModifier("one");
            noun3.addComplement(prep1);

            var coordNoun1 = new CoordinatedPhraseElement(
                noun1, noun2);

            coordNoun1.setConjunction("or");

            VPPhraseSpec verbPhrase1 = SetupForExternalTest.phraseFactory.createVerbPhrase("have");

            verbPhrase1.setFeature(Feature.TENSE.ToString(), Tense.PRESENT);

            SPhraseSpec sentence1 = SetupForExternalTest.phraseFactory.createClause(coordNoun1,
                                                                                    verbPhrase1, noun3);

            Assert
            .AreEqual(
                "the patient's mother or the patient's father has one changed copy of the FGFR3 gene in every cell",

                SetupForExternalTest.realiser.realise(sentence1).getRealisation());

            // Rachel's second test
            noun3       = SetupForExternalTest.phraseFactory.createNounPhrase("a", "gene test");
            noun2       = SetupForExternalTest.phraseFactory.createNounPhrase("an", "LDL test");
            noun1       = SetupForExternalTest.phraseFactory.createNounPhrase("the", "clinic");
            verbPhrase1 = SetupForExternalTest.phraseFactory.createVerbPhrase("perform");

            var coord1 = new CoordinatedPhraseElement(noun2,
                                                      noun3);

            sentence1 = SetupForExternalTest.phraseFactory.createClause(noun1, verbPhrase1, coord1);
            sentence1.setFeature(Feature.TENSE.ToString(), Tense.PAST);

            Assert
            .AreEqual(
                "the clinic performed an LDL test and a gene test", SetupForExternalTest.realiser
                .realise(sentence1).getRealisation());
        }
예제 #10
0
        /**
         * Sets the np features.
         *
         * @param wp
         *            The xml Noun Phrase object.
         * @param p
         *            the NPPhraseSpec object to get the features.
         */
        private void setNPFeatures(wrapper.XmlNPPhraseSpec wp, NPPhraseSpec p)
        {
            if (wp.NUMBER != null)
            {
                // map number feature from wrapper ~NumberAgr to actual NumberAgr
                string numString = wp.NUMBER.ToString();
                Enum.TryParse(numString, out NumberAgreement simplenlgNum);
                // p.setFeature(Feature.NUMBER, wp.getNUMBER());
                p.setFeature(Feature.NUMBER, simplenlgNum);
            }

            if (wp.PERSON != null)
            {
                // map person feature from wrapper Person to actual Person
                string perString = wp.PERSON.ToString();
                Enum.TryParse(perString, out Person simplenlgPers);
                p.setFeature(Feature.PERSON, simplenlgPers);
            }

            if (wp.GENDER != null)
            {
                // map gender feature from wrapper Gender to actual Gender
                string genString = wp.GENDER.ToString();
                Enum.TryParse(genString, out Gender simplenlgGen);
                p.setFeature(LexicalFeature.GENDER, simplenlgGen);
            }

            p.setFeature(Feature.ELIDED, wp.ELIDED);
            p.setFeature(Feature.POSSESSIVE, wp.POSSESSIVE);
            p.setFeature(Feature.PRONOMINAL, wp.PRONOMINAL);
        }
        public virtual void spellingVariantsInNPTest()
        {
            WordElement asd = lexicon.getWord("Adams-Stokes disease");

            Assert.AreEqual("Adams-Stokes disease", asd.DefaultSpellingVariant);
            NPPhraseSpec np = factory.createNounPhrase(asd);

            np.setSpecifier(lexicon.getWord("the"));
            Assert.AreEqual("the Adams-Stokes disease", realiser.realise(np).Realisation);


            // change spelling var
            asd.DefaultSpellingVariant = "Adams Stokes disease";
            Assert.AreEqual("Adams Stokes disease", asd.DefaultSpellingVariant);
            Assert.AreEqual("the Adams Stokes disease", realiser.realise(np).Realisation);


            //default infl for this word is uncount
            np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
            Assert.AreEqual("the Adams Stokes disease", realiser.realise(np).Realisation);


            //change default infl for this word
            asd.setDefaultInflectionalVariant(Inflection.REGULAR);
            Assert.AreEqual("the Adams Stokes diseases", realiser.realise(np).Realisation);
        }
예제 #12
0
        public virtual void section8_Test()
        {
            Lexicon    lexicon    = Lexicon.DefaultLexicon;  // default simplenlg lexicon
            NLGFactory nlgFactory = new NLGFactory(lexicon); // factory based on lexicon
            Realiser   realiser   = new Realiser(lexicon);

            NPPhraseSpec subject = nlgFactory.createNounPhrase("Mary");
            NPPhraseSpec @object = nlgFactory.createNounPhrase("the monkey");
            VPPhraseSpec verb    = nlgFactory.createVerbPhrase("chase");

            subject.addModifier("fast");

            SPhraseSpec p = nlgFactory.createClause();

            p.setSubject(subject);
            p.setVerb(verb);
            p.setObject(@object);

            string outputA = realiser.realiseSentence(p);

            Assert.AreEqual("Fast Mary chases the monkey.", outputA);

            verb.addModifier("quickly");

            string outputB = realiser.realiseSentence(p);

            Assert.AreEqual("Fast Mary quickly chases the monkey.", outputB);
        }
예제 #13
0
        public virtual void testFutureTense()
        {
            SPhraseSpec test = phraseFactory.createClause();

            NPPhraseSpec subj = phraseFactory.createNounPhrase("I");

            VPPhraseSpec verb = phraseFactory.createVerbPhrase("go");

            AdvPhraseSpec adverb = phraseFactory.createAdverbPhrase("tomorrow");

            test.setSubject(subj);
            test.VerbPhrase = verb;
            test.setFeature(Feature.TENSE, Tense.FUTURE);
            test.addPostModifier(adverb);
            string sentence = realiser.realiseSentence(test);

            Assert.AreEqual("I will go tomorrow.", sentence);

            SPhraseSpec test2 = phraseFactory.createClause();
            NLGElement  vb    =
                phraseFactory.createWord("go", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.VERB));

            test2.setSubject(subj);
            test2.setVerb(vb);
            test2.setFeature(Feature.TENSE, Tense.FUTURE);
            test2.addPostModifier(adverb);
            string sentence2 = realiser.realiseSentence(test);

            Assert.AreEqual("I will go tomorrow.", sentence2);
        }
예제 #14
0
        public virtual void leanTest()
        {
            SPhraseSpec sentence = phraseFactory.createClause();

            sentence.setVerb("be");
            sentence.setObject("a ball");
            sentence.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHAT_SUBJECT);
            Assert.AreEqual("What is a ball?", realiser.realiseSentence(sentence));

            sentence = phraseFactory.createClause();
            sentence.setVerb("be");
            NPPhraseSpec @object = phraseFactory.createNounPhrase("example");

            @object.Plural = true;
            @object.addModifier("of jobs");
            sentence.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHAT_SUBJECT);
            sentence.setObject(@object);
            Assert.AreEqual("What are examples of jobs?", realiser.realiseSentence(sentence));

            SPhraseSpec  p    = phraseFactory.createClause();
            NPPhraseSpec sub1 = phraseFactory.createNounPhrase("Mary");

            sub1.setFeature(LexicalFeature.GENDER, Gender.FEMININE);
            sub1.setFeature(Feature.PRONOMINAL, true);
            sub1.setFeature(Feature.PERSON, Person.FIRST);
            p.setSubject(sub1);
            p.setVerb("chase");
            p.setObject("the monkey");


            string output2 = realiser.realiseSentence(p); // Realiser created earlier.

            Assert.AreEqual("I chase the monkey.", output2);

            SPhraseSpec  test    = phraseFactory.createClause();
            NPPhraseSpec subject = phraseFactory.createNounPhrase("Mary");

            subject.setFeature(Feature.PRONOMINAL, true);
            subject.setFeature(Feature.PERSON, Person.SECOND);
            test.setSubject(subject);
            test.setVerb("cry");

            test.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHY);
            test.setFeature(Feature.TENSE, Tense.PRESENT);
            Assert.AreEqual("Why do you cry?", realiser.realiseSentence(test));

            test    = phraseFactory.createClause();
            subject = phraseFactory.createNounPhrase("Mary");

            subject.setFeature(Feature.PRONOMINAL, true);
            subject.setFeature(Feature.PERSON, Person.SECOND);
            test.setSubject(subject);
            test.setVerb("be");
            test.setObject("crying");

            test.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHY);
            test.setFeature(Feature.TENSE, Tense.PRESENT);
            Assert.AreEqual("Why are you crying?", realiser.realiseSentence(test));
        }
예제 #15
0
        public virtual void multipleAdjPremodifiersTest()
        {
            NPPhraseSpec np = phraseFactory.createNounPhrase("a", "stenosis");

            np.addPreModifier(phraseFactory.createAdjectivePhrase("eccentric"));
            np.addPreModifier(phraseFactory.createAdjectivePhrase("discrete"));
            Assert.AreEqual("an eccentric, discrete stenosis", realiser.realise(np).Realisation);
        }
예제 #16
0
        public virtual void testAAnCoord()
        {
            NPPhraseSpec _dog = phraseFactory.createNounPhrase("a", "dog");

            _dog.addPreModifier(phraseFactory.createCoordinatedPhrase("enormous", "black"));
            string realisation = realiser.realise(_dog).Realisation;

            Assert.AreEqual("an enormous and black dog", realisation);
        }
예제 #17
0
        public virtual void stringElementAsHeadTest()
        {
            NPPhraseSpec np = phraseFactory.createNounPhrase();

            np.setHead(phraseFactory.createStringElement("dogs and cats"));
            np.setSpecifier(phraseFactory.createWord("the",
                                                     new LexicalCategory(LexicalCategory.LexicalCategoryEnum.DETERMINER)));
            Assert.AreEqual("the dogs and cats", realiser.realise(np).Realisation);
        }
예제 #18
0
        public virtual void multipleNLGElementListRealiserTest()
        {
            List <NLGElement> elements = new List <NLGElement>();
            // Create test NLGElements to realize:

            // "The cat jumping on the counter."
            DocumentElement sentence1 = nlgFactory.createSentence();
            NPPhraseSpec    subject_1 = nlgFactory.createNounPhrase("the", "cat");
            VPPhraseSpec    verb_1    = nlgFactory.createVerbPhrase("jump");

            verb_1.setFeature(Feature.FORM, Form.PRESENT_PARTICIPLE);
            PPPhraseSpec prep_1   = nlgFactory.createPrepositionPhrase();
            NPPhraseSpec object_1 = nlgFactory.createNounPhrase();

            object_1.setDeterminer("the");
            object_1.setNoun("counter");
            prep_1.addComplement(object_1);
            prep_1.setPreposition("on");
            SPhraseSpec clause_1 = nlgFactory.createClause();

            clause_1.setSubject(subject_1);
            clause_1.VerbPhrase = verb_1;
            clause_1.setObject(prep_1);
            sentence1.addComponent(clause_1);

            // "The dog running on the counter."
            DocumentElement sentence2 = nlgFactory.createSentence();
            NPPhraseSpec    subject_2 = nlgFactory.createNounPhrase("the", "dog");
            VPPhraseSpec    verb_2    = nlgFactory.createVerbPhrase("run");

            verb_2.setFeature(Feature.FORM, Form.PRESENT_PARTICIPLE);
            PPPhraseSpec prep_2   = nlgFactory.createPrepositionPhrase();
            NPPhraseSpec object_2 = nlgFactory.createNounPhrase();

            object_2.setDeterminer("the");
            object_2.setNoun("counter");
            prep_2.addComplement(object_2);
            prep_2.setPreposition("on");
            SPhraseSpec clause_2 = nlgFactory.createClause();

            clause_2.setSubject(subject_2);
            clause_2.VerbPhrase = verb_2;
            clause_2.setObject(prep_2);
            sentence2.addComponent(clause_2);


            elements.Add(sentence1);
            elements.Add(sentence2);

            IList <NLGElement> realisedElements = realiser.realise(elements);

            Assert.IsNotNull(realisedElements);
            Assert.AreEqual(2, realisedElements.Count);
            Assert.AreEqual("The cat jumping on the counter.", realisedElements[0].Realisation);
            Assert.AreEqual("The dog running on the counter.", realisedElements[1].Realisation);
        }
예제 #19
0
        public void multipleNLGElementListRealiserTest()
        {
            List <INLGElement> elements = new List <INLGElement>();
            // Create test NLGElements to realize:

            // "The cat jumping on the counter."
            DocumentElement sentence1 = SetupForRealiserTest.phraseFactory.createSentence();
            NPPhraseSpec    subject_1 = SetupForRealiserTest.phraseFactory.createNounPhrase("the", "cat");
            VPPhraseSpec    verb_1    = SetupForRealiserTest.phraseFactory.createVerbPhrase("jump");

            verb_1.setFeature(Feature.FORM.ToString(), Form.PRESENT_PARTICIPLE);
            PPPhraseSpec prep_1   = SetupForRealiserTest.phraseFactory.createPrepositionPhrase();
            NPPhraseSpec object_1 = SetupForRealiserTest.phraseFactory.createNounPhrase();

            object_1.setDeterminer("the");
            object_1.setNoun("counter");
            prep_1.addComplement(object_1);
            prep_1.setPreposition("on");
            SPhraseSpec clause_1 = SetupForRealiserTest.phraseFactory.createClause();

            clause_1.setSubject(subject_1);
            clause_1.setVerbPhrase(verb_1);
            clause_1.setObject(prep_1);
            sentence1.addComponent(clause_1);

            // "The dog running on the counter."
            DocumentElement sentence2 = SetupForRealiserTest.phraseFactory.createSentence();
            NPPhraseSpec    subject_2 = SetupForRealiserTest.phraseFactory.createNounPhrase("the", "dog");
            VPPhraseSpec    verb_2    = SetupForRealiserTest.phraseFactory.createVerbPhrase("run");

            verb_2.setFeature(Feature.FORM.ToString(), Form.PRESENT_PARTICIPLE);
            PPPhraseSpec prep_2   = SetupForRealiserTest.phraseFactory.createPrepositionPhrase();
            NPPhraseSpec object_2 = SetupForRealiserTest.phraseFactory.createNounPhrase();

            object_2.setDeterminer("the");
            object_2.setNoun("counter");
            prep_2.addComplement(object_2);
            prep_2.setPreposition("on");
            SPhraseSpec clause_2 = SetupForRealiserTest.phraseFactory.createClause();

            clause_2.setSubject(subject_2);
            clause_2.setVerbPhrase(verb_2);
            clause_2.setObject(prep_2);
            sentence2.addComponent(clause_2);


            elements.add(sentence1);
            elements.add(sentence2);

            List <INLGElement> realisedElements = SetupForRealiserTest.realiser.realise(elements);

            Assert.IsNotNull(realisedElements);
            Assert.AreEqual(2, realisedElements.size());
            Assert.AreEqual("The cat jumping on the counter.", realisedElements.get(0).getRealisation());
            Assert.AreEqual("The dog running on the counter.", realisedElements.get(1).getRealisation());
        }
예제 #20
0
        public virtual void testSingluarThatDeterminerNPObject()
        {
            SPhraseSpec sentence_1 = phraseFactory.createClause();

            NPPhraseSpec nounPhrase_1 = phraseFactory.createNounPhrase("that", "monkey");

            sentence_1.setObject(nounPhrase_1);

            Assert.AreEqual("That monkey.", realiser.realiseSentence(sentence_1));
        }
예제 #21
0
        public virtual void testLowercaseConstant()
        {
            SPhraseSpec sentence = phraseFactory.createClause();

            NPPhraseSpec subject = phraseFactory.createNounPhrase("a", "dog");

            sentence.setSubject(subject);

            string output = realiser.realiseSentence(sentence);

            Assert.AreEqual("A dog.", output);
        }
예제 #22
0
        public virtual void testPluralTheseDeterminerNPObject()
        {
            SPhraseSpec sentence_1 = phraseFactory.createClause();

            NPPhraseSpec nounPhrase_1 = phraseFactory.createNounPhrase("monkey");

            nounPhrase_1.Plural = true;
            nounPhrase_1.setDeterminer("these");
            sentence_1.setObject(nounPhrase_1);

            Assert.AreEqual("These monkeys.", realiser.realiseSentence(sentence_1));
        }
예제 #23
0
        public virtual void testIrregularSubjects()
        {
            SPhraseSpec sentence = phraseFactory.createClause();

            NPPhraseSpec subject = phraseFactory.createNounPhrase("a", "one");

            sentence.setSubject(subject);

            string output = realiser.realiseSentence(sentence);

            Assert.AreEqual("A one.", output);
        }
예제 #24
0
        public virtual void testNumericAn()
        {
            SPhraseSpec sentence = phraseFactory.createClause();

            NPPhraseSpec subject = phraseFactory.createNounPhrase("a", "11");

            sentence.setSubject(subject);

            string output = realiser.realiseSentence(sentence);

            Assert.AreEqual("An 11.", output);
        }
예제 #25
0
        public virtual void testUppercaseVowel()
        {
            SPhraseSpec sentence = phraseFactory.createClause();

            NPPhraseSpec subject = phraseFactory.createNounPhrase("a", "Emu");

            sentence.setSubject(subject);

            string output = realiser.realiseSentence(sentence);

            Assert.AreEqual("An Emu.", output);
        }
예제 #26
0
        public virtual void stringIndefiniteArticleInflectionVowelTest()
        {
            SPhraseSpec senSpec = phraseFactory.createClause();

            senSpec.addComplement(phraseFactory.createStringElement("I see a"));
            NPPhraseSpec firstNoun = phraseFactory.createNounPhrase("elephant");

            senSpec.addComplement(firstNoun);
            DocumentElement completeSen = phraseFactory.createSentence();

            completeSen.addComponent(senSpec);
            Assert.AreEqual("I see an elephant.", realiser.realise(completeSen).Realisation);
        }
예제 #27
0
        public virtual void frontNPStringElementTest()
        {
            SPhraseSpec  senSpec = phraseFactory.createClause();
            NPPhraseSpec np      = phraseFactory.createNounPhrase();

            np.setHead("cat");
            np.setDeterminer("the");
            senSpec.addComplement(np);
            senSpec.addComplement(phraseFactory.createStringElement("loves a dog"));
            DocumentElement completeSen = phraseFactory.createSentence();

            completeSen.addComponent(senSpec);
            Assert.AreEqual("The cat loves a dog.", realiser.realise(completeSen).Realisation);
        }
예제 #28
0
        public virtual void pointAbsorptionTrailingWhiteSpaceTest()
        {
            SPhraseSpec  senSpec   = phraseFactory.createClause();
            NPPhraseSpec firstNoun = phraseFactory.createNounPhrase();

            firstNoun.setNoun("yaha");
            senSpec.addComplement(firstNoun);
            senSpec.addComplement("was sleeping on his own and dreaming etc.      ");
            DocumentElement completeSen = phraseFactory.createSentence();

            completeSen.addComponent(senSpec);
            Assert.AreEqual("Yaha was sleeping on his own and dreaming etc.",
                            realiser.realise(completeSen).Realisation);
        }
예제 #29
0
        public virtual void stringIndefiniteArticleInflectionConsonantTest()
        {
            SPhraseSpec senSpec = phraseFactory.createClause();

            senSpec.addComplement(phraseFactory.createStringElement("I see an"));
            NPPhraseSpec firstNoun = phraseFactory.createNounPhrase("cow");

            senSpec.addComplement(firstNoun);
            DocumentElement completeSen = phraseFactory.createSentence();

            completeSen.addComponent(senSpec);
            // Do not attempt "an" -> "a"
            Assert.AreNotSame("I see an cow.", realiser.realise(completeSen).Realisation);
        }
예제 #30
0
        public virtual void mulitpleStringElementsTest()
        {
            SPhraseSpec senSpec = phraseFactory.createClause();

            senSpec.addComplement(phraseFactory.createStringElement("the world loves"));
            NPPhraseSpec np = phraseFactory.createNounPhrase();

            np.setHead("ABBA");
            senSpec.addComplement(np);
            senSpec.addComplement(phraseFactory.createStringElement("but not a sore loser"));
            DocumentElement completeSen = phraseFactory.createSentence();

            completeSen.addComponent(senSpec);
            Assert.AreEqual("The world loves ABBA but not a sore loser.", realiser.realise(completeSen).Realisation);
        }