Package simplenlg.phrasespec

Examples of simplenlg.phrasespec.SPhraseSpec


  /**
   * Test for questions with "be" in future tense
   */
  @Test
  public void testBeQuestionsFuture() {
    SPhraseSpec p = this.phraseFactory.createClause(this.phraseFactory
        .createNounPhrase("a", "ball"), this.phraseFactory.createWord(
        "be", LexicalCategory.VERB), this.phraseFactory
        .createNounPhrase("a", "toy"));
    p.setFeature(Feature.TENSE, Tense.FUTURE);

    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHAT_OBJECT);
    Assert.assertEquals("what will a ball be", this.realiser.realise(p)
        .getRealisation());

    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
    Assert.assertEquals("will a ball be a toy", this.realiser.realise(p)
        .getRealisation());

    p
        .setFeature(Feature.INTERROGATIVE_TYPE,
            InterrogativeType.WHAT_SUBJECT);
    Assert.assertEquals("what will be a toy", this.realiser.realise(p)
        .getRealisation());

    SPhraseSpec p2 = this.phraseFactory.createClause("Mary", "be",
        "beautiful");
    p2.setFeature(Feature.TENSE, Tense.FUTURE);
    p2.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHY);
    Assert.assertEquals("why will Mary be beautiful", this.realiser
        .realise(p2).getRealisation());

    p2
        .setFeature(Feature.INTERROGATIVE_TYPE,
            InterrogativeType.WHO_SUBJECT);
    Assert.assertEquals("who will be beautiful", this.realiser.realise(p2)
        .getRealisation());
  }
View Full Code Here


    pp1.addComplement("Paul"); //$NON-NLS-1$
    s1.addPostModifier(pp1);

    Assert.assertEquals("Marie is associated with Peter and Paul", //$NON-NLS-1$
        this.realiser.realise(s1).getRealisation());
    SPhraseSpec s2 = this.phraseFactory.createClause();
    s2.setSubject(this.phraseFactory
        .createNounPhrase("Peter")); //$NON-NLS-1$
    s2.setVerb("have"); //$NON-NLS-1$
    s2.setObject("something to do"); //$NON-NLS-1$
    s2.addPostModifier(this.phraseFactory.createPrepositionPhrase(
        "with", "Paul")); //$NON-NLS-1$ //$NON-NLS-2$


    Assert.assertEquals("Peter has something to do with Paul", //$NON-NLS-1$
        this.realiser.realise(s2).getRealisation());
View Full Code Here

    Assert.assertEquals("Mary chases George in the park", this.realiser //$NON-NLS-1$
        .realise(p).getRealisation());

    // another question from Nicole
    SPhraseSpec run = this.phraseFactory.createClause(
        "you", "go", "running"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    run.setFeature(Feature.MODAL, "should"); //$NON-NLS-1$
    run.addPreModifier("really"); //$NON-NLS-1$
    SPhraseSpec think = this.phraseFactory.createClause("I", "think"); //$NON-NLS-1$ //$NON-NLS-2$
    think.setObject(run);
    run.setFeature(Feature.SUPRESSED_COMPLEMENTISER, true);

    String text = this.realiser.realise(think).getRealisation();
    Assert.assertEquals("I think you should really go running", text); //$NON-NLS-1$
  }
View Full Code Here

        PhraseElement prepPhrase = phraseFactory.createPrepositionPhrase("from");
        prepPhrase.addComplement("home");

        verbElement.addComplement(prepPhrase);
        SPhraseSpec newSentence = phraseFactory.createClause();
        newSentence.setSubject(subjectElement);
        newSentence.setVerbPhrase(verbElement);

    Assert.assertEquals("I run from home", this.realiser.realise(newSentence) //$NON-NLS-1$
        .getRealisation());

  }
View Full Code Here

  }

  @Test
  public void testKerber() {
    // Frederic Kerber's tests
        SPhraseSpec sp =  phraseFactory.createClause("he", "need");
        SPhraseSpec secondSp = phraseFactory.createClause();
        secondSp.setVerb("build");
        secondSp.setObject("a house");
        secondSp.setFeature(Feature.FORM,Form.INFINITIVE);
        sp.setObject("stone");
        sp.addComplement(secondSp);
        Assert.assertEquals("he needs stone to build a house", this.realiser.realise(sp).getRealisation());
      
        SPhraseSpec sp2 =  phraseFactory.createClause("he", "give");
        sp2.setIndirectObject("I");
        sp2.setObject("the book");
        Assert.assertEquals("he gives me the book", this.realiser.realise(sp2).getRealisation());

  }
View Full Code Here

  }
 
  @Test
  public void testStephenson() {
    // Bruce Stephenson's test
    SPhraseSpec qs2 = this.phraseFactory.createClause();
    qs2 = this.phraseFactory.createClause();
    qs2.setSubject("moles of Gold");
    qs2.setVerb("are");
    qs2.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    qs2.setFeature(Feature.PASSIVE, false);
    qs2.setFeature(Feature.INTERROGATIVE_TYPE,InterrogativeType.HOW_MANY);
    qs2.setObject("in a 2.50 g sample of pure Gold");
    DocumentElement sentence = this.phraseFactory.createSentence(qs2);
    Assert.assertEquals("How many moles of Gold are in a 2.50 g sample of pure Gold?", this.realiser.realise(sentence).getRealisation());
  }
View Full Code Here

  }
 
  @Test
  public void testPierre() {
    // John Pierre's test
    SPhraseSpec p = this.phraseFactory.createClause("Mary", "chase", "George");
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHAT_OBJECT);
    Assert.assertEquals("What does Mary chase?", realiser.realiseSentence(p));

    p = this.phraseFactory.createClause("Mary", "chase", "George");
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
    Assert.assertEquals("Does Mary chase George?", realiser.realiseSentence(p));

    p = this.phraseFactory.createClause("Mary", "chase", "George");
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHERE);
    Assert.assertEquals("Where does Mary chase George?", realiser.realiseSentence(p));

    p = this.phraseFactory.createClause("Mary", "chase", "George");
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHY);
    Assert.assertEquals("Why does Mary chase George?", realiser.realiseSentence(p));

    p = this.phraseFactory.createClause("Mary", "chase", "George");
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.HOW);
    Assert.assertEquals("How does Mary chase George?", realiser.realiseSentence(p));


  }
View Full Code Here

 
  @Test
  public void testData2Text() {
    // Data2Text tests
    // test OK to have number at end of sentence
    SPhraseSpec p = this.phraseFactory.createClause("the dog", "weigh", "12");
    Assert.assertEquals("The dog weighes 12.", realiser.realiseSentence(p));
   
    // test OK to have "there be" sentence with "there" as a StringElement
    NLGElement dataDropout2 = this.phraseFactory.createNLGElement("data dropouts");
    dataDropout2.setPlural(true);
    SPhraseSpec sentence2 = this.phraseFactory.createClause();
    sentence2.setSubject(this.phraseFactory.createStringElement("there"));
    sentence2.setVerb("be");
    sentence2.setObject(dataDropout2);
    Assert.assertEquals("There are data dropouts.", realiser.realiseSentence(sentence2));
   
    // test OK to have gerund form verb
    SPhraseSpec weather1 = this.phraseFactory.createClause("SE 10-15", "veer", "S 15-20");
    weather1.setFeature(Feature.FORM, Form.GERUND);
    Assert.assertEquals("SE 10-15 veering S 15-20.", realiser.realiseSentence(weather1));   

    // test OK to have subject only
    SPhraseSpec weather2 = this.phraseFactory.createClause("cloudy and misty", "be", "XXX");
    weather2.getVerbPhrase().setFeature(Feature.ELIDED, true);
    Assert.assertEquals("Cloudy and misty.", realiser.realiseSentence(weather2));
   
    // test OK to have VP only
    SPhraseSpec weather3 = this.phraseFactory.createClause("S 15-20", "increase", "20-25");
    weather3.setFeature(Feature.FORM, Form.GERUND);
    weather3.getSubject().setFeature(Feature.ELIDED, true);
    Assert.assertEquals("Increasing 20-25.", realiser.realiseSentence(weather3));   
   
    // conjoined test
    SPhraseSpec weather4 = this.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.setConjunction("then");
    Assert.assertEquals("SE 10-15 veering S 15-20, increasing 20-25 then backing SSE.", realiser.realiseSentence(coord));   
   

    // no verb
    SPhraseSpec weather5 = this.phraseFactory.createClause("rain", null, "likely");
    Assert.assertEquals("Rain likely.", realiser.realiseSentence(weather5));

  }
View Full Code Here

    List<String> ret=this.realizeAll(results);
    Assert.assertEquals("[John Lennon and you agreed with it, Geri Halliwell disagreed with it, Melanie B and Emma Bunton commented on it]", ret.toString());
  }
 
  private NLGElement commentPhrase(String name){  // used by testRafael
    SPhraseSpec s = phraseFactory.createClause();
    s.setSubject(phraseFactory.createNounPhrase(name));
    s.setVerbPhrase(phraseFactory.createVerbPhrase("comment on"));
    s.setObject("it");
    s.setFeature(Feature.TENSE, Tense.PAST);
    return s;
  }
View Full Code Here

    s.setFeature(Feature.TENSE, Tense.PAST);
    return s;
  }

  private NLGElement agreePhrase(String name){  // used by testRafael
    SPhraseSpec s = phraseFactory.createClause();
    s.setSubject(phraseFactory.createNounPhrase(name));
    s.setVerbPhrase(phraseFactory.createVerbPhrase("agree with"));
    s.setObject("it");
    s.setFeature(Feature.TENSE, Tense.PAST);
    return s;
  }
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.