Package simplenlg.framework

Examples of simplenlg.framework.CoordinatedPhraseElement


    this.beautiful.addPreModifier("amazingly"); //$NON-NLS-1$
    Assert.assertEquals("amazingly beautiful", this.realiser //$NON-NLS-1$
        .realise(this.beautiful).getRealisation());

    // coordinate the two aps
    CoordinatedPhraseElement coordap = new CoordinatedPhraseElement(
        this.salacious, this.beautiful);
    Assert.assertEquals("incredibly salacious and amazingly beautiful", //$NON-NLS-1$
        this.realiser.realise(coordap).getRealisation());

    // changing the inner conjunction
    coordap.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$
    Assert.assertEquals("incredibly salacious or amazingly beautiful", //$NON-NLS-1$
        this.realiser.realise(coordap).getRealisation());

    // coordinate this with a new AdjPhraseSpec
    CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(coordap,
        this.stunning);
    Assert.assertEquals(
        "incredibly salacious or amazingly beautiful and stunning", //$NON-NLS-1$
        this.realiser.realise(coord2).getRealisation());

    // 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
        .assertEquals(
View Full Code Here


   * Test for coordinate NP complements of PPs.
   */
  @Test
  public void testComplementation() {
    this.inTheRoom.clearComplements();
    this.inTheRoom.addComplement(new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("the", "room"), //$NON-NLS-1$ //$NON-NLS-2$
        this.phraseFactory.createNounPhrase("a", "car"))); //$NON-NLS-1$//$NON-NLS-2$
    Assert.assertEquals("in the room and a car", this.realiser //$NON-NLS-1$
        .realise(this.inTheRoom).getRealisation());
  }
View Full Code Here

   * Test for PP coordination.
   */
  public void testCoordination() {
    // simple coordination

    CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
        this.inTheRoom, this.behindTheCurtain);
    Assert.assertEquals("in the room and behind the curtain", this.realiser //$NON-NLS-1$
        .realise(coord1).getRealisation());

    // change the conjunction
    coord1.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$
    Assert.assertEquals("in the room or behind the curtain", this.realiser //$NON-NLS-1$
        .realise(coord1).getRealisation());

    // new coordinate
    CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(
        this.onTheRock, this.underTheTable);
    coord2.setFeature(Feature.CONJUNCTION, "or"); //$NON-NLS-1$
    Assert.assertEquals("on the rock or under the table", this.realiser //$NON-NLS-1$
        .realise(coord2).getRealisation());

    // coordinate two coordinates
    CoordinatedPhraseElement coord3 = new CoordinatedPhraseElement(coord1,
        coord2);

    String text = this.realiser.realise(coord3).getRealisation();
    Assert
        .assertEquals(
View Full Code Here

  /**
   * Check that empty coordinate phrases are not realised as "null"
   */
  public void testEmptyCoordination() {   
    //first a simple phrase with no coordinates
    CoordinatedPhraseElement coord = this.phraseFactory.createCoordinatedPhrase();
    Assert.assertEquals("", this.realiser.realise(coord).getRealisation());
   
    //now one with a premodifier and nothing else
    coord.addPreModifier(this.phraseFactory.createAdjectivePhrase("nice"));
    Assert.assertEquals("nice", this.realiser.realise(coord).getRealisation());     
  }
View Full Code Here

    this.phraseFactory.setLexicon(this.lexicon);

    NLGElement dave = phraseFactory.createWord("Dave Bus", LexicalCategory.NOUN);
    NLGElement albert = phraseFactory.createWord("Albert", LexicalCategory.NOUN);
   
    CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
        dave, albert);
   
    PhraseElement born = phraseFactory.createClause(coord1, "be", "born");
    born.setFeature(Feature.TENSE,Tense.PAST);
    born.addPostModifier("in");
View Full Code Here

   * Test NP coordination.
   */
  @Test
  public void testCoordination() {

    CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(this.dog,
        this.woman);
    // simple coordination
    Assert.assertEquals("the dog and the woman", this.realiser //$NON-NLS-1$
        .realise(cnp1).getRealisation());

    // simple coordination with complementation of entire coordinate NP
    cnp1.addComplement(this.behindTheCurtain);
    Assert.assertEquals("the dog and the woman behind the curtain", //$NON-NLS-1$
        this.realiser.realise(cnp1).getRealisation());

    // raise the specifier in this cnp
    // Assert.assertEquals(true, cnp1.raiseSpecifier()); // should return
View Full Code Here

    // simple coordination of complementised nps
    this.dog.clearComplements();
    this.woman.clearComplements();

    CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(this.dog,
        this.woman);
    cnp1.setFeature(Feature.RAISE_SPECIFIER, true);
    NLGElement realised = this.realiser.realise(cnp1);
    Assert.assertEquals("the dog and woman", realised.getRealisation());

    this.dog.addComplement(this.onTheRock);
    this.woman.addComplement(this.behindTheCurtain);

    CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(this.dog,
        this.woman);

    this.woman.setFeature(InternalFeature.RAISED, false);
    Assert.assertEquals(
        "the dog on the rock and the woman behind the curtain", //$NON-NLS-1$
        this.realiser.realise(cnp2).getRealisation());

    // complementised coordinates + outer pp modifier
    cnp2.addPostModifier(this.inTheRoom);
    Assert
        .assertEquals(
            "the dog on the rock and the woman behind the curtain in the room", //$NON-NLS-1$
            this.realiser.realise(cnp2).getRealisation());

    // set the specifier for this cnp; should unset specifiers for all inner
    // coordinates
    NLGElement every = this.phraseFactory.createWord(
        "every", LexicalCategory.DETERMINER); //$NON-NLS-1$

    cnp2.setFeature(InternalFeature.SPECIFIER, every);

    Assert
        .assertEquals(
            "every dog on the rock and every woman behind the curtain in the room", //$NON-NLS-1$
            this.realiser.realise(cnp2).getRealisation());

    // pronominalise one of the constituents
    this.dog.setFeature(Feature.PRONOMINAL, true); // ="it"
    this.dog.setFeature(InternalFeature.SPECIFIER, this.phraseFactory
        .createWord("the", LexicalCategory.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.assertEquals(
        "it and every woman behind the curtain in the room", //$NON-NLS-1$
        this.realiser.realise(cnp2).getRealisation());
View Full Code Here

   * Test possessives in coordinate NPs.
   */
  @Test
  public void testPossessiveCoordinate() {
    // simple coordination
    CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(this.dog,
        this.woman);
    Assert.assertEquals("the dog and the woman", this.realiser //$NON-NLS-1$
        .realise(cnp2).getRealisation());

    // set possessive -- wide-scope by default
    cnp2.setFeature(Feature.POSSESSIVE, true);
    Assert.assertEquals("the dog and the woman's", this.realiser.realise( //$NON-NLS-1$
        cnp2).getRealisation());

    // set possessive with pronoun
    this.dog.setFeature(Feature.PRONOMINAL, true);
    this.dog.setFeature(Feature.POSSESSIVE, true);
    cnp2.setFeature(Feature.POSSESSIVE, true);
    Assert.assertEquals("its and the woman's", this.realiser.realise(cnp2) //$NON-NLS-1$
        .getRealisation());

  }
View Full Code Here

  /**
   * Test pre and post-modification of coordinate VPs inside a sentence.
   */
  @Test
  public void testModifiedCoordVP() {
    CoordinatedPhraseElement coord = this.phraseFactory
        .createCoordinatedPhrase(this.getUp, this.fallDown);
    coord.setFeature(Feature.TENSE, Tense.PAST);
    Assert.assertEquals("got up and fell down", this.realiser
        .realise(coord).getRealisation());

    // add a premodifier
    coord.addPreModifier("slowly");
    Assert.assertEquals("slowly got up and fell down", this.realiser
        .realise(coord).getRealisation());

    // adda postmodifier
    coord.addPostModifier(this.behindTheCurtain);
    Assert.assertEquals("slowly got up and fell down behind the curtain",
        this.realiser.realise(coord).getRealisation());

    // put within the context of a sentence
    SPhraseSpec s = this.phraseFactory.createClause("Jake", coord);
View Full Code Here

        .createPrepositionPhrase("into", this.lexicon.getWord(
            "cardiogenic shock", LexicalCategory.NOUN));
    vp2.addComplement(pp);

    // coordinate
    CoordinatedPhraseElement coord = this.phraseFactory
        .createCoordinatedPhrase(vp1, vp2);
    coord.setFeature(Feature.TENSE, Tense.PAST);
    Assert
        .assertEquals(
            "had an adverse contrast media reaction and went into cardiogenic shock",
            this.realiser.realise(coord).getRealisation());
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.