Examples of PhraseElement


Examples of simplenlg.framework.PhraseElement

    this.s1 = this.phraseFactory.createClause();
    this.s1.setSubject(this.woman);
    this.s1.setVerb("kiss");
    this.s1.setObject(this.man);

    PhraseElement _man = this.phraseFactory.createNounPhrase("the", "man"); //$NON-NLS-1$ //$NON-NLS-2$
    this.s3 = this.phraseFactory.createClause();
    this.s3.setSubject(_man);
    this.s3.setVerb("give");

    NPPhraseSpec flower = this.phraseFactory.createNounPhrase("flower"); //$NON-NLS-1$
    NPPhraseSpec john = this.phraseFactory.createNounPhrase("John"); //$NON-NLS-1$
    john.setFeature(Feature.POSSESSIVE, true);
    flower.setSpecifier(john);
    this.s3.setObject(flower);

    PhraseElement _woman = this.phraseFactory.createNounPhrase(
        "the", "woman"); //$NON-NLS-1$ //$NON-NLS-2$
    this.s3.setIndirectObject(_woman);

    // the coordinate sentence allows us to raise and lower complementiser
    CoordinatedPhraseElement coord2 = new CoordinatedPhraseElement(this.s1,
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testStringRecognition() {

    // test recognition of forms of "be"
    PhraseElement _s1 = this.phraseFactory.createClause(
        "my cat", "be", "sad"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Assert.assertEquals(
        "my cat is sad", this.realiser.realise(_s1).getRealisation()); //$NON-NLS-1$

    // test recognition of pronoun for afreement
    PhraseElement _s2 = this.phraseFactory
        .createClause("I", "want", "Mary"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    Assert.assertEquals(
        "I want Mary", this.realiser.realise(_s2).getRealisation()); //$NON-NLS-1$

    // test recognition of pronoun for correct form
    PhraseElement subject = this.phraseFactory.createNounPhrase("dog"); //$NON-NLS-1$
    subject.setFeature(InternalFeature.SPECIFIER, "a"); //$NON-NLS-1$
    subject.addPostModifier("from next door"); //$NON-NLS-1$
    PhraseElement object = this.phraseFactory.createNounPhrase("I"); //$NON-NLS-1$
    PhraseElement s = this.phraseFactory.createClause(subject,
        "chase", object); //$NON-NLS-1$
    s.setFeature(Feature.PROGRESSIVE, true);
    Assert.assertEquals("a dog from next door is chasing me", //$NON-NLS-1$
        this.realiser.realise(s).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testComplementation() {

    // was kissing Mary
    PhraseElement mary = this.phraseFactory.createNounPhrase("Mary"); //$NON-NLS-1$
    mary.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT);
    this.kiss.clearComplements();
    this.kiss.addComplement(mary);
    this.kiss.setFeature(Feature.PROGRESSIVE, true);
    this.kiss.setFeature(Feature.TENSE,Tense.PAST);

View Full Code Here

Examples of simplenlg.framework.PhraseElement

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

Examples of simplenlg.framework.PhraseElement

    }

    // Phrases
    else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlPhraseElement) {
      simplenlg.xmlrealiser.wrapper.XmlPhraseElement we = (simplenlg.xmlrealiser.wrapper.XmlPhraseElement) wps;
      PhraseElement hp = null;
      simplenlg.xmlrealiser.wrapper.XmlWordElement w = we.getHead();
      NLGElement head = UnwrapWordElement(w);

      // Noun Phrase
      if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec) {
        simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlNPPhraseSpec) wps;

        NPPhraseSpec p = factory.createNounPhrase(head);
        hp = p;

        if (wp.getSpec() != null) {
          // p.setSpecifier(UnwrapWordElement(wp.getSpec()));
          simplenlg.xmlrealiser.wrapper.XmlNLGElement spec = wp
              .getSpec();

          if (spec instanceof simplenlg.xmlrealiser.wrapper.XmlWordElement) {
            WordElement specifier = (WordElement) UnwrapWordElement((simplenlg.xmlrealiser.wrapper.XmlWordElement) spec);

            if (specifier != null) {
              p.setSpecifier(specifier);
            }

          } else {
            p.setSpecifier(UnwrapNLGElement(spec));
          }
        }

        setNPFeatures(wp, p);
      }

      // Adjective Phrase
      else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlAdjPhraseSpec) {
        simplenlg.xmlrealiser.wrapper.XmlAdjPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlAdjPhraseSpec) wps;
        AdjPhraseSpec p = factory.createAdjectivePhrase(head);
        hp = p;

        p.setFeature(Feature.IS_COMPARATIVE, wp.isISCOMPARATIVE());
        p.setFeature(Feature.IS_SUPERLATIVE, wp.isISSUPERLATIVE());
      }

      // Prepositional Phrase
      else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlPPPhraseSpec) {
        PPPhraseSpec p = factory.createPrepositionPhrase(head);
        hp = p;
      }

      // Adverb Phrase
      else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlAdvPhraseSpec) {
        simplenlg.xmlrealiser.wrapper.XmlAdvPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlAdvPhraseSpec) wps;
        AdvPhraseSpec p = factory.createAdverbPhrase();
        p.setHead(head);
        hp = p;
        p.setFeature(Feature.IS_COMPARATIVE, wp.isISCOMPARATIVE());
        p.setFeature(Feature.IS_SUPERLATIVE, wp.isISSUPERLATIVE());
      }

      // Verb Phrase
      else if (wps instanceof simplenlg.xmlrealiser.wrapper.XmlVPPhraseSpec) {
        simplenlg.xmlrealiser.wrapper.XmlVPPhraseSpec wp = (simplenlg.xmlrealiser.wrapper.XmlVPPhraseSpec) wps;
        VPPhraseSpec p = factory.createVerbPhrase(head);
        hp = p;
        setVPFeatures(wp, p);
      }

      // Common phrase components.
      UnwrapPhraseComponents(hp, wps);

      // set the discourse function, if defined
      if (we.getDiscourseFunction() != null) {
        hp.setFeature(InternalFeature.DISCOURSE_FUNCTION, Enum.valueOf(
            simplenlg.features.DiscourseFunction.class, we
                .getDiscourseFunction().toString()));
      }

      return hp;
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  private static void addDoAuxiliary(PhraseElement phrase,
      SyntaxProcessor parent, NLGFactory phraseFactory,
      ListElement realisedElement) {

    PhraseElement doPhrase = phraseFactory.createVerbPhrase("do"); //$NON-NLS-1$
    doPhrase.setFeature(Feature.TENSE, phrase.getFeature(Feature.TENSE));
    doPhrase.setFeature(Feature.PERSON, phrase.getFeature(Feature.PERSON));
    doPhrase.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER));
    realisedElement.addComponent(parent.realise(doPhrase));
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Override
  public void setFeature(String featureName, Object featureValue) {
    super.setFeature(featureName, featureValue);
    if (vpFeatures.contains(featureName)) {
      PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
      if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
        verbPhrase.setFeature(featureName, featureValue);
    }
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   * @seesimplenlg.framework.PhraseElement#addComplement(simplenlg.framework.
   * NLGElement)
   */
  @Override
  public void addComplement(NLGElement complement) {
    PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
    if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
      verbPhrase.addComplement(complement);
    else
      super.addComplement(complement);
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   *
   * @see simplenlg.framework.PhraseElement#addComplement(java.lang.String)
   */
  @Override
  public void addComplement(String newComplement) {
    PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
    if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
      verbPhrase.addComplement(newComplement);
    else
      super.addComplement(newComplement);
  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   * @return verb of clause
   */
  public NLGElement getVerb() {

    // WARNING - I don't understand verb phrase, so this may not work!!
    PhraseElement verbPhrase = (PhraseElement) getFeatureAsElement(InternalFeature.VERB_PHRASE);
    if (verbPhrase != null || verbPhrase instanceof VPPhraseSpec)
      return verbPhrase.getHead();
    else
      // return null if VP is coordinated phrase
      return null;
  }
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.