Examples of NPPhraseSpec


Examples of simplenlg.phrasespec.NPPhraseSpec

   * Test change from "a" to "an" in the presence of a premodifier with a vowel
   */
  public void testIndefiniteWithPremodifier() {
    SPhraseSpec s = this.phraseFactory.createClause("there", "be");
    s.setFeature(Feature.TENSE, Tense.PRESENT);
    NPPhraseSpec np = this.phraseFactory.createNounPhrase("a", "stenosis");
    s.setObject(np);
   
    //check without modifiers -- article should be "a"
    Assert.assertEquals("there is a stenosis", this.realiser.realise(s).getRealisation());
   
    //add a single modifier -- should turn article to "an"
    np.addPreModifier(this.phraseFactory.createAdjectivePhrase("eccentric"));
    Assert.assertEquals("there is an eccentric stenosis", this.realiser.realise(s).getRealisation());
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

 
  /**
   * Test for comma separation between premodifers
   */
  public void testMultipleAdjPremodifiers() {
    NPPhraseSpec np = this.phraseFactory.createNounPhrase("a", "stenosis");
    np.addPreModifier(this.phraseFactory.createAdjectivePhrase("eccentric"));
    np.addPreModifier(this.phraseFactory.createAdjectivePhrase("discrete"));
    Assert.assertEquals("an eccentric, discrete stenosis", this.realiser.realise(np).getRealisation());       
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   
    String verb = "associate";
    VPPhraseSpec adjP = this.phraseFactory.createVerbPhrase(verb);
    adjP.setFeature(Feature.TENSE, Tense.PAST);
   
    NPPhraseSpec np = this.phraseFactory.createNounPhrase("a", "thrombus");
    np.addPreModifier(adjP);
    String realised = this.realiser.realise(np).getRealisation();
    System.out.println(realised);
    // cch TESTING The following line doesn't work when the lexeme is a
    // verb.
    // morphP.preMod.Add(new AdjPhraseSpec((Lexeme)modifier));
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   * Test the pronominalisation method for full NPs (more thorough than above)
   */
  @Test
  public void testPronominalisation2() {
    // Ehud - added extra pronominalisation tests
    NPPhraseSpec pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.FIRST);
    SPhraseSpec sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "I like John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.SECOND);
    sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "You like John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.THIRD);
    pro.setFeature(LexicalFeature.GENDER, Gender.FEMININE);
    sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "She likes John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.FIRST);
    pro.setPlural(true);
    sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "We like John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.SECOND);
    pro.setPlural(true);
    sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "You like John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("Mary");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.THIRD);
    pro.setPlural(true);
    pro.setFeature(LexicalFeature.GENDER, Gender.FEMININE);
    sent = phraseFactory.createClause(pro,"like", "John");
    Assert.assertEquals(
        "They like John.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.FIRST);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes me.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.SECOND);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes you.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.THIRD);
    pro.setFeature(LexicalFeature.GENDER, Gender.MASCULINE);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes him.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.FIRST);
    pro.setPlural(true);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes us.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.SECOND);
    pro.setPlural(true);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes you.", this.realiser.realiseSentence(sent));
   
    pro = phraseFactory.createNounPhrase("John");
    pro.setFeature(Feature.PRONOMINAL, true);
    pro.setFeature(Feature.PERSON, Person.THIRD);
    pro.setFeature(LexicalFeature.GENDER, Gender.MASCULINE);
    pro.setPlural(true);
    sent = phraseFactory.createClause("Mary", "like", pro);
    Assert.assertEquals(
        "Mary likes them.", this.realiser.realiseSentence(sent));
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

 
  /**
   * Further tests for a/an agreement with coordinated premodifiers
   */
  public void testAAnCoord() {
    NPPhraseSpec _dog = this.phraseFactory.createNounPhrase("a", "dog");
    _dog.addPreModifier(this.phraseFactory.createCoordinatedPhrase("enormous", "black"));
    String realisation = this.realiser.realise(_dog).getRealisation();
    Assert.assertEquals("an enormous and black dog", realisation);
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

 
  /**
   * Test for a/an agreement with numbers
   */
  public void testAAnWithNumbers() {
    NPPhraseSpec num = this.phraseFactory.createNounPhrase("a", "change");
    String realisation;
   
    //no an with "one"
    num.setPreModifier("one percent");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("a one percent change", realisation);
   
    //an with "eighty"
    num.setPreModifier("eighty percent");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an eighty percent change", realisation);
   
   
    //an with 80
    num.setPreModifier("80%");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 80% change", realisation);
   
    //an with 80000
    num.setPreModifier("80000");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 80000 change", realisation);
   
    //an with 11,000
    num.setPreModifier("11,000");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 11,000 change", realisation);
   
    //an with 18
    num.setPreModifier("18%");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 18% change", realisation);
   
    //a with 180
    num.setPreModifier("180");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("a 180 change", realisation);
   
    //a with 1100
    num.setPreModifier("1100");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("a 1100 change", realisation);     
   
    //a with 180,000
    num.setPreModifier("180,000");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("a 180,000 change", realisation);
   
    //an with 11000
    num.setPreModifier("11000");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 11000 change", realisation);

   
    //an with 18000
    num.setPreModifier("18000");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 18000 change", realisation);
   
    //an with 18.1
    num.setPreModifier("18.1%");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 18.1% change", realisation);
   
    //an with 11.1
    num.setPreModifier("11.1%");
    realisation = this.realiser.realise(num).getRealisation();
    Assert.assertEquals("an 11.1% change", realisation);

  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   * Ensure that no extra whitespace is inserted into a realisation if a
   * constituent is empty. (This is to check for a bug fix for addition of
   * spurious whitespace).
   */
  public void testExtraWhitespace() {
    NPPhraseSpec np1 = this.phraseFactory.createNounPhrase("a", "vessel");

    // empty coordinate as premod
    np1.setPreModifier(this.phraseFactory.createCoordinatedPhrase());
    Assert.assertEquals("a vessel", this.realiser.realise(np1)
        .getRealisation());
   
    // empty adjP as premod
    np1.setPreModifier(this.phraseFactory.createAdjectivePhrase());
    Assert.assertEquals("a vessel", this.realiser.realise(np1)
        .getRealisation());
   
    // empty string
    np1.setPreModifier("");
    Assert.assertEquals("a vessel", this.realiser.realise(np1)
        .getRealisation());
   
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

    // the man gives the woman John's flower
    this.s3 = this.phraseFactory.createClause();
    this.s3.setSubject(this.man);
    this.s3.setVerbPhrase(this.give);

    NPPhraseSpec flower = this.phraseFactory.createNounPhrase("flower"); //$NON-NLS-1$
    NPPhraseSpec john = this.phraseFactory.createNounPhrase("John"); //$NON-NLS-1$
    john.setFeature(Feature.POSSESSIVE, true);
    flower.setFeature(InternalFeature.SPECIFIER, john);
    this.s3.setObject(flower);
    this.s3.setIndirectObject(this.woman);

    this.s4 = this.phraseFactory.createClause();
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

    PhraseElement _man = this.phraseFactory.createNounPhrase("the", "man"); //$NON-NLS-1$ //$NON-NLS-2$
    this.s3 = this.phraseFactory.createClause();
    this.s3.setSubject(_man);
    this.s3.setVerb("give");

    NPPhraseSpec flower = this.phraseFactory.createNounPhrase("flower"); //$NON-NLS-1$
    NPPhraseSpec john = this.phraseFactory.createNounPhrase("John"); //$NON-NLS-1$
    john.setFeature(Feature.POSSESSIVE, true);
    flower.setSpecifier(john);
    this.s3.setObject(flower);

    PhraseElement _woman = this.phraseFactory.createNounPhrase(
        "the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   */
  @Test
  public void testAgreement() {

    // basic agreement
    NPPhraseSpec np = this.phraseFactory.createNounPhrase("dog"); //$NON-NLS-1$
    np.setSpecifier("the"); //$NON-NLS-1$
    np.addPreModifier("angry"); //$NON-NLS-1$
    PhraseElement _s1 = this.phraseFactory
        .createClause(np, "chase", "John"); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("the angry dog chases John", this.realiser //$NON-NLS-1$
        .realise(_s1).getRealisation());

    // plural
    np = this.phraseFactory.createNounPhrase("dog"); //$NON-NLS-1$
    np.setSpecifier("the"); //$NON-NLS-1$
    np.addPreModifier("angry"); //$NON-NLS-1$
    np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    _s1 = this.phraseFactory.createClause(np, "chase", "John"); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("the angry dogs chase John", this.realiser //$NON-NLS-1$
        .realise(_s1).getRealisation());

    // test agreement with "there is"
    np = this.phraseFactory.createNounPhrase("dog"); //$NON-NLS-1$
    np.addPreModifier("angry"); //$NON-NLS-1$
    np.setFeature(Feature.NUMBER, NumberAgreement.SINGULAR);
    np.setSpecifier("a"); //$NON-NLS-1$
    PhraseElement _s2 = this.phraseFactory.createClause("there", "be", np); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("there is an angry dog", this.realiser //$NON-NLS-1$
        .realise(_s2).getRealisation());

    // plural with "there"
    np = this.phraseFactory.createNounPhrase("dog"); //$NON-NLS-1$
    np.addPreModifier("angry"); //$NON-NLS-1$
    np.setSpecifier("a"); //$NON-NLS-1$
    np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    _s2 = this.phraseFactory.createClause("there", "be", np); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("there are some angry dogs", this.realiser //$NON-NLS-1$
        .realise(_s2).getRealisation());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.