Examples of CoordinatedPhraseElement


Examples of simplenlg.framework.CoordinatedPhraseElement

            this.realiser.realise(this.give).getRealisation());

    // reset the arguments
    this.give.clearComplements();
    this.give.addComplement(this.dog);
    CoordinatedPhraseElement womanBoy = new CoordinatedPhraseElement(
        this.woman, this.boy);
    womanBoy.setFeature(InternalFeature.DISCOURSE_FUNCTION,
        DiscourseFunction.INDIRECT_OBJECT);
    this.give.addComplement(womanBoy);

    // if we unset the passive, we should get the indirect objects
    // they won't be coordinated
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    s.setSubject(this.phraseFactory
        .createNounPhrase("John")); //$NON-NLS-1$

    // Create a sentence first
    CoordinatedPhraseElement maryAndSusan = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Mary"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Susan")); //$NON-NLS-1$

    this.kiss.clearComplements();
    s.setVerbPhrase(this.kiss);
    s.setObject(maryAndSusan);
    s.setFeature(Feature.PROGRESSIVE, true);
    s.setFeature(Feature.TENSE,Tense.PAST);
    s.addPostModifier(this.inTheRoom);
    Assert.assertEquals("John was kissing Mary and Susan in the room", //$NON-NLS-1$
        this.realiser.realise(s).getRealisation());

    // make the main VP past
    this.say.setFeature(Feature.TENSE,Tense.PAST);
    Assert.assertEquals("said", this.realiser.realise(this.say) //$NON-NLS-1$
        .getRealisation());

    // now add the sentence as complement of "say". Should make the sentence
    // subordinate
    // note that sentential punctuation is suppressed
    this.say.addComplement(s);
    Assert.assertEquals(
        "said that John was kissing Mary and Susan in the room", //$NON-NLS-1$
        this.realiser.realise(this.say).getRealisation());

    // add a postModifier to the main VP
    // yields [says [that John was kissing Mary and Susan in the room]
    // [behind the curtain]]
    this.say.addPostModifier(this.behindTheCurtain);
    Assert
        .assertEquals(
            "said that John was kissing Mary and Susan in the room behind the curtain", //$NON-NLS-1$
            this.realiser.realise(this.say).getRealisation());

    // create a new sentential complement
    PhraseElement s2 = this.phraseFactory.createClause(this.phraseFactory
        .createNounPhrase("all"), //$NON-NLS-1$
        "be", //$NON-NLS-1$
        this.phraseFactory.createAdjectivePhrase("fine")); //$NON-NLS-1$

    s2.setFeature(Feature.TENSE,Tense.FUTURE);
    Assert.assertEquals("all will be fine", this.realiser.realise(s2) //$NON-NLS-1$
        .getRealisation());

    // add the new complement to the VP
    // yields [said [that John was kissing Mary and Susan in the room and
    // all will be fine] [behind the curtain]]
    CoordinatedPhraseElement s3 = new CoordinatedPhraseElement(s, s2);
    this.say.clearComplements();
    this.say.addComplement(s3);

    // first with outer complementiser suppressed
    s3.setFeature(Feature.SUPRESSED_COMPLEMENTISER, true);
    Assert.assertEquals(
        "said that John was kissing Mary and Susan in the room " //$NON-NLS-1$
            + "and all will be fine behind the curtain", //$NON-NLS-1$
        this.realiser.realise(this.say).getRealisation());

    setUp();
    s = this.phraseFactory.createClause();

    s.setSubject(this.phraseFactory
        .createNounPhrase("John")); //$NON-NLS-1$

    // Create a sentence first
    maryAndSusan = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Mary"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Susan")); //$NON-NLS-1$

    s.setVerbPhrase(this.kiss);
    s.setObject(maryAndSusan);
    s.setFeature(Feature.PROGRESSIVE, true);
    s.setFeature(Feature.TENSE,Tense.PAST);
    s.addPostModifier(this.inTheRoom);
    s2 = this.phraseFactory.createClause(this.phraseFactory
        .createNounPhrase("all"), //$NON-NLS-1$
        "be", //$NON-NLS-1$
        this.phraseFactory.createAdjectivePhrase("fine")); //$NON-NLS-1$

    s2.setFeature(Feature.TENSE,Tense.FUTURE);
    // then with complementiser not suppressed and not aggregated
    s3 = new CoordinatedPhraseElement(s, s2);
    this.say.addComplement(s3);
    this.say.setFeature(Feature.TENSE,Tense.PAST);
    this.say.addPostModifier(this.behindTheCurtain);
   
    Assert.assertEquals(
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

  public void testCoordination() {
    // simple case
    this.kiss.addComplement(this.dog);
    this.kick.addComplement(this.boy);

    CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
        this.kiss, this.kick);

    coord1.setFeature(Feature.PERSON, Person.THIRD);
    coord1.setFeature(Feature.TENSE,Tense.PAST);
    Assert.assertEquals("kissed the dog and kicked the boy", this.realiser //$NON-NLS-1$
        .realise(coord1).getRealisation());

    // with negation: should be inherited by all components
    coord1.setFeature(Feature.NEGATED, true);
    this.realiser.setLexicon(this.lexicon);
    Assert.assertEquals("did not kiss the dog and did not kick the boy", //$NON-NLS-1$
        this.realiser.realise(coord1).getRealisation());

    // set a modal
    coord1.setFeature(Feature.MODAL, "could"); //$NON-NLS-1$
    Assert
        .assertEquals(
            "could not have kissed the dog and could not have kicked the boy", //$NON-NLS-1$
            this.realiser.realise(coord1).getRealisation());

    // set perfect and progressive
    coord1.setFeature(Feature.PERFECT, true);
    coord1.setFeature(Feature.PROGRESSIVE, true);
    Assert.assertEquals("could not have been kissing the dog and " //$NON-NLS-1$
        + "could not have been kicking the boy", this.realiser.realise( //$NON-NLS-1$
        coord1).getRealisation());

    // now aggregate
    coord1.setFeature(Feature.AGGREGATE_AUXILIARY, true);
    Assert.assertEquals(
        "could not have been kissing the dog and kicking the boy", //$NON-NLS-1$
        this.realiser.realise(coord1).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

        aggregated
            .setFeature(
                InternalFeature.FRONT_MODIFIERS,
                previous
                    .getFeatureAsElementList(InternalFeature.FRONT_MODIFIERS));
        CoordinatedPhraseElement subjects = this.factory
            .createCoordinatedPhrase();
        subjects.setCategory(PhraseCategory.NOUN_PHRASE);
        List<NLGElement> allSubjects = previous
            .getFeatureAsElementList(InternalFeature.SUBJECTS);
        allSubjects.addAll(next
            .getFeatureAsElementList(InternalFeature.SUBJECTS));

        for (NLGElement subj : allSubjects) {
          subjects.addCoordinate(subj);
        }

        aggregated.setFeature(InternalFeature.SUBJECTS, subjects);
        aggregated
            .setFeature(
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    NLGElement ret = null;

    // CoordinatedPhraseElement
    if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlCoordinatedPhraseElement) {
      simplenlg.xmlrealiser.wrapper.XmlCoordinatedPhraseElement wp = (simplenlg.xmlrealiser.wrapper.XmlCoordinatedPhraseElement) wps;
      CoordinatedPhraseElement cp = new CoordinatedPhraseElement();
      ElementCategory cat = UnwrapCategory(wp.getCat());
      if (cat != null && cat instanceof PhraseCategory) {
        cp.setCategory(cat);
      }
      if (wp.getConj() != null) {
        String s = wp.getConj();
        if (s != null) {
          cp.setConjunction(s);
        }
      }
      if (wp.getPERSON() != null) {
        cp.setFeature(Feature.PERSON, wp.getPERSON());
      }

      cp.setFeature(Feature.POSSESSIVE, wp.isPOSSESSIVE());

      for (simplenlg.xmlrealiser.wrapper.XmlNLGElement p : wp.getCoord()) {
        NLGElement p1 = UnwrapNLGElement(p);
        if (p1 != null) {
          cp.addCoordinate(p1);
        }

      }
      ret = cp;
    }
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    if (phrase != null) {
      realisedElement = new ListElement();
      PhraseHelper.realiseList(parent, realisedElement, phrase
          .getPreModifiers(), DiscourseFunction.PRE_MODIFIER);

      CoordinatedPhraseElement coordinated = new CoordinatedPhraseElement();

      List<NLGElement> children = phrase.getChildren();
      String conjunction = phrase.getFeatureAsString(Feature.CONJUNCTION);
      coordinated.setFeature(Feature.CONJUNCTION, conjunction);
      coordinated.setFeature(Feature.CONJUNCTION_TYPE, phrase
          .getFeature(Feature.CONJUNCTION_TYPE));

      InflectedWordElement conjunctionElement = null;

      if (children != null && children.size() > 0) {
       
        if (phrase.getFeatureAsBoolean(Feature.RAISE_SPECIFIER)
            .booleanValue()) {
          raiseSpecifier(children);
        }

        NLGElement child = phrase.getLastCoordinate();
        child.setFeature(Feature.POSSESSIVE, phrase
            .getFeature(Feature.POSSESSIVE));

        child = children.get(0);

        setChildFeatures(phrase, child);

        coordinated.addCoordinate(parent.realise(child));
        for (int index = 1; index < children.size(); index++) {
          child = children.get(index);
          setChildFeatures(phrase, child);
          if (phrase.getFeatureAsBoolean(Feature.AGGREGATE_AUXILIARY)
              .booleanValue()) {
            child.setFeature(InternalFeature.REALISE_AUXILIARY,
                false);
          }

          if (child.isA(PhraseCategory.CLAUSE)) {
            child
                .setFeature(
                    Feature.SUPRESSED_COMPLEMENTISER,
                    phrase
                        .getFeature(Feature.SUPRESSED_COMPLEMENTISER));
          }

          //skip conjunction if it's null or empty string
          if (conjunction != null && conjunction.length() > 0) {
            conjunctionElement = new InflectedWordElement(
                conjunction, LexicalCategory.CONJUNCTION);
            conjunctionElement.setFeature(
                InternalFeature.DISCOURSE_FUNCTION,
                DiscourseFunction.CONJUNCTION);
            coordinated.addCoordinate(conjunctionElement);
          }

          coordinated.addCoordinate(parent.realise(child));
        }
        realisedElement.addComponent(coordinated);
      }

      PhraseHelper.realiseList(parent, realisedElement, phrase
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    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(
        this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
        "the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    // complex case with cue phrases
    // sentence: "however, tomorrow, Jane and Andrew will pick up the balls
    // in the shop"
    // this gets the front modifier "tomorrow" shifted to the end
    setUp();
    CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
        "the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

    Assert.assertEquals("did the woman not kiss the man", this.realiser //$NON-NLS-1$
        .realise(this.s1).getRealisation());

    // sentence: however, tomorrow, Jane and Andrew will not pick up the
    // balls in the shop
    CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    this.s4 = this.phraseFactory.createClause(subjects, "pick up", //$NON-NLS-1$
        "the balls"); //$NON-NLS-1$
    this.s4.addPostModifier("in the shop"); //$NON-NLS-1$
View Full Code Here

Examples of simplenlg.framework.CoordinatedPhraseElement

  @Test
  public void testCoordinateVPQuestions() {

    // create a complex vp: "kiss the dog and walk in the room"
    setUp();
    CoordinatedPhraseElement complex = new CoordinatedPhraseElement(
        this.kiss, this.walk);
    this.kiss.addComplement(this.dog);
    this.walk.addComplement(this.inTheRoom);

    // sentence: "However, tomorrow, Jane and Andrew will kiss the dog and
    // will walk in the room"
    CoordinatedPhraseElement subjects = new CoordinatedPhraseElement(
        this.phraseFactory.createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    this.s4 = this.phraseFactory.createClause(subjects, complex);
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$
    this.s4.setFeature(Feature.TENSE, Tense.FUTURE);

    Assert
        .assertEquals(
            "however tomorrow Jane and Andrew will kiss the dog and will walk in the room", //$NON-NLS-1$
            this.realiser.realise(this.s4).getRealisation());

    // setting to interrogative should automatically give us a single,
    // wide-scope aux
    setUp();
    subjects = new CoordinatedPhraseElement(this.phraseFactory
        .createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    this.kiss.addComplement(this.dog);
    this.walk.addComplement(this.inTheRoom);
    complex = new CoordinatedPhraseElement(this.kiss, this.walk);
    this.s4 = this.phraseFactory.createClause(subjects, complex);
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$
    this.s4.setFeature(Feature.TENSE, Tense.FUTURE);
    this.s4
        .setFeature(Feature.INTERROGATIVE_TYPE,
            InterrogativeType.YES_NO);

    Assert
        .assertEquals(
            "however will Jane and Andrew kiss the dog and walk in the room tomorrow", //$NON-NLS-1$
            this.realiser.realise(this.s4).getRealisation());

    // slightly more complex -- perfective
    setUp();
    this.realiser.setLexicon(this.lexicon);
    subjects = new CoordinatedPhraseElement(this.phraseFactory
        .createNounPhrase("Jane"), //$NON-NLS-1$
        this.phraseFactory.createNounPhrase("Andrew")); //$NON-NLS-1$
    complex = new CoordinatedPhraseElement(this.kiss, this.walk);
    this.kiss.addComplement(this.dog);
    this.walk.addComplement(this.inTheRoom);
    this.s4 = this.phraseFactory.createClause(subjects, complex);
    this.s4.setFeature(Feature.CUE_PHRASE, "however"); //$NON-NLS-1$
    this.s4.addFrontModifier("tomorrow"); //$NON-NLS-1$
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.