/** * Test for PP coordination. */ public void testCoordination() { // simple coordination var coord1 = new CoordinatedPhraseElement( this.inTheRoom, this.behindTheCurtain); Assert.AreEqual("in the room and behind the curtain", this.realiser .realise(coord1).getRealisation()); // change the conjunction coord1.setFeature(Feature.CONJUNCTION.ToString(), "or"); Assert.AreEqual("in the room or behind the curtain", this.realiser .realise(coord1).getRealisation()); // new coordinate var coord2 = new CoordinatedPhraseElement( this.onTheRock, this.underTheTable); coord2.setFeature(Feature.CONJUNCTION.ToString(), "or"); Assert.AreEqual("on the rock or under the table", this.realiser .realise(coord2).getRealisation()); // coordinate two coordinates var coord3 = new CoordinatedPhraseElement(coord1, coord2); var text = this.realiser.realise(coord3).getRealisation(); Assert .AreEqual( "in the room or behind the curtain and on the rock or under the table", text); }
public override void setUp() { base.setUp(); // // the man gives the woman John's flower PhraseElement john = phraseFactory.createNounPhrase("John"); //$NON-NLS-1$ john.setFeature(Feature.POSSESSIVE, true); PhraseElement flower = phraseFactory.createNounPhrase(john, "flower"); //$NON-NLS-1$ PhraseElement _woman = phraseFactory.createNounPhrase("the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$ s3 = phraseFactory.createClause(man, give, flower); s3.setIndirectObject(_woman); CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4 = phraseFactory.createClause(subjects, "pick up", "the balls"); //$NON-NLS-1$ - $NON-NLS-1$ s4.addPostModifier("in the shop"); //$NON-NLS-1$ s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); // this.s5 = new SPhraseSpec(); // this.s5.setSubject(new NPPhraseSpec("the", "dog")); // this.s5.setHead("be"); // this.s5.setComplement(new NPPhraseSpec("the", "rock"), // DiscourseFunction.OBJECT); }
public virtual void testCoordination() { // simple coordination CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(inTheRoom, behindTheCurtain); Assert.AreEqual("in the room and behind the curtain", realiser.realise(coord1).Realisation); //$NON-NLS-1$ // change the conjunction coord1.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$ Assert.AreEqual("in the room or behind the curtain", realiser.realise(coord1).Realisation); //$NON-NLS-1$ // new coordinate CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(onTheRock, underTheTable); coord2.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$ Assert.AreEqual("on the rock or under the table", realiser.realise(coord2).Realisation); //$NON-NLS-1$ // coordinate two coordinates CoordinatedPhraseElement coord3 = new CoordinatedPhraseElement(coord1, coord2); string text = realiser.realise(coord3).Realisation; Assert.AreEqual("in the room or behind the curtain and on the rock or under the table", text); //$NON-NLS-1$ }
public virtual void testComplementiserFeatureInACoordinatePhrase_PastTense() { phraseFactory.Lexicon = lexicon; NLGElement dave = phraseFactory.createWord("Dave Bus", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.NOUN)); NLGElement albert = phraseFactory.createWord("Albert", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.NOUN)); CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(dave, albert); PhraseElement born = phraseFactory.createClause(coord1, "be", "born"); born.setFeature(Feature.TENSE, Tense.PAST); born.addPostModifier("in"); born.setFeature(Feature.COMPLEMENTISER, "which"); PhraseElement theHouse = phraseFactory.createNounPhrase("the", "house"); theHouse.addComplement(born); PhraseElement clause = phraseFactory.createClause(theHouse, "be", phraseFactory.createPrepositionPhrase("in", "Edinburgh")); DocumentElement sentence = docFactory.createSentence(clause); NLGElement realised = realiser.realise(sentence); // Retrieve the realisation and dump it to the console Assert.AreEqual("The house which Dave Bus and Albert were born in is in Edinburgh.", realised.Realisation); }
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$ }
public void testNegatedQuestions() { setUp(); this.phraseFactory.setLexicon(this.lexicon); this.realiser.setLexicon(this.lexicon); // sentence: "the woman did not kiss the man" s1 = this.phraseFactory.createClause(this.woman, "kiss", this.man); s1.setFeature(Feature.TENSE.ToString(), Tense.PAST); s1.setFeature(Feature.NEGATED.ToString(), true); s1.setFeature(Feature.INTERROGATIVE_TYPE.ToString(), InterrogativeType.YES_NO); Assert.AreEqual("did the woman not kiss the man", this.realiser .realise(s1).getRealisation()); // sentence: however, tomorrow, Jane and Andrew will not pick up the // balls in the shop var subjects = new CoordinatedPhraseElement( this.phraseFactory.createNounPhrase("Jane"), this.phraseFactory.createNounPhrase("Andrew")); s4 = this.phraseFactory.createClause(subjects, "pick up", "the balls"); s4.addPostModifier("in the shop"); s4.setFeature(Feature.CUE_PHRASE.ToString(), "however,"); s4.addFrontModifier("tomorrow"); s4.setFeature(Feature.NEGATED.ToString(), true); s4.setFeature(Feature.TENSE.ToString(), Tense.FUTURE); s4.setFeature(Feature.INTERROGATIVE_TYPE.ToString(), InterrogativeType.YES_NO); Assert.AreEqual( "however, will Jane and Andrew not pick up the balls in the shop tomorrow", this.realiser.realise(s4).getRealisation()); }
protected override void setUp() { // // the man gives the woman John's flower var john = this.phraseFactory.createNounPhrase("John"); john.setFeature(Feature.POSSESSIVE.ToString(), true); var flower = this.phraseFactory.createNounPhrase(john, "flower"); var _woman = this.phraseFactory.createNounPhrase( "the", "woman"); s3 = this.phraseFactory.createClause(this.man, this.give, flower); s3.setIndirectObject(_woman); var subjects = new CoordinatedPhraseElement( this.phraseFactory.createNounPhrase("Jane"), this.phraseFactory.createNounPhrase("Andrew")); s4 = this.phraseFactory.createClause(subjects, "pick up", "the balls"); s4.addPostModifier("in the shop"); s4.setFeature(Feature.CUE_PHRASE.ToString(), "however"); s4.addFrontModifier("tomorrow"); s4.setFeature(Feature.TENSE.ToString(), Tense.FUTURE); // s5 = new SPhraseSpec(); // s5.setSubject(new NPPhraseSpec("the", "dog")); // s5.setHead("be"); // s5.setComplement(new NPPhraseSpec("the", "rock"), // DiscourseFunction.OBJECT); }
public void testComplementiserFeatureInACoordinatePhrase_PastTense() { var dave = this.phraseFactory.createWord("Dave Bus", new LexicalCategory_NOUN()); var albert = this.phraseFactory.createWord("Albert", new LexicalCategory_NOUN()); var coord1 = new CoordinatedPhraseElement( dave, albert); var born = this.phraseFactory.createClause(coord1, "be", "born"); born.setFeature(Feature.TENSE.ToString(), Tense.PAST); born.addPostModifier("in"); born.setFeature(Feature.COMPLEMENTISER.ToString(), "which"); var theHouse = this.phraseFactory.createNounPhrase("the", "house"); theHouse.addComplement(born); var clause = this.phraseFactory.createClause(theHouse, "be", this.phraseFactory.createPrepositionPhrase("in", "Edinburgh")); var sentence = this.phraseFactory.createSentence(clause); var realised = this.realiser.realise(sentence); // Retrieve the realisation and dump it to the console Assert.AreEqual("The house which Dave Bus and Albert were born in is in Edinburgh.", realised.getRealisation()); }
public virtual void section13_Test() { Lexicon lexicon = Lexicon.DefaultLexicon; // default simplenlg lexicon NLGFactory nlgFactory = new NLGFactory(lexicon); // factory based on lexicon Realiser realiser = new Realiser(lexicon); SPhraseSpec s1 = nlgFactory.createClause("my cat", "like", "fish"); SPhraseSpec s2 = nlgFactory.createClause("my dog", "like", "big bones"); SPhraseSpec s3 = nlgFactory.createClause("my horse", "like", "grass"); CoordinatedPhraseElement c = nlgFactory.createCoordinatedPhrase(); c.addCoordinate(s1); c.addCoordinate(s2); c.addCoordinate(s3); string outputA = realiser.realiseSentence(c); Assert.AreEqual("My cat likes fish, my dog likes big bones and my horse likes grass.", outputA); SPhraseSpec p = nlgFactory.createClause("I", "be", "happy"); SPhraseSpec q = nlgFactory.createClause("I", "eat", "fish"); q.setFeature(Feature.COMPLEMENTISER, "because"); q.setFeature(Feature.TENSE, Tense.PAST); p.addComplement(q); string outputB = realiser.realiseSentence(p); Assert.AreEqual("I am happy because I ate fish.", outputB); }
public virtual void testNegatedQuestions() { setUp(); phraseFactory.Lexicon = lexicon; realiser.Lexicon = lexicon; // sentence: "the woman did not kiss the man" s1 = phraseFactory.createClause(woman, "kiss", man); s1.setFeature(Feature.TENSE, Tense.PAST); s1.setFeature(Feature.NEGATED, true); s1.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO); Assert.AreEqual("did the woman not kiss the man", realiser.realise(s1).Realisation); //$NON-NLS-1$ // sentence: however, tomorrow, Jane and Andrew will not pick up the // balls in the shop CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4 = phraseFactory.createClause(subjects, "pick up", "the balls"); //$NON-NLS-1$ - $NON-NLS-1$ s4.addPostModifier("in the shop"); //$NON-NLS-1$ s4.setFeature(Feature.CUE_PHRASE, "however,"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ s4.setFeature(Feature.NEGATED, true); s4.setFeature(Feature.TENSE, Tense.FUTURE); s4.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO); Assert.AreEqual("however, will Jane and Andrew not pick up the balls in the shop tomorrow", realiser.realise(s4).Realisation); //$NON-NLS-1$ }
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()); }
public virtual void testCoordinateVPQuestions() { // create a complex vp: "kiss the dog and walk in the room" setUp(); CoordinatedPhraseElement complex = new CoordinatedPhraseElement(kiss, walk); kiss.addComplement(dog); walk.addComplement(inTheRoom); // sentence: "However, tomorrow, Jane and Andrew will kiss the dog and // will walk in the room" CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4 = phraseFactory.createClause(subjects, complex); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); Assert.AreEqual("however tomorrow Jane and Andrew will kiss the dog and will walk in the room", realiser.realise(s4).Realisation); //$NON-NLS-1$ // setting to interrogative should automatically give us a single, // wide-scope aux setUp(); subjects = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ kiss.addComplement(dog); walk.addComplement(inTheRoom); complex = new CoordinatedPhraseElement(kiss, walk); s4 = phraseFactory.createClause(subjects, complex); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); s4.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO); Assert.AreEqual("however will Jane and Andrew kiss the dog and walk in the room tomorrow", realiser.realise(s4).Realisation); //$NON-NLS-1$ // slightly more complex -- perfective setUp(); realiser.Lexicon = lexicon; subjects = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ complex = new CoordinatedPhraseElement(kiss, walk); kiss.addComplement(dog); walk.addComplement(inTheRoom); s4 = phraseFactory.createClause(subjects, complex); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); s4.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO); s4.setFeature(Feature.PERFECT, true); Assert.AreEqual("however will Jane and Andrew have kissed the dog and walked in the room tomorrow", realiser.realise(s4).Realisation); //$NON-NLS-1$ }
public virtual void complementationTest_2() { // give the woman the dog woman.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.INDIRECT_OBJECT); dog.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT); give.clearComplements(); give.addComplement(dog); give.addComplement(woman); Assert.AreEqual("gives the woman the dog", realiser.realise(give).Realisation); //$NON-NLS-1$ // add a few premodifiers and postmodifiers give.addPreModifier("slowly"); //$NON-NLS-1$ give.addPostModifier(behindTheCurtain); give.addPostModifier(inTheRoom); Assert.AreEqual("slowly gives the woman the dog behind the curtain in the room", realiser.realise(give).Realisation); //$NON-NLS-1$ // reset the arguments give.clearComplements(); give.addComplement(dog); CoordinatedPhraseElement womanBoy = new CoordinatedPhraseElement(woman, boy); womanBoy.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.INDIRECT_OBJECT); give.addComplement(womanBoy); // if we unset the passive, we should get the indirect objects // they won't be coordinated give.setFeature(Feature.PASSIVE, false); Assert.AreEqual("slowly gives the woman and the boy the dog behind the curtain in the room", realiser.realise(give).Realisation); //$NON-NLS-1$ // set them to a coordinate instead // set ONLY the complement INDIRECT_OBJECT, leaves OBJECT intact give.clearComplements(); give.addComplement(womanBoy); give.addComplement(dog); IList <NLGElement> complements = give.getFeatureAsElementList(InternalFeature.COMPLEMENTS); int indirectCount = 0; foreach (NLGElement eachElement in complements) { if (DiscourseFunction.INDIRECT_OBJECT.Equals(eachElement.getFeature(InternalFeature.DISCOURSE_FUNCTION)) ) { indirectCount++; } } Assert.AreEqual(1, indirectCount); // only one indirect object // where // there were two before Assert.AreEqual("slowly gives the woman and the boy the dog behind the curtain in the room", realiser.realise(give).Realisation); //$NON-NLS-1$ }
public void data2TextTest() { // Data2Text tests // test OK to have number at end of sentence SPhraseSpec p = SetupForExternalTest.phraseFactory.createClause("the dog", "weigh", "12"); Assert.AreEqual("The dog weighs 12.", SetupForExternalTest.realiser.realiseSentence(p)); // test OK to have "there be" sentence with "there" as a StringElement var dataDropout2 = SetupForExternalTest.phraseFactory.createNLGElement("data dropouts"); dataDropout2.setPlural(true); var sentence2 = SetupForExternalTest.phraseFactory.createClause(); sentence2.setSubject(SetupForExternalTest.phraseFactory.createStringElement("there")); sentence2.setVerb("be"); sentence2.setObject(dataDropout2); Assert.AreEqual("There are data dropouts.", SetupForExternalTest.realiser.realiseSentence(sentence2)); // test OK to have gerund form verb SPhraseSpec weather1 = SetupForExternalTest.phraseFactory.createClause("SE 10-15", "veer", "S 15-20"); weather1.setFeature(Feature.FORM.ToString(), Form.GERUND); Assert.AreEqual("SE 10-15 veering S 15-20.", SetupForExternalTest.realiser.realiseSentence(weather1)); // test OK to have subject only SPhraseSpec weather2 = SetupForExternalTest.phraseFactory.createClause("cloudy and misty", "be", "XXX"); weather2.getVerbPhrase().setFeature(Feature.ELIDED.ToString(), true); Assert.AreEqual("Cloudy and misty.", SetupForExternalTest.realiser.realiseSentence(weather2)); // test OK to have VP only SPhraseSpec weather3 = SetupForExternalTest.phraseFactory.createClause("S 15-20", "increase", "20-25"); weather3.setFeature(Feature.FORM.ToString(), Form.GERUND); weather3.getSubject().setFeature(Feature.ELIDED.ToString(), true); Assert.AreEqual("Increasing 20-25.", SetupForExternalTest.realiser.realiseSentence(weather3)); // conjoined test SPhraseSpec weather4 = SetupForExternalTest.phraseFactory.createClause("S 20-25", "back", "SSE"); weather4.setFeature(Feature.FORM.ToString(), Form.GERUND); weather4.getSubject().setFeature(Feature.ELIDED.ToString(), true); var coord = new CoordinatedPhraseElement(); coord.addCoordinate(weather1); coord.addCoordinate(weather3); coord.addCoordinate(weather4); coord.setConjunction("then"); Assert.AreEqual("SE 10-15 veering S 15-20, increasing 20-25 then backing SSE.", SetupForExternalTest.realiser.realiseSentence(coord)); // no verb SPhraseSpec weather5 = SetupForExternalTest.phraseFactory.createClause("rain", null, "likely"); Assert.AreEqual("Rain likely.", SetupForExternalTest.realiser.realiseSentence(weather5)); }
/** * Applies aggregation to two NLGElements e1 and e2, succeeding only if they * are clauses (that is, e1.getCategory() == e2.getCategory == * {@link simplenlg.framework.PhraseCategory#CLAUSE}). */ public override NLGElement apply(NLGElement previous, NLGElement next) { NLGElement aggregated = null; if (previous.Category == PhraseCategory.PhraseCategoryEnum.CLAUSE && next.Category == PhraseCategory.PhraseCategoryEnum.CLAUSE && PhraseChecker.nonePassive(previous, next) && !PhraseChecker.expletiveSubjects(previous, next)) { if (PhraseChecker.sameSentences(previous, next)) { // case 1: identical sentences: remove the current aggregated = previous; } else if (PhraseChecker.sameFrontMods(previous, next) && PhraseChecker.sameSubjects(previous, next) && PhraseChecker.samePostMods(previous, next)) { // case 2: subjects identical: coordinate VPs aggregated = factory.createClause(); aggregated.setFeature(InternalFeature.SUBJECTS, previous.getFeatureAsElementList(InternalFeature.SUBJECTS)); aggregated.setFeature(InternalFeature.FRONT_MODIFIERS, previous.getFeatureAsElement(InternalFeature.FRONT_MODIFIERS)); aggregated.setFeature(Feature.CUE_PHRASE, previous.getFeatureAsElement(Feature.CUE_PHRASE)); aggregated.setFeature(InternalFeature.POSTMODIFIERS, previous.getFeatureAsElementList(InternalFeature.POSTMODIFIERS)); NLGElement vp; if (!PhraseChecker.sameVPArgs(previous, next) && PhraseChecker.sameVPHead(previous, next) && PhraseChecker.sameVPModifiers(previous, next)) { // case 2.1: VPs have different arguments but same head & mods NLGElement vp1 = previous.getFeatureAsElement(InternalFeature.VERB_PHRASE); vp = factory.createVerbPhrase(); vp.setFeature(InternalFeature.HEAD, vp1.getFeatureAsElement(InternalFeature.HEAD)); vp.setFeature(InternalFeature.COMPLEMENTS, vp1.getFeatureAsElementList(InternalFeature.COMPLEMENTS)); vp.setFeature(InternalFeature.PREMODIFIERS, vp1.getFeatureAsElementList(InternalFeature.PREMODIFIERS)); vp.setFeature(InternalFeature.POSTMODIFIERS, vp1.getFeatureAsElementList(InternalFeature.POSTMODIFIERS)); } else { // case 2.2: just create a coordinate vP NLGElement vp1 = previous.getFeatureAsElement(InternalFeature.VERB_PHRASE); NLGElement vp2 = next.getFeatureAsElement(InternalFeature.VERB_PHRASE); vp = factory.createCoordinatedPhrase(vp1, vp2); } // case 2.3: expletive subjects aggregated.setFeature(InternalFeature.VERB_PHRASE, vp); } else if (PhraseChecker.sameFrontMods(previous, next) && PhraseChecker.sameVP(previous, next) && PhraseChecker.samePostMods(previous, next)) { // case 3: identical VPs: conjoin subjects and front modifiers aggregated = factory.createClause(); aggregated.setFeature(InternalFeature.FRONT_MODIFIERS, previous.getFeatureAsElementList(InternalFeature.FRONT_MODIFIERS)); CoordinatedPhraseElement subjects = factory.createCoordinatedPhrase(); subjects.Category = new PhraseCategory(PhraseCategory.PhraseCategoryEnum.NOUN_PHRASE); IList <NLGElement> allSubjects = previous.getFeatureAsElementList(InternalFeature.SUBJECTS); ((List <NLGElement>)allSubjects).AddRange(next.getFeatureAsElementList(InternalFeature.SUBJECTS)); foreach (NLGElement subj in allSubjects) { subjects.addCoordinate(subj); } aggregated.setFeature(InternalFeature.SUBJECTS, subjects); aggregated.setFeature(InternalFeature.POSTMODIFIERS, previous.getFeatureAsElementList(InternalFeature.POSTMODIFIERS)); aggregated.setFeature(InternalFeature.VERB_PHRASE, previous.getFeature(InternalFeature.VERB_PHRASE)); } } return(aggregated); }
public virtual void testForm() { // check the getter method Assert.AreEqual(Form.NORMAL, s1.getFeatureAsElement(InternalFeature.VERB_PHRASE).getFeature(Feature.FORM)); // infinitive s1.setFeature(Feature.FORM, Form.INFINITIVE); Assert.AreEqual("to kiss the man", realiser.realise(s1).Realisation); //$NON-NLS-1$ // gerund with "there" s2.setFeature(Feature.FORM, Form.GERUND); Assert.AreEqual("there being the dog on the rock", realiser.realise(s2).Realisation); //$NON-NLS-1$ // gerund with possessive s3.setFeature(Feature.FORM, Form.GERUND); Assert.AreEqual("the man's giving the woman John's flower", realiser.realise(s3).Realisation); //$NON-NLS-1$ // imperative s3.setFeature(Feature.FORM, Form.IMPERATIVE); Assert.AreEqual("give the woman John's flower", realiser.realise(s3).Realisation); //$NON-NLS-1$ // subordinating the imperative to a verb should turn it to infinitive say.addComplement(s3); Assert.AreEqual("says to give the woman John's flower", realiser.realise(say).Realisation); //$NON-NLS-1$ // imperative -- case II s4.setFeature(Feature.FORM, Form.IMPERATIVE); Assert.AreEqual("however tomorrow pick up the balls in the shop", realiser.realise(s4).Realisation); //$NON-NLS-1$ // infinitive -- case II s4 = phraseFactory.createClause(); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ CoordinatedPhraseElement subject = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4.setFeature(InternalFeature.SUBJECTS, subject); PhraseElement pick = phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$ s4.setFeature(InternalFeature.VERB_PHRASE, pick); s4.setObject("the balls"); //$NON-NLS-1$ s4.addPostModifier("in the shop"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); s4.setFeature(Feature.FORM, Form.INFINITIVE); Assert.AreEqual("however to pick up the balls in the shop tomorrow", realiser.realise(s4).Realisation); //$NON-NLS-1$ }
public void testForm2() { // set s4 as subject of a new sentence var temp = this.phraseFactory.createClause(s4, "be", "recommended"); Assert.AreEqual( "however tomorrow Jane and Andrew's picking up the " + "balls in the shop is recommended", this.realiser.realise(temp).getRealisation()); // compose this with a new sentence // ER - switched direct and indirect object in sentence var temp2 = this.phraseFactory.createClause("I", "tell", temp); temp2.setFeature(Feature.TENSE.ToString(), Tense.FUTURE); var indirectObject = this.phraseFactory .createNounPhrase("John"); temp2.setIndirectObject(indirectObject); Assert.AreEqual("I will tell John that however tomorrow Jane and " + "Andrew's picking up the balls in the shop is " + "recommended", this.realiser.realise(temp2).getRealisation()); // turn s4 to imperative and put it in indirect object position s4 = this.phraseFactory.createClause(); s4.setFeature(Feature.CUE_PHRASE.ToString(), "however"); s4.addFrontModifier("tomorrow"); var subject = new CoordinatedPhraseElement( this.phraseFactory.createNounPhrase("Jane"), this.phraseFactory .createNounPhrase("Andrew")); s4.setSubject(subject); var pick = this.phraseFactory.createVerbPhrase("pick up"); s4.setVerbPhrase(pick); s4.setObject("the balls"); s4.addPostModifier("in the shop"); s4.setFeature(Feature.TENSE.ToString(), Tense.FUTURE); s4.setFeature(Feature.FORM.ToString(), Form.IMPERATIVE); temp2 = this.phraseFactory.createClause("I", "tell", s4); indirectObject = this.phraseFactory.createNounPhrase("John"); temp2.setIndirectObject(indirectObject); temp2.setFeature(Feature.TENSE.ToString(), Tense.FUTURE); Assert.AreEqual("I will tell John however to pick up the balls " + "in the shop tomorrow", this.realiser.realise(temp2) .getRealisation()); }
public void testCoordination2() { // simple coordination of complementised nps this.dog.clearComplements(); this.woman.clearComplements(); var cnp1 = new CoordinatedPhraseElement(this.dog, this.woman); cnp1.setFeature(Feature.RAISE_SPECIFIER.ToString(), true); var realised = this.realiser.realise(cnp1); Assert.AreEqual("the dog and woman", realised.getRealisation()); this.dog.addComplement(this.onTheRock); this.woman.addComplement(this.behindTheCurtain); var cnp2 = new CoordinatedPhraseElement(this.dog, this.woman); this.woman.setFeature(InternalFeature.RAISED.ToString(), false); Assert.AreEqual( "the dog on the rock and the woman behind the curtain", this.realiser.realise(cnp2).getRealisation()); // complementised coordinates + outer pp modifier cnp2.addPostModifier(this.inTheRoom); Assert .AreEqual( "the dog on the rock and the woman behind the curtain in the room", this.realiser.realise(cnp2).getRealisation()); // set the specifier for this cnp; should unset specifiers for all inner // coordinates var every = this.phraseFactory.createWord( "every", new LexicalCategory_DETERMINER()); cnp2.setFeature(InternalFeature.SPECIFIER.ToString(), every); Assert .AreEqual( "every dog on the rock and every woman behind the curtain in the room", this.realiser.realise(cnp2).getRealisation()); // pronominalise one of the constituents this.dog.setFeature(Feature.PRONOMINAL.ToString(), true); // ="it" this.dog.setFeature(InternalFeature.SPECIFIER.ToString(), this.phraseFactory .createWord("the", new LexicalCategory_DETERMINER())); // raising spec still returns true as spec has been set cnp2.setFeature(Feature.RAISE_SPECIFIER.ToString(), true); // CNP should be realised with pronominal internal const Assert.AreEqual( "it and every woman behind the curtain in the room", this.realiser.realise(cnp2).getRealisation()); }
public virtual void data2TextTest() { SPhraseSpec p = phraseFactory.createClause("the dog", "weigh", "12"); Assert.AreEqual("The dog weighes 12.", realiser.realiseSentence(p)); NLGElement dataDropout2 = phraseFactory.createNLGElement("data dropouts"); dataDropout2.Plural = true; SPhraseSpec sentence2 = phraseFactory.createClause(); sentence2.setSubject(phraseFactory.createStringElement("there")); sentence2.setVerb("be"); sentence2.setObject(dataDropout2); Assert.AreEqual("There are data dropouts.", realiser.realiseSentence(sentence2)); SPhraseSpec weather1 = phraseFactory.createClause("SE 10-15", "veer", "S 15-20"); weather1.setFeature(Feature.FORM, Form.GERUND); Assert.AreEqual("SE 10-15 veering S 15-20.", realiser.realiseSentence(weather1)); SPhraseSpec weather2 = phraseFactory.createClause("cloudy and misty", "be", "XXX"); weather2.VerbPhrase.setFeature(Feature.ELIDED, true); Assert.AreEqual("Cloudy and misty.", realiser.realiseSentence(weather2)); SPhraseSpec weather3 = phraseFactory.createClause("S 15-20", "increase", "20-25"); weather3.setFeature(Feature.FORM, Form.GERUND); weather3.getSubject().setFeature(Feature.ELIDED, true); Assert.AreEqual("Increasing 20-25.", realiser.realiseSentence(weather3)); SPhraseSpec weather4 = phraseFactory.createClause("S 20-25", "back", "SSE"); weather4.setFeature(Feature.FORM, Form.GERUND); weather4.getSubject().setFeature(Feature.ELIDED, true); CoordinatedPhraseElement coord = new CoordinatedPhraseElement(); coord.addCoordinate(weather1); coord.addCoordinate(weather3); coord.addCoordinate(weather4); coord.Conjunction = "then"; Assert.AreEqual("SE 10-15 veering S 15-20, increasing 20-25 then backing SSE.", realiser.realiseSentence(coord)); SPhraseSpec weather5 = phraseFactory.createClause("rain", null, "likely"); Assert.AreEqual("Rain likely.", realiser.realiseSentence(weather5)); }
/** * Sets the common features from the phrase to the child element. * * @param phrase * the <code>CoordinatedPhraseElement</code> * @param child * a single coordinated <code>NLGElement</code> within the * coordination. */ private static void setChildFeatures(CoordinatedPhraseElement phrase, NLGElement child) { if (phrase.hasFeature(Feature.PROGRESSIVE)) { child.setFeature(Feature.PROGRESSIVE, phrase.getFeature(Feature.PROGRESSIVE)); } if (phrase.hasFeature(Feature.PERFECT)) { child.setFeature(Feature.PERFECT, phrase.getFeature(Feature.PERFECT)); } if (phrase.hasFeature(InternalFeature.SPECIFIER)) { child.setFeature(InternalFeature.SPECIFIER, phrase.getFeature(InternalFeature.SPECIFIER)); } if (phrase.hasFeature(LexicalFeature.GENDER)) { child.setFeature(LexicalFeature.GENDER, phrase.getFeature(LexicalFeature.GENDER)); } if (phrase.hasFeature(Feature.NUMBER)) { child.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER)); } if (phrase.hasFeature(Feature.TENSE)) { child.setFeature(Feature.TENSE, phrase.getFeature(Feature.TENSE)); } if (phrase.hasFeature(Feature.PERSON)) { child.setFeature(Feature.PERSON, phrase.getFeature(Feature.PERSON)); } if (phrase.hasFeature(Feature.NEGATED)) { child.setFeature(Feature.NEGATED, phrase.getFeature(Feature.NEGATED)); } if (phrase.hasFeature(Feature.MODAL)) { child.setFeature(Feature.MODAL, phrase.getFeature(Feature.MODAL)); } if (phrase.hasFeature(InternalFeature.DISCOURSE_FUNCTION)) { child.setFeature(InternalFeature.DISCOURSE_FUNCTION, phrase.getFeature(InternalFeature.DISCOURSE_FUNCTION)); } if (phrase.hasFeature(Feature.FORM)) { child.setFeature(Feature.FORM, phrase.getFeature(Feature.FORM)); } if (phrase.hasFeature(InternalFeature.CLAUSE_STATUS)) { child.setFeature(InternalFeature.CLAUSE_STATUS, phrase.getFeature(InternalFeature.CLAUSE_STATUS)); } if (phrase.hasFeature(Feature.INTERROGATIVE_TYPE)) { child.setFeature(InternalFeature.IGNORE_MODAL, true); } }
public virtual void aggregationStringElementTest() { CoordinatedPhraseElement coordinate = phraseFactory.createCoordinatedPhrase( new StringElement("John is going to Tesco"), new StringElement("Mary is going to Sainsburys")); SPhraseSpec sentence = phraseFactory.createClause(); sentence.addComplement(coordinate); Assert.AreEqual("John is going to Tesco and Mary is going to Sainsburys.", realiser.realiseSentence(sentence)); }
public virtual void emptyCoordinationTest() { // first a simple phrase with no coordinates CoordinatedPhraseElement coord = phraseFactory.createCoordinatedPhrase(); Assert.AreEqual("", realiser.realise(coord).Realisation); // now one with a premodifier and nothing else coord.addPreModifier(phraseFactory.createAdjectivePhrase("nice")); Assert.AreEqual("nice", realiser.realise(coord).Realisation); }
public virtual void testNegationFeature() { SPhraseSpec s1 = phraseFactory.createClause("he", "have", "asthma"); SPhraseSpec s2 = phraseFactory.createClause("he", "have", "diabetes"); s1.setFeature(Feature.NEGATED, true); CoordinatedPhraseElement coord = phraseFactory.createCoordinatedPhrase(s1, s2); string realisation = realiser.realise(coord).Realisation; Console.WriteLine(realisation); Assert.AreEqual("he does not have asthma and he has diabetes", realisation); }
public void testAdj() { // form the adjphrase "incredibly salacious" this.salacious.addPreModifier(this.phraseFactory .createAdverbPhrase("incredibly")); Assert.AreEqual("incredibly salacious", this.realiser .realise(this.salacious).getRealisation()); // form the adjphrase "incredibly beautiful" this.beautiful.addPreModifier("amazingly"); Assert.AreEqual("amazingly beautiful", this.realiser .realise(this.beautiful).getRealisation()); // coordinate the two aps var coordap = new CoordinatedPhraseElement( this.salacious, this.beautiful); Assert.AreEqual("incredibly salacious and amazingly beautiful", this.realiser.realise(coordap).getRealisation()); // changing the inner conjunction coordap.setFeature(Feature.CONJUNCTION.ToString(), "or"); Assert.AreEqual("incredibly salacious or amazingly beautiful", this.realiser.realise(coordap).getRealisation()); // coordinate this with a new AdjPhraseSpec var coord2 = new CoordinatedPhraseElement(coordap, this.stunning); //this.realiser.setDebugMode(true); Assert.AreEqual( "incredibly salacious or amazingly beautiful and stunning", this.realiser.realise(coord2).getRealisation()); // add a premodifier the coordinate phrase, yielding // "seriously and undeniably incredibly salacious or amazingly beautiful // and stunning" var preMod = new CoordinatedPhraseElement( new StringElement("seriously"), new StringElement("undeniably")); coord2.addPreModifier(preMod); Assert.AreEqual( "seriously and undeniably incredibly salacious or amazingly beautiful and stunning", this.realiser.realise(coord2).getRealisation()); // adding a coordinate rather than coordinating should give a different // result coordap.addCoordinate(this.stunning); Assert.AreEqual( "incredibly salacious, amazingly beautiful or stunning", this.realiser.realise(coordap).getRealisation()); }
public virtual void testCoordination2() { // simple coordination of complementised nps dog.clearComplements(); woman.clearComplements(); CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(dog, woman); cnp1.setFeature(Feature.RAISE_SPECIFIER, true); NLGElement realised = realiser.realise(cnp1); Assert.AreEqual("the dog and woman", realised.Realisation); dog.addComplement(onTheRock); woman.addComplement(behindTheCurtain); CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(dog, woman); woman.setFeature(InternalFeature.RAISED, false); Assert.AreEqual("the dog on the rock and the woman behind the curtain", realiser.realise(cnp2).Realisation); //$NON-NLS-1$ // complementised coordinates + outer pp modifier cnp2.addPostModifier(inTheRoom); Assert.AreEqual("the dog on the rock and the woman behind the curtain in the room", realiser.realise(cnp2).Realisation); //$NON-NLS-1$ // set the specifier for this cnp; should unset specifiers for all inner coordinates NLGElement every = phraseFactory.createWord("every", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.DETERMINER)); //$NON-NLS-1$ cnp2.setFeature(InternalFeature.SPECIFIER, every); Assert.AreEqual("every dog on the rock and every woman behind the curtain in the room", realiser.realise(cnp2).Realisation); //$NON-NLS-1$ // pronominalise one of the constituents dog.setFeature(Feature.PRONOMINAL, true); // ="it" dog.setFeature(InternalFeature.SPECIFIER, phraseFactory.createWord("the", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.DETERMINER))); // raising spec still returns true as spec has been set cnp2.setFeature(Feature.RAISE_SPECIFIER, true); // CNP should be realised with pronominal internal const Assert.AreEqual("it and every woman behind the curtain in the room", realiser.realise(cnp2).Realisation); //$NON-NLS-1$ }
public virtual void testForm2() { // set s4 as subject of a new sentence SPhraseSpec temp = phraseFactory.createClause(s4, "be", "recommended"); //$NON-NLS-1$ - $NON-NLS-1$ Assert.AreEqual("however tomorrow Jane and Andrew's picking up the " + "balls in the shop is recommended", realiser.realise(temp).Realisation); //$NON-NLS-1$ - $NON-NLS-1$ // compose this with a new sentence // ER - switched direct and indirect object in sentence SPhraseSpec temp2 = phraseFactory.createClause("I", "tell", temp); //$NON-NLS-1$ //$NON-NLS-2$ temp2.setFeature(Feature.TENSE, Tense.FUTURE); PhraseElement indirectObject = phraseFactory.createNounPhrase("John"); //$NON-NLS-1$ temp2.setIndirectObject(indirectObject); Assert.AreEqual( "I will tell John that however tomorrow Jane and " + "Andrew's picking up the balls in the shop is " + "recommended", realiser.realise(temp2).Realisation); //$NON-NLS-1$ - $NON-NLS-1$ - $NON-NLS-1$ // turn s4 to imperative and put it in indirect object position s4 = phraseFactory.createClause(); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ CoordinatedPhraseElement subject = new CoordinatedPhraseElement(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4.setSubject(subject); PhraseElement pick = phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$ s4.VerbPhrase = pick; s4.setObject("the balls"); //$NON-NLS-1$ s4.addPostModifier("in the shop"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); s4.setFeature(Feature.FORM, Form.IMPERATIVE); temp2 = phraseFactory.createClause("I", "tell", s4); //$NON-NLS-1$ //$NON-NLS-2$ indirectObject = phraseFactory.createNounPhrase("John"); //$NON-NLS-1$ temp2.setIndirectObject(indirectObject); temp2.setFeature(Feature.TENSE, Tense.FUTURE); Assert.AreEqual("I will tell John however to pick up the balls " + "in the shop tomorrow", realiser.realise(temp2).Realisation); //$NON-NLS-1$ - $NON-NLS-1$ }
public virtual void testAdj() { // form the adjphrase "incredibly salacious" salacious.addPreModifier(phraseFactory.createAdverbPhrase("incredibly")); //$NON-NLS-1$ Assert.AreEqual("incredibly salacious", realiser.realise(salacious).Realisation); //$NON-NLS-1$ // form the adjphrase "incredibly beautiful" beautiful.addPreModifier("amazingly"); //$NON-NLS-1$ Assert.AreEqual("amazingly beautiful", realiser.realise(beautiful).Realisation); //$NON-NLS-1$ // coordinate the two aps CoordinatedPhraseElement coordap = new CoordinatedPhraseElement(salacious, beautiful); Assert.AreEqual("incredibly salacious and amazingly beautiful", realiser.realise(coordap).Realisation); //$NON-NLS-1$ // changing the inner conjunction coordap.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$ Assert.AreEqual("incredibly salacious or amazingly beautiful", realiser.realise(coordap).Realisation); //$NON-NLS-1$ // coordinate this with a new AdjPhraseSpec CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(coordap, stunning); Assert.AreEqual("incredibly salacious or amazingly beautiful and stunning", realiser.realise(coord2).Realisation); //$NON-NLS-1$ // add a premodifier the coordinate phrase, yielding // "seriously and undeniably incredibly salacious or amazingly beautiful // and stunning" CoordinatedPhraseElement preMod = new CoordinatedPhraseElement(new StringElement("seriously"), new StringElement("undeniably")); //$NON-NLS-1$//$NON-NLS-2$ coord2.addPreModifier(preMod); Assert.AreEqual("seriously and undeniably incredibly salacious or amazingly beautiful and stunning", realiser.realise(coord2).Realisation); //$NON-NLS-1$ // adding a coordinate rather than coordinating should give a different result coordap.addCoordinate(stunning); Assert.AreEqual("incredibly salacious, amazingly beautiful or stunning", realiser.realise(coordap).Realisation); //$NON-NLS-1$ }
public void complementationTest() { // was kissing Mary var mary = this.phraseFactory.createNounPhrase("Mary"); mary.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.OBJECT); this.kiss.clearComplements(); this.kiss.addComplement(mary); this.kiss.setFeature(Feature.PROGRESSIVE.ToString(), true); this.kiss.setFeature(Feature.TENSE.ToString(), Tense.PAST); Assert.AreEqual("was kissing Mary", this.realiser .realise(this.kiss).getRealisation()); var mary2 = new CoordinatedPhraseElement(mary, this.phraseFactory.createNounPhrase("Susan")); // add another complement -- should come out as "Mary and Susan" this.kiss.clearComplements(); this.kiss.addComplement(mary2); Assert.AreEqual("was kissing Mary and Susan", this.realiser .realise(this.kiss).getRealisation()); // passivise -- should make the direct object complement disappear // Note: The verb doesn't come out as plural because agreement // is determined by the sentential subjects and this VP isn't inside a // sentence this.kiss.setFeature(Feature.PASSIVE.ToString(), true); Assert.AreEqual("was being kissed", this.realiser .realise(this.kiss).getRealisation()); // make it plural (this is usually taken care of in SPhraseSpec) this.kiss.setFeature(Feature.NUMBER.ToString(), NumberAgreement.PLURAL); Assert.AreEqual("were being kissed", this.realiser.realise( this.kiss).getRealisation()); // depassivise and add post-mod: yields "was kissing Mary in the room" this.kiss.addPostModifier(this.inTheRoom); this.kiss.setFeature(Feature.PASSIVE.ToString(), false); this.kiss.setFeature(Feature.NUMBER.ToString(), NumberAgreement.SINGULAR); Assert.AreEqual("was kissing Mary and Susan in the room", this.realiser.realise(this.kiss).getRealisation()); // passivise again: should make direct object disappear, but not postMod // ="was being kissed in the room" this.kiss.setFeature(Feature.PASSIVE.ToString(), true); this.kiss.setFeature(Feature.NUMBER.ToString(), NumberAgreement.PLURAL); Assert.AreEqual("were being kissed in the room", this.realiser .realise(this.kiss).getRealisation()); }
public virtual void dwightTest() { phraseFactory.Lexicon = lexicon; NPPhraseSpec noun4 = phraseFactory.createNounPhrase("FGFR3 gene in every cell"); //$NON-NLS-1$ noun4.setSpecifier("the"); PhraseElement prep1 = phraseFactory.createPrepositionPhrase("of", noun4); //$NON-NLS-1$ PhraseElement noun1 = phraseFactory.createNounPhrase("the", "patient's mother"); //$NON-NLS-1$ //$NON-NLS-2$ PhraseElement noun2 = phraseFactory.createNounPhrase("the", "patient's father"); //$NON-NLS-1$ //$NON-NLS-2$ PhraseElement noun3 = phraseFactory.createNounPhrase("changed copy"); //$NON-NLS-1$ noun3.addPreModifier("one"); //$NON-NLS-1$ noun3.addComplement(prep1); CoordinatedPhraseElement coordNoun1 = new CoordinatedPhraseElement(noun1, noun2); coordNoun1.Conjunction = "or"; //$NON-NLS-1$ PhraseElement verbPhrase1 = phraseFactory.createVerbPhrase("have"); //$NON-NLS-1$ verbPhrase1.setFeature(Feature.TENSE, Tense.PRESENT); PhraseElement sentence1 = phraseFactory.createClause(coordNoun1, verbPhrase1, noun3); realiser.DebugMode = true; Assert.AreEqual( "the patient's mother or the patient's father has one changed copy of the FGFR3 gene in every cell", realiser.realise(sentence1).Realisation); //$NON-NLS-1$ noun3 = phraseFactory.createNounPhrase("a", "gene test"); //$NON-NLS-1$ //$NON-NLS-2$ noun2 = phraseFactory.createNounPhrase("an", "LDL test"); //$NON-NLS-1$ //$NON-NLS-2$ noun1 = phraseFactory.createNounPhrase("the", "clinic"); //$NON-NLS-1$ //$NON-NLS-2$ verbPhrase1 = phraseFactory.createVerbPhrase("perform"); //$NON-NLS-1$ CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(noun2, noun3); sentence1 = phraseFactory.createClause(noun1, verbPhrase1, coord1); sentence1.setFeature(Feature.TENSE, Tense.PAST); Assert.AreEqual("the clinic performed an LDL test and a gene test", realiser.realise(sentence1).Realisation); //$NON-NLS-1$ }
public override void setUp() { base.setUp(); // the woman kisses the man s1 = phraseFactory.createClause(); s1.setSubject(woman); s1.VerbPhrase = kiss; s1.setObject(man); // there is the dog on the rock s2 = phraseFactory.createClause(); s2.setSubject("there"); //$NON-NLS-1$ s2.setVerb("be"); //$NON-NLS-1$ s2.setObject(dog); s2.addPostModifier(onTheRock); // the man gives the woman John's flower s3 = phraseFactory.createClause(); s3.setSubject(man); s3.VerbPhrase = give; NPPhraseSpec flower = phraseFactory.createNounPhrase("flower"); //$NON-NLS-1$ NPPhraseSpec john = phraseFactory.createNounPhrase("John"); //$NON-NLS-1$ john.setFeature(Feature.POSSESSIVE, true); flower.setFeature(InternalFeature.SPECIFIER, john); s3.setObject(flower); s3.setIndirectObject(woman); s4 = phraseFactory.createClause(); s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$ s4.addFrontModifier("tomorrow"); //$NON-NLS-1$ CoordinatedPhraseElement subject = phraseFactory.createCoordinatedPhrase(phraseFactory.createNounPhrase("Jane"), phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$ - $NON-NLS-1$ s4.setSubject(subject); PhraseElement pick = phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$ s4.VerbPhrase = pick; s4.setObject("the balls"); //$NON-NLS-1$ s4.addPostModifier("in the shop"); //$NON-NLS-1$ s4.setFeature(Feature.TENSE, Tense.FUTURE); }