Examples of PhraseElement


Examples of simplenlg.framework.PhraseElement

   * Returns the direct object of a clause (assumes there is only one)
   *
   * @return subject of clause (assume only one)
   */
  public NLGElement getObject() {
    PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
    if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
      return ((VPPhraseSpec) verbPhrase).getObject();
    else
      // return null if VP is coordinated phrase
      return null;
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   * Returns the indirect object of a clause (assumes there is only one)
   *
   * @return subject of clause (assume only one)
   */
  public NLGElement getIndirectObject() {
    PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
    if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
      return ((VPPhraseSpec) verbPhrase).getIndirectObject();
    else
      // return null if VP is coordinated phrase
      return null;
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  /** Sets the  object of a PP
   *
   * @param object
   */
  public void setObject(Object object) {
    PhraseElement objectPhrase = getFactory().createNounPhrase(object);
    objectPhrase.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT);
    addComplement(objectPhrase);
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    // this.s2.setHead("be");
    // this.s2.setComplement(this.dog);
    // this.s2.addModifier(SModifierPosition.POST_VERB, this.onTheRock);
    //
    // // the man gives the woman John's flower
    PhraseElement john = this.phraseFactory.createNounPhrase("John"); //$NON-NLS-1$
    john.setFeature(Feature.POSSESSIVE, true);
    PhraseElement flower = this.phraseFactory.createNounPhrase(john,
        "flower"); //$NON-NLS-1$
    PhraseElement _woman = this.phraseFactory.createNounPhrase(
        "the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$
    this.s3 = this.phraseFactory.createClause(this.man, this.give, flower);
    this.s3.setIndirectObject(_woman);

    CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    Assert.assertEquals("has there been the dog on the rock", //$NON-NLS-1$
        this.realiser.realise(this.s2).getRealisation());

    // progressive
    // sentence: "the man was giving the woman John's flower"
    PhraseElement john = this.phraseFactory.createNounPhrase("John"); //$NON-NLS-1$
    john.setFeature(Feature.POSSESSIVE, true);
    PhraseElement flower = this.phraseFactory.createNounPhrase(john,
        "flower"); //$NON-NLS-1$
    PhraseElement _woman = this.phraseFactory.createNounPhrase(
        "the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$
    this.s3 = this.phraseFactory.createClause(this.man, this.give, flower);
    this.s3.setIndirectObject(_woman);
    this.s3.setFeature(Feature.TENSE, Tense.PAST);
    this.s3.setFeature(Feature.PROGRESSIVE, true);
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testSimpleQuestions2() {
    setUp();
    this.realiser.setLexicon(this.lexicon);
    PhraseElement s = this.phraseFactory.createClause("the woman", "kiss", //$NON-NLS-1$ //$NON-NLS-2$
        "the man"); //$NON-NLS-1$

    // try with the simple yes/no type first
    s.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
    Assert.assertEquals("does the woman kiss the man", this.realiser //$NON-NLS-1$
        .realise(s).getRealisation());

    // now in the passive
    s = this.phraseFactory.createClause("the woman", "kiss", //$NON-NLS-1$ //$NON-NLS-2$
        "the man"); //$NON-NLS-1$
    s.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
    s.setFeature(Feature.PASSIVE, true);
    Assert.assertEquals("is the man kissed by the woman", this.realiser //$NON-NLS-1$
        .realise(s).getRealisation());

    // // subject interrogative with simple present
    // // sentence: "the woman kisses the man"
    s = this.phraseFactory.createClause("the woman", "kiss", //$NON-NLS-1$ //$NON-NLS-2$
        "the man"); //$NON-NLS-1$
    s.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHO_SUBJECT);

    Assert.assertEquals("who kisses the man", this.realiser.realise(s) //$NON-NLS-1$
        .getRealisation());

    // object interrogative with simple present
    s = this.phraseFactory.createClause("the woman", "kiss", //$NON-NLS-1$ //$NON-NLS-2$
        "the man"); //$NON-NLS-1$
    s.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHO_OBJECT);
    Assert.assertEquals("who does the woman kiss", this.realiser //$NON-NLS-1$
        .realise(s).getRealisation());

    // subject interrogative with passive
    s = this.phraseFactory.createClause("the woman", "kiss", //$NON-NLS-1$ //$NON-NLS-2$
        "the man"); //$NON-NLS-1$
    s.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHO_SUBJECT);
    s.setFeature(Feature.PASSIVE, true);
    Assert.assertEquals("who is the man kissed by", this.realiser //$NON-NLS-1$
        .realise(s).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  @Test
  public void testTutorialQuestions() {
    setUp();
    this.realiser.setLexicon(this.lexicon);

    PhraseElement p = this.phraseFactory.createClause("Mary", "chase", //$NON-NLS-1$ //$NON-NLS-2$
        "George"); //$NON-NLS-1$
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.YES_NO);
    Assert.assertEquals("does Mary chase George", this.realiser.realise(p) //$NON-NLS-1$
        .getRealisation());

    p = this.phraseFactory.createClause("Mary", "chase", //$NON-NLS-1$ //$NON-NLS-2$
        "George"); //$NON-NLS-1$
    p.setFeature(Feature.INTERROGATIVE_TYPE, InterrogativeType.WHO_OBJECT);
    Assert.assertEquals("who does Mary chase", this.realiser.realise(p) //$NON-NLS-1$
        .getRealisation());

  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testForcher() {
    // Bjorn Forcher's tests
    this.phraseFactory.setLexicon(this.lexicon);
    PhraseElement s1 = this.phraseFactory.createClause(null, "associate",
        "Marie");
    s1.setFeature(Feature.PASSIVE, true);
    PhraseElement pp1 = this.phraseFactory.createPrepositionPhrase("with"); //$NON-NLS-1$
    pp1.addComplement("Peter"); //$NON-NLS-1$
    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();
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  @Test
  public void testLu() {
    // Xin Lu's test
    this.phraseFactory.setLexicon(this.lexicon);
    PhraseElement s1 = this.phraseFactory.createClause("we", //$NON-NLS-1$
        "consider", //$NON-NLS-1$
        "John"); //$NON-NLS-1$
    s1.addPostModifier("a friend"); //$NON-NLS-1$

    Assert.assertEquals("we consider John a friend", this.realiser //$NON-NLS-1$
        .realise(s1).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    NPPhraseSpec noun4 = this.phraseFactory
        .createNounPhrase("FGFR3 gene in every cell"); //$NON-NLS-1$

    noun4.setSpecifier("the");

    PhraseElement prep1 = this.phraseFactory.createPrepositionPhrase(
        "of", noun4); //$NON-NLS-1$

    PhraseElement noun1 = this.phraseFactory.createNounPhrase(
        "the", "patient's mother"); //$NON-NLS-1$ //$NON-NLS-2$

    PhraseElement noun2 = this.phraseFactory.createNounPhrase(
        "the", "patient's father"); //$NON-NLS-1$ //$NON-NLS-2$

    PhraseElement noun3 = this.phraseFactory
        .createNounPhrase("changed copy"); //$NON-NLS-1$
    noun3.addPreModifier("one"); //$NON-NLS-1$
    noun3.addComplement(prep1);

    CoordinatedPhraseElement coordNoun1 = new CoordinatedPhraseElement(
        noun1, noun2);
    coordNoun1.setConjunction( "or"); //$NON-NLS-1$

    PhraseElement verbPhrase1 = this.phraseFactory.createVerbPhrase("have"); //$NON-NLS-1$
    verbPhrase1.setFeature(Feature.TENSE,Tense.PRESENT);

    PhraseElement sentence1 = this.phraseFactory.createClause(coordNoun1,
        verbPhrase1, noun3);

    realiser.setDebugMode(true);
    Assert
        .assertEquals(
            "the patient's mother or the patient's father has one changed copy of the FGFR3 gene in every cell", //$NON-NLS-1$
            this.realiser.realise(sentence1).getRealisation());

    // Rachel's second test
    noun3 = this.phraseFactory.createNounPhrase("a", "gene test"); //$NON-NLS-1$ //$NON-NLS-2$
    noun2 = this.phraseFactory.createNounPhrase("an", "LDL test"); //$NON-NLS-1$ //$NON-NLS-2$
    noun1 = this.phraseFactory.createNounPhrase("the", "clinic"); //$NON-NLS-1$ //$NON-NLS-2$
    verbPhrase1 = this.phraseFactory.createVerbPhrase("perform"); //$NON-NLS-1$

    CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(noun2,
        noun3);
    sentence1 = this.phraseFactory.createClause(noun1, verbPhrase1, coord1);
    sentence1.setFeature(Feature.TENSE,Tense.PAST);

    Assert
        .assertEquals(
            "the clinic performed an LDL test and a gene test", this.realiser //$NON-NLS-1$
                .realise(sentence1).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.