Package simplenlg.framework

Examples of simplenlg.framework.CoordinatedPhraseElement


   * Test setting a conjunction to null
   */
  public void testNullConjunction() {
    SPhraseSpec p = this.phraseFactory.createClause("I", "be", "happy");
    SPhraseSpec q = this.phraseFactory.createClause("I", "eat", "fish");
    CoordinatedPhraseElement pq = this.phraseFactory
        .createCoordinatedPhrase();
    pq.addCoordinate(p);
    pq.addCoordinate(q);
    pq.setFeature(Feature.CONJUNCTION, "");

    //should come out without conjunction
    Assert.assertEquals("I am happy I eat fish", this.realiser.realise(pq)
        .getRealisation());
   
    //should come out without conjunction
    pq.setFeature(Feature.CONJUNCTION, null);
    Assert.assertEquals("I am happy I eat fish", this.realiser.realise(pq)
        .getRealisation());

  }
View Full Code Here


    this.s4 = this.phraseFactory.createClause();
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$

    CoordinatedPhraseElement subject = this.phraseFactory
        .createCoordinatedPhrase(this.phraseFactory
            .createNounPhrase("Jane"), this.phraseFactory //$NON-NLS-1$
            .createNounPhrase("Andrew")); //$NON-NLS-1$

    this.s4.setSubject(subject);
View Full Code Here

    // infinitive -- case II
    this.s4 = this.phraseFactory.createClause();
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$

    CoordinatedPhraseElement subject = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Jane"), this.phraseFactory //$NON-NLS-1$
            .createNounPhrase("Andrew")); //$NON-NLS-1$

    this.s4.setFeature(InternalFeature.SUBJECTS, subject);
View Full Code Here

    this.s4 = this.phraseFactory.createClause();
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$

    CoordinatedPhraseElement subject = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Jane"), this.phraseFactory //$NON-NLS-1$
            .createNounPhrase("Andrew")); //$NON-NLS-1$

    this.s4.setSubject(subject);
View Full Code Here

    SPhraseSpec s5 = this.phraseFactory.createClause();
    s5.setSubject(this.phraseFactory.createNounPhrase("some", "person")); //$NON-NLS-1$ //$NON-NLS-2$
    s5.setVerbPhrase(this.phraseFactory.createVerbPhrase("stroke")); //$NON-NLS-1$
    s5.setObject(this.phraseFactory.createNounPhrase("the", "cat")); //$NON-NLS-1$ //$NON-NLS-2$

    CoordinatedPhraseElement coord = new CoordinatedPhraseElement(this.s3,
        s5);
    complexS = this.phraseFactory.createClause();
    complexS.setVerbPhrase(this.phraseFactory.createVerbPhrase("upset")); //$NON-NLS-1$
    complexS.setFeature(Feature.TENSE, Tense.PAST);
    complexS.setObject(this.phraseFactory.createNounPhrase("Peter")); //$NON-NLS-1$
    complexS.setSubject(coord);
    this.s3.setFeature(Feature.PERFECT, true);

    Assert.assertEquals("the man's having given the woman John's flower " //$NON-NLS-1$
        + "and some person's stroking the cat upset Peter", //$NON-NLS-1$
        this.realiser.realise(complexS).getRealisation());

    setUp();
    // now subordinate the complex sentence
    // coord.setClauseStatus(SPhraseSpec.ClauseType.MAIN);
    SPhraseSpec s6 = this.phraseFactory.createClause();
    s6.setVerbPhrase(this.phraseFactory.createVerbPhrase("tell")); //$NON-NLS-1$
    s6.setFeature(Feature.TENSE, Tense.PAST);
    s6.setSubject(this.phraseFactory.createNounPhrase("the", "boy")); //$NON-NLS-1$ //$NON-NLS-2$
    // ER - switched indirect and direct object
    PhraseElement indirect = this.phraseFactory.createNounPhrase("every", //$NON-NLS-1$
        "girl"); //$NON-NLS-1$
    s6.setIndirectObject(indirect);
    complexS = this.phraseFactory.createClause();
    complexS.setVerbPhrase(this.phraseFactory.createVerbPhrase("upset")); //$NON-NLS-1$
    complexS.setFeature(Feature.TENSE, Tense.PAST);
    complexS.setObject(this.phraseFactory.createNounPhrase("Peter")); //$NON-NLS-1$
    s6.setObject(complexS);
    coord = new CoordinatedPhraseElement(this.s3, s5);
    complexS.setSubject(coord);
    this.s3.setFeature(Feature.PERFECT, true);
    Assert.assertEquals(
        "the boy told every girl that the man's having given the woman " //$NON-NLS-1$
            + "John's flower and some person's stroking the cat " //$NON-NLS-1$
View Full Code Here

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

    // the coordinate sentence allows us to raise and lower complementiser
    CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(this.s1,
        this.s3);
    coord2.setFeature(Feature.TENSE, Tense.PAST);

    this.realiser.setDebugMode(true);
    Assert
        .assertEquals(
            "the woman kissed the man and the man gave the woman John's flower", //$NON-NLS-1$
View Full Code Here

    Assert.assertEquals("the baby is given 50ug of morphine by the nurse", //$NON-NLS-1$
        this.realiser.realise(_s2).getRealisation());

    // test agreement in passive
    PhraseElement _s3 = this.phraseFactory.createClause(
        new CoordinatedPhraseElement("my dog", "your cat"), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "George"); //$NON-NLS-1$
    _s3.setFeature(Feature.TENSE, Tense.PAST);
    _s3.addFrontModifier("yesterday"); //$NON-NLS-1$
    Assert.assertEquals("yesterday my dog and your cat chased George", //$NON-NLS-1$
        this.realiser.realise(_s3).getRealisation());

    _s3 = this.phraseFactory.createClause(new CoordinatedPhraseElement(
        "my dog", "your cat"), "chase", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        this.phraseFactory.createNounPhrase("George")); //$NON-NLS-1$
    _s3.setFeature(Feature.TENSE, Tense.PAST);
    _s3.addFrontModifier("yesterday"); //$NON-NLS-1$
    _s3.setFeature(Feature.PASSIVE, true);
View Full Code Here

     
      NPPhraseSpec subject1 = nlgFactory.createNounPhrase( "Mary" ) ;
      NPPhraseSpec subject2 = nlgFactory.createNounPhrase( "your", "giraffe" ) ;
     
      // next line is not correct ~ should be nlgFactory.createCoordinatedPhrase ~ may be corrected in the API
      CoordinatedPhraseElement subj = nlgFactory.createCoordinatedPhrase( subject1, subject2 ) ;
     
      VPPhraseSpec verb = nlgFactory.createVerbPhrase( "chase" ) ; ;

      SPhraseSpec p = nlgFactory.createClause( ) ;
      p.setSubject( subj ) ;
      p.setVerb( verb ) ;
      p.setObject( "the monkey" ) ;
     
      String outputA = realiser.realiseSentence( p ) ;
      Assert.assertEquals( "Mary and your giraffe chase the monkey.", outputA ) ;
     
      NPPhraseSpec object1 = nlgFactory.createNounPhrase( "the monkey" ) ;
      NPPhraseSpec object2 = nlgFactory.createNounPhrase( "George" ) ;
     
      // next line is not correct ~ should be nlgFactory.createCoordinatedPhrase ~ may be corrected in the API
      CoordinatedPhraseElement obj = nlgFactory.createCoordinatedPhrase( object1, object2 ) ;
      obj.addCoordinate( "Martha" ) ;
      p.setObject( obj ) ;
     
      String outputB = realiser.realiseSentence( p ) ;
      Assert.assertEquals( "Mary and your giraffe chase the monkey, George and Martha.", outputB )

      obj.setFeature( Feature.CONJUNCTION, "or" ) ;
     
      String outputC = realiser.realiseSentence( p ) ;
      Assert.assertEquals( "Mary and your giraffe chase the monkey, George or Martha.", outputC )
  } // testSection10
View Full Code Here

 
    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 ) ; // gives the wrong result ~ should be 'bones' but get 'bone' !
    c.addCoordinate( s3 ) ;
   
    String outputA = realiser.realiseSentence( c ) ;
    Assert.assertEquals( "My cat likes fish, my dog likes big bones and my horse likes grass.", outputA ) ;
   
    SPhraseSpec p = nlgFactory.createClause( "I", "be""happy" ) ;
View Full Code Here

    this.kiss.setFeature(Feature.TENSE,Tense.PAST);

    Assert.assertEquals("was kissing Mary", this.realiser //$NON-NLS-1$
        .realise(this.kiss).getRealisation());

    CoordinatedPhraseElement mary2 = new CoordinatedPhraseElement(mary,
        this.phraseFactory.createNounPhrase("Susan")); //$NON-NLS-1$
    // add another complement -- should come out as "Mary and Susan"
    this.kiss.clearComplements();
    this.kiss.addComplement(mary2);
    Assert.assertEquals("was kissing Mary and Susan", this.realiser //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of simplenlg.framework.CoordinatedPhraseElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.