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); }
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()); }
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); }
public virtual void mulitpleNPElementsTest() { SPhraseSpec senSpec = phraseFactory.createClause(); NPPhraseSpec frontNoun = phraseFactory.createNounPhrase(); frontNoun.setHead("john"); senSpec.addComplement(frontNoun); senSpec.addComplement(phraseFactory.createStringElement("is a trier")); NPPhraseSpec backNoun = phraseFactory.createNounPhrase(); backNoun.setDeterminer("for"); backNoun.setNoun("cheese"); senSpec.addComplement(backNoun); DocumentElement completeSen = phraseFactory.createSentence(); completeSen.addComponent(senSpec); Assert.AreEqual("John is a trier for cheese.", realiser.realise(completeSen).Realisation); }
public virtual void middleAbbreviationTest() { SPhraseSpec senSpec = phraseFactory.createClause(); NPPhraseSpec firstNoun = phraseFactory.createNounPhrase(); firstNoun.setNoun("yahya"); senSpec.addComplement(firstNoun); senSpec.addComplement(phraseFactory.createStringElement("and friends etc. went to")); NPPhraseSpec secondNoun = phraseFactory.createNounPhrase(); secondNoun.setDeterminer("the"); secondNoun.setNoun("park"); senSpec.addComplement(secondNoun); senSpec.addComplement("to play"); DocumentElement completeSen = phraseFactory.createSentence(); completeSen.addComponent(senSpec); Assert.AreEqual("Yahya and friends etc. went to the park to play.", realiser.realise(completeSen).Realisation); }
public virtual void whiteSpaceNPTest() { SPhraseSpec senSpec = phraseFactory.createClause(); NPPhraseSpec firstNoun = phraseFactory.createNounPhrase(); firstNoun.setDeterminer("the"); firstNoun.setNoun("Nasdaq"); senSpec.addComplement(firstNoun); senSpec.addComplement(phraseFactory.createStringElement(" rose steadily during ")); NPPhraseSpec secondNoun = phraseFactory.createNounPhrase(); secondNoun.setSpecifier("early"); secondNoun.setNoun("trading"); senSpec.addComplement(secondNoun); senSpec.addComplement(phraseFactory.createStringElement(" , however it plummeted due to")); NPPhraseSpec thirdNoun = phraseFactory.createNounPhrase(); thirdNoun.setSpecifier("a"); thirdNoun.setNoun("shock"); senSpec.addComplement(thirdNoun); senSpec.addComplement(phraseFactory.createStringElement(" after ")); NPPhraseSpec fourthNoun = phraseFactory.createNounPhrase(); fourthNoun.setNoun("IBM"); senSpec.addComplement(fourthNoun); senSpec.addComplement(phraseFactory.createStringElement("announced poor ")); NPPhraseSpec fifthNoun = phraseFactory.createNounPhrase(); fifthNoun.setSpecifier("first quarter"); fifthNoun.setNoun("results"); fifthNoun.Plural = true; senSpec.addComplement(fifthNoun); DocumentElement completeSen = phraseFactory.createSentence(); completeSen.addComponent(senSpec); Assert.AreEqual( "The Nasdaq rose steadily during early trading, however it plummeted due to a shock after IBM announced poor first quarter results.", realiser.realise(completeSen).Realisation); }