Examples of PhraseElement


Examples of simplenlg.framework.PhraseElement

    this.phraseFactory.setLexicon(this.lexicon);

    NLGElement sandwich = phraseFactory.createNounPhrase(LexicalCategory.NOUN, "sandwich");
    sandwich.setPlural(true);
    //
    PhraseElement first = phraseFactory.createClause("I", "make", sandwich);
    first.setFeature(Feature.TENSE,Tense.PAST);
    first.setFeature(Feature.PROGRESSIVE,true);
    first.setPlural(false);
   
    PhraseElement second = phraseFactory.createClause("the mayonnaise", "run out");
    second.setFeature(Feature.TENSE,Tense.PAST);
    //
    second.setFeature(Feature.COMPLEMENTISER, "when");
   
    first.addComplement(second);
   
    DocumentElement sentence = docFactory.createSentence(first);
    NLGElement realised = realiser.realise(sentence);
View Full Code Here

Examples of simplenlg.framework.PhraseElement

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

Examples of simplenlg.framework.PhraseElement

    // passive with subject and indirect object
    SPhraseSpec _s2 = this.phraseFactory.createClause(null, "give", //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("the", "baby")); //$NON-NLS-1$ //$NON-NLS-2$

    PhraseElement morphine = this.phraseFactory
        .createNounPhrase("50ug of morphine"); //$NON-NLS-1$
    _s2.setIndirectObject(morphine);
    _s2.setFeature(Feature.PASSIVE, true);
    Assert.assertEquals("the baby is given 50ug of morphine", //$NON-NLS-1$
        this.realiser.realise(_s2).getRealisation());

    // passive with subject, complement and indirect object
    _s2 = this.phraseFactory.createClause(this.phraseFactory
        .createNounPhrase("the", "nurse"), "give", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        this.phraseFactory.createNounPhrase("the", "baby")); //$NON-NLS-1$ //$NON-NLS-2$

    morphine = this.phraseFactory.createNounPhrase("50ug of morphine"); //$NON-NLS-1$
    _s2.setIndirectObject(morphine);
    _s2.setFeature(Feature.PASSIVE, true);
    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);
    Assert.assertEquals(
        "yesterday George was chased by my dog and your cat", //$NON-NLS-1$
        this.realiser.realise(_s3).getRealisation());

    // test correct pronoun forms
    PhraseElement _s4 = this.phraseFactory.createClause(this.phraseFactory
        .createNounPhrase("he"), "chase", //$NON-NLS-1$ //$NON-NLS-2$
        this.phraseFactory.createNounPhrase("I")); //$NON-NLS-1$
    Assert.assertEquals("he chases me", this.realiser.realise(_s4) //$NON-NLS-1$
        .getRealisation());
    _s4 = this.phraseFactory
        .createClause(
            this.phraseFactory.createNounPhrase("he"), "chase", this.phraseFactory.createNounPhrase("me")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    _s4.setFeature(Feature.PASSIVE, true);
    Assert
        .assertEquals(
            "I am chased by him", this.realiser.realise(_s4).getRealisation()); //$NON-NLS-1$

    // same thing, but giving the S constructor "me". Should recognise
    // correct pro
    // anyway
    PhraseElement _s5 = this.phraseFactory
        .createClause("him", "chase", "I"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Assert.assertEquals(
        "he chases me", this.realiser.realise(_s5).getRealisation()); //$NON-NLS-1$

    _s5 = this.phraseFactory.createClause("him", "chase", "I"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    _s5.setFeature(Feature.PASSIVE, true);
    Assert
        .assertEquals(
            "I am chased by him", this.realiser.realise(_s5).getRealisation()); //$NON-NLS-1$
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

 
  /**
   * Test that complements set within the VP are raised when sentence is passivised.
   */
  public void testPassiveWithInternalVPComplement() {
    PhraseElement vp = this.phraseFactory.createVerbPhrase(phraseFactory.createWord(
        "upset", LexicalCategory.VERB));
    vp.addComplement(phraseFactory.createNounPhrase("the", "man"));
    PhraseElement _s6 = this.phraseFactory.createClause(phraseFactory.createNounPhrase(
        "the", "child"), vp);
    _s6.setFeature(Feature.TENSE, Tense.PAST);
    Assert.assertEquals("the child upset the man", this.realiser.realise(_s6).getRealisation());
   
    _s6.setFeature(Feature.PASSIVE, true);
    Assert.assertEquals("the man was upset by the child", this.realiser.realise(_s6).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

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

    this.s4.setSubject(subject);

    PhraseElement pick = this.phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$
    this.s4.setVerbPhrase(pick);
    this.s4.setObject("the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
    this.s4.setFeature(Feature.TENSE, Tense.FUTURE);
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  /**
   * Test did not
   */
  public void testDidNot() {
    PhraseElement s = phraseFactory.createClause("John", "eat");
    s.setFeature(Feature.TENSE, Tense.PAST);
    s.setFeature(Feature.NEGATED, true);

    Assert.assertEquals("John did not eat", //$NON-NLS-1$
        this.realiser.realise(s).getRealisation());

  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  /**
   * Test did not
   */
  public void testVPNegation() {
    // negate the VP
    PhraseElement vp = phraseFactory.createVerbPhrase("lie");
    vp.setFeature(Feature.TENSE, Tense.PAST);
    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);

View Full Code Here

Examples of simplenlg.framework.PhraseElement

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

    this.s4.setFeature(InternalFeature.SUBJECTS, subject);

    PhraseElement pick = this.phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$
    this.s4.setFeature(InternalFeature.VERB_PHRASE, pick);
    this.s4.setObject("the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
    this.s4.setFeature(Feature.TENSE, Tense.FUTURE);
    this.s4.setFeature(Feature.FORM, Form.INFINITIVE);
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    // compose this with a new sentence
    // ER - switched direct and indirect object in sentence
    SPhraseSpec temp2 = this.phraseFactory.createClause("I", "tell", temp); //$NON-NLS-1$ //$NON-NLS-2$
    temp2.setFeature(Feature.TENSE, Tense.FUTURE);

    PhraseElement indirectObject = this.phraseFactory
        .createNounPhrase("John"); //$NON-NLS-1$

    temp2.setIndirectObject(indirectObject);

    Assert.assertEquals("I will tell John that however tomorrow Jane and " + //$NON-NLS-1$
        "Andrew's picking up the balls in the shop is " + //$NON-NLS-1$
        "recommended", //$NON-NLS-1$
        this.realiser.realise(temp2).getRealisation());

    // turn s4 to imperative and put it in indirect object position

    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);

    PhraseElement pick = this.phraseFactory.createVerbPhrase("pick up"); //$NON-NLS-1$
    this.s4.setVerbPhrase(pick);
    this.s4.setObject("the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
    this.s4.setFeature(Feature.TENSE, Tense.FUTURE);
    this.s4.setFeature(Feature.FORM, Form.IMPERATIVE);
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    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);
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.