Examples of NPPhraseSpec


Examples of simplenlg.phrasespec.NPPhraseSpec

    s.setSubject(this.phraseFactory.createNounPhrase("the", "patient"));

    // first VP
    VPPhraseSpec vp1 = this.phraseFactory.createVerbPhrase(this.lexicon
        .getWord("have", LexicalCategory.VERB));
    NPPhraseSpec np1 = this.phraseFactory.createNounPhrase("a",
        this.lexicon.getWord("contrast media reaction",
            LexicalCategory.NOUN));
    np1.addPreModifier(this.lexicon.getWord("adverse",
        LexicalCategory.ADJECTIVE));
    vp1.addComplement(np1);

    // second VP
    VPPhraseSpec vp2 = this.phraseFactory.createVerbPhrase(this.lexicon
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

    Lexicon lexicon = new XMLLexicon();                          // default simplenlg lexicon
    NLGFactory nlgFactory = new NLGFactory(lexicon);             // factory based on lexicon

    // create sentences
    //   "John did not go to the bigger park. He played football there."
    NPPhraseSpec thePark = nlgFactory.createNounPhrase("the", "park");   // create an NP
    AdjPhraseSpec bigp = nlgFactory.createAdjectivePhrase("big");        // create AdjP
    bigp.setFeature(Feature.IS_COMPARATIVE, true);                       // use comparative form ("bigger")
    thePark.addModifier(bigp);                                        // add adj as modifier in NP
    // above relies on default placement rules.  You can force placement as a premodifier
    // (before head) by using addPreModifier
    PPPhraseSpec toThePark = nlgFactory.createPrepositionPhrase("to");    // create a PP
    toThePark.setObject(thePark);                                     // set PP object
    // could also just say nlgFactory.createPrepositionPhrase("to", the Park);
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

    public void testSection8( ) {
      Lexicon lexicon = Lexicon.getDefaultLexicon( ) ;      // default simplenlg lexicon
      NLGFactory nlgFactory = new NLGFactory( lexicon ) // factory based on lexicon
      Realiser realiser = new Realiser( lexicon ) ;
     
      NPPhraseSpec subject = nlgFactory.createNounPhrase( "Mary" ) ;
      NPPhraseSpec object = nlgFactory.createNounPhrase( "the monkey" ) ;
      VPPhraseSpec verb = nlgFactory.createVerbPhrase( "chase" ) ; ;
      subject.addModifier( "fast" ) ;
     
      SPhraseSpec p = nlgFactory.createClause( ) ;
      p.setSubject( subject ) ;
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

    public void testSection10( ) {
      Lexicon lexicon = Lexicon.getDefaultLexicon( ) ;      // default simplenlg lexicon
      NLGFactory nlgFactory = new NLGFactory( lexicon ) // factory based on lexicon
      Realiser realiser = new Realiser( lexicon ) ;
     
      NPPhraseSpec subject1 = nlgFactory.createNounPhrase( "Mary" ) ;
      NPPhraseSpec subject2 = nlgFactory.createNounPhrase( "your", "giraffe" ) ;
     
      // next line is not correct ~ should be nlgFactory.createCoordinatedPhrase ~ may be corrected in the API
      CoordinatedPhraseElement subj = nlgFactory.createCoordinatedPhrase( subject1, subject2 ) ;
     
      VPPhraseSpec verb = nlgFactory.createVerbPhrase( "chase" ) ; ;

      SPhraseSpec p = nlgFactory.createClause( ) ;
      p.setSubject( subj ) ;
      p.setVerb( verb ) ;
      p.setObject( "the monkey" ) ;
     
      String outputA = realiser.realiseSentence( p ) ;
      Assert.assertEquals( "Mary and your giraffe chase the monkey.", outputA ) ;
     
      NPPhraseSpec object1 = nlgFactory.createNounPhrase( "the monkey" ) ;
      NPPhraseSpec object2 = nlgFactory.createNounPhrase( "George" ) ;
     
      // next line is not correct ~ should be nlgFactory.createCoordinatedPhrase ~ may be corrected in the API
      CoordinatedPhraseElement obj = nlgFactory.createCoordinatedPhrase( object1, object2 ) ;
      obj.addCoordinate( "Martha" ) ;
      p.setObject( obj ) ;
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   
    String outputA = realiser.realiseSentence( pA ) ;   
    Assert.assertEquals( "Mary chases the monkey in the park.", outputA ) ;
   
    // alternative build paradigm
    NPPhraseSpec place = nlgFactory.createNounPhrase( "park" ) ;
    SPhraseSpec pB = nlgFactory.createClause( "Mary", "chase", "the monkey" ) ;
   
    // next line is depreciated ~ may be corrected in the API
    place.setDeterminer( "the" ) ;
    PPPhraseSpec pp = nlgFactory.createPrepositionPhrase( ) ;
    pp.addComplement( place ) ;
    pp.setPreposition( "in" ) ;
   
    pB.addComplement( pp ) ;
   
    String outputB = realiser.realiseSentence( pB ) ;   
    Assert.assertEquals( "Mary chases the monkey in park.", outputB ) // NB missing the determiner "the" !! 
   
    place.addPreModifier( "leafy" ) ;
   
    String outputC = realiser.realiseSentence( pB ) ;   
    Assert.assertEquals( "Mary chases the monkey in leafy park.", outputC ) // NB missing the determiner "the" !! 
   } // testSection11
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

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

Examples of simplenlg.phrasespec.NPPhraseSpec

    Assert.assertTrue(spellVars.contains("formalisation"));
    Assert.assertEquals(Inflection.REGULAR, word
        .getDefaultInflectionalVariant());

    // create with default spelling
    NPPhraseSpec np = factory.createNounPhrase("the", word);
    np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    Assert.assertEquals("the formalizations", this.realiser.realise(np)
        .getRealisation());

    // reset spell var
    word.setDefaultSpellingVariant("formalisation");
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

  @Test
  public void testSpellingVariantsInNP() {
    WordElement asd = lexicon.getWord("Adams-Stokes disease");
    Assert.assertEquals("Adams-Stokes disease", asd
        .getDefaultSpellingVariant());
    NPPhraseSpec np = this.factory.createNounPhrase(asd);
    np.setSpecifier(lexicon.getWord("the"));
    Assert.assertEquals("the Adams-Stokes disease", this.realiser.realise(
        np).getRealisation());

    // change spelling var
    asd.setDefaultSpellingVariant("Adams Stokes disease");
    Assert.assertEquals("Adams Stokes disease", asd
        .getDefaultSpellingVariant());
    Assert.assertEquals("the Adams Stokes disease", this.realiser.realise(
        np).getRealisation());

    np.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    Assert.assertEquals("the Adams Stokes diseases", this.realiser.realise(
        np).getRealisation());
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

   */
  public NPPhraseSpec createNounPhrase(Object specifier, Object noun) {
    if (noun instanceof NPPhraseSpec)
      return (NPPhraseSpec) noun;

    NPPhraseSpec phraseElement = new NPPhraseSpec(this);
    NLGElement nounElement = createNLGElement(noun, LexicalCategory.NOUN);
    setPhraseHead(phraseElement, nounElement);

    if (specifier != null)
      phraseElement.setSpecifier(specifier);

    return phraseElement;
  }
View Full Code Here

Examples of simplenlg.phrasespec.NPPhraseSpec

  @Test
  public void testDwight() {
    // Rachel Dwight's test
    this.phraseFactory.setLexicon(this.lexicon);

    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(
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.