Package simplenlg.phrasespec

Examples of simplenlg.phrasespec.SPhraseSpec


  /**
   * Check that empty phrases are not realised as "null"
   */
  public void testEmptyPhraseRealisation() {
    SPhraseSpec emptyClause = this.phraseFactory.createClause();
    Assert.assertEquals("", this.realiser.realise(emptyClause).getRealisation());
  }
View Full Code Here


 
  /**
   * 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"
View Full Code Here

 
  /**
   * Check that setComplement replaces earlier complements
   */
  public void testSetComplement() {
    SPhraseSpec s = this.phraseFactory.createClause();
    s.setSubject("I");
    s.setVerb("see");
    s.setObject("a dog");
   
    Assert.assertEquals("I see a dog", this.realiser.realise(s).getRealisation());
   
    s.setObject("a cat");
    Assert.assertEquals("I see a cat", this.realiser.realise(s).getRealisation());
   
    s.setObject("a wolf");
    Assert.assertEquals("I see a wolf", this.realiser.realise(s).getRealisation());

  }
View Full Code Here

  /**
   * Test for elision of specific words rather than phrases
   */
  public void testWordElision() {
    this.realiser.setDebugMode(true);
    SPhraseSpec s1 = this.phraseFactory.createClause();
    s1.setSubject(this.np4); //the rock
    this.kiss.setComplement(this.np5);//kiss the curtain
    s1.setVerbPhrase(this.kiss);
   
    this.kiss.getHead().setFeature(Feature.ELIDED, true);
    Assert.assertEquals("the rock kisses", this.realiser.realise(s1).getRealisation());
  }
View Full Code Here

   * phrase directly.
   */
  @Test
  public void testCoordinateVPComplexSubject() {
    // "As a result of the procedure the patient had an adverse contrast media reaction and went into cardiogenic shock."
    SPhraseSpec s = this.phraseFactory.createClause();

    s.setSubject(this.phraseFactory.createNounPhrase("the", "patient"));

    // first VP
    VPPhraseSpec vp1 = this.phraseFactory.createVerbPhrase(this.lexicon
        .getWord("have", LexicalCategory.VERB));
    NPPhraseSpec np1 = this.phraseFactory.createNounPhrase("a",
        this.lexicon.getWord("contrast media reaction",
            LexicalCategory.NOUN));
    np1.addPreModifier(this.lexicon.getWord("adverse",
        LexicalCategory.ADJECTIVE));
    vp1.addComplement(np1);

    // second VP
    VPPhraseSpec vp2 = this.phraseFactory.createVerbPhrase(this.lexicon
        .getWord("go", LexicalCategory.VERB));
    PPPhraseSpec pp = this.phraseFactory
        .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());

    // now put this in the sentence
    s.setVerbPhrase(coord);
    s.addFrontModifier("As a result of the procedure");
    Assert
        .assertEquals(
            "As a result of the procedure the patient had an adverse contrast media reaction and went into cardiogenic shock",
            this.realiser.realise(s).getRealisation());

View Full Code Here

  /**
   * 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, "");
View Full Code Here

  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);
View Full Code Here

   */
  @Test
  public void testSPhraseSpec() {
   
    // simple test of methods
    SPhraseSpec c1 = (SPhraseSpec) phraseFactory.createClause();
    c1.setVerb("give");
    c1.setSubject("John");
    c1.setObject("an apple");
    c1.setIndirectObject("Mary");
    c1.setFeature(Feature.TENSE, Tense.PAST);
    c1.setFeature(Feature.NEGATED, true);
   
    // check getXXX methods
    Assert.assertEquals("give",  getBaseForm(c1.getVerb()));
    Assert.assertEquals("John", getBaseForm(c1.getSubject()));
    Assert.assertEquals("an apple", getBaseForm(c1.getObject()));
    Assert.assertEquals("Mary", getBaseForm(c1.getIndirectObject()));
   
    Assert.assertEquals("John did not give Mary an apple", this.realiser //$NON-NLS-1$
        .realise(c1).getRealisation());
   

   
    // test modifier placement
    SPhraseSpec c2 = (SPhraseSpec) phraseFactory.createClause();
    c2.setVerb("see");
    c2.setSubject("the man");
    c2.setObject("me");
    c2.addModifier("fortunately");
    c2.addModifier("quickly");
    c2.addModifier("in the park");
    // try setting tense directly as a feature
    c2.setFeature(Feature.TENSE, Tense.PAST);
    Assert.assertEquals("fortunately the man quickly saw me in the park", this.realiser //$NON-NLS-1$
        .realise(c2).getRealisation());
  }
View Full Code Here

    inner.setFeature(Feature.COMPLEMENTISER, "where");
   
    PhraseElement house = phraseFactory.createNounPhrase("the", "house");
    house.addComplement(inner);
   
    SPhraseSpec outer = phraseFactory.createClause(null, "abandon", house);
   
    outer.addPostModifier("since 1986");
   
    outer.setFeature(Feature.PASSIVE, true);
    outer.setFeature(Feature.PERFECT, true);
   
    DocumentElement sentence = docFactory.createSentence(outer);
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());
View Full Code Here

    vp.setFeature(Feature.NEGATED, true);
    PhraseElement compl = phraseFactory.createVerbPhrase("etherize");
    compl.setFeature(Feature.TENSE, Tense.PAST);
    vp.setComplement(compl);

    SPhraseSpec s = phraseFactory.createClause(phraseFactory
        .createNounPhrase("the", "patient"), vp);

    Assert.assertEquals("the patient did not lie etherized", //$NON-NLS-1$
        this.realiser.realise(s).getRealisation());
View Full Code Here

TOP

Related Classes of simplenlg.phrasespec.SPhraseSpec

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.