Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
        public void xmlLexiconImmutabilityTest()
        {
            this.lexicon = new XMLLexicon();
            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.ToString()));

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

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

            sentence.addPostModifier(pp);
            var r = realiser.realiseSentence(sentence);

            Assert.AreEqual(r, "Motion observed in the walls.");

            // 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.ToString()));
        }