Examples of PhraseElement


Examples of simplenlg.framework.PhraseElement

   * Simple test of adverbials
   */
  @Test
  public void testAdv() {

    PhraseElement sent = this.phraseFactory.createClause("John", "eat"); //$NON-NLS-1$ //$NON-NLS-2$

    PhraseElement adv = this.phraseFactory.createAdverbPhrase("quickly"); //$NON-NLS-1$

    sent.addPreModifier(adv);

    Assert.assertEquals("John quickly eats", this.realiser.realise(sent) //$NON-NLS-1$
        .getRealisation());

    adv.addPreModifier("very"); //$NON-NLS-1$

    Assert.assertEquals("John very quickly eats", this.realiser.realise( //$NON-NLS-1$
        sent).getRealisation());

  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testPossessive() {

    // simple possessive 's: 'a man's'
    PhraseElement possNP = this.phraseFactory.createNounPhrase("a", "man"); //$NON-NLS-1$ //$NON-NLS-2$
    possNP.setFeature(Feature.POSSESSIVE, true);
    Assert.assertEquals("a man's", this.realiser.realise(possNP) //$NON-NLS-1$
        .getRealisation());

    // now set this possessive as specifier of the NP 'the dog'
    this.dog.setFeature(InternalFeature.SPECIFIER, possNP);
    Assert.assertEquals("a man's dog", this.realiser.realise(this.dog) //$NON-NLS-1$
        .getRealisation());

    // convert possNP to pronoun and turn "a dog" into "his dog"
    // need to specify gender, as default is NEUTER
    possNP.setFeature(LexicalFeature.GENDER, Gender.MASCULINE);
    possNP.setFeature(Feature.PRONOMINAL, true);
    Assert.assertEquals("his dog", this.realiser.realise(this.dog) //$NON-NLS-1$
        .getRealisation());

    // make it slightly more complicated: "his dog's rock"
    this.dog.setFeature(Feature.POSSESSIVE, true); // his dog's
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  /**
   * Test A vs An.
   */
  @Test
  public void testAAn() {
    PhraseElement _dog = this.phraseFactory.createNounPhrase("a", "dog"); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("a dog", this.realiser.realise(_dog) //$NON-NLS-1$
        .getRealisation());

    _dog.addPreModifier("enormous"); //$NON-NLS-1$

    Assert.assertEquals("an enormous dog", this.realiser.realise(_dog) //$NON-NLS-1$
        .getRealisation());

    PhraseElement elephant = this.phraseFactory.createNounPhrase(
        "a", "elephant"); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("an elephant", this.realiser.realise(elephant) //$NON-NLS-1$
        .getRealisation());

    elephant.addPreModifier("big"); //$NON-NLS-1$
    Assert.assertEquals("a big elephant", this.realiser.realise(elephant) //$NON-NLS-1$
        .getRealisation());

    // test treating of plural specifiers
    _dog.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  /**
   * Test Modifier "guess" placement.
   */
  @Test
  public void testModifier() {
    PhraseElement _dog = this.phraseFactory.createNounPhrase("a", "dog"); //$NON-NLS-1$ //$NON-NLS-2$
    _dog.addPreModifier("angry"); //$NON-NLS-1$

    Assert.assertEquals("an angry dog", this.realiser.realise(_dog) //$NON-NLS-1$
        .getRealisation());

    _dog.addPostModifier("in the park"); //$NON-NLS-1$
    Assert.assertEquals("an angry dog in the park", this.realiser.realise( //$NON-NLS-1$
        _dog).getRealisation());

    PhraseElement cat = this.phraseFactory.createNounPhrase("a", "cat"); //$NON-NLS-1$ //$NON-NLS-2$
    cat.addPreModifier(this.phraseFactory.createAdjectivePhrase("angry")); //$NON-NLS-1$
    Assert.assertEquals("an angry cat", this.realiser.realise(cat) //$NON-NLS-1$
        .getRealisation());

    cat.addPostModifier(this.phraseFactory.createPrepositionPhrase(
        "in", "the park")); //$NON-NLS-1$ //$NON-NLS-2$
    Assert.assertEquals("an angry cat in the park", this.realiser.realise( //$NON-NLS-1$
        cat).getRealisation());

  }
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    // Set possessive on the pronoun to make it 'her'
    she.setFeature(Feature.POSSESSIVE, true);

    // Create a noun phrase with the subject lover and the determiner
    // as she
    PhraseElement herLover = phraseFactory.createNounPhrase(she,"lover");

    // Create a clause to say 'he be her lover'
    PhraseElement clause = phraseFactory.createClause("he", "be", herLover);

    // Add the cue phrase need the comma as orthography
    // currently doesn't handle this.
    // This could be expanded to be a noun phrase with determiner
    // 'two' and noun 'week', set to plural and with a premodifier of
    // 'after'
    clause.setFeature(Feature.CUE_PHRASE, "after two weeks,");

    // Add the 'for a fortnight' as a post modifier. Alternatively
    // this could be added as a prepositional phrase 'for' with a
    // complement of a noun phrase ('a' 'fortnight')
    clause.addPostModifier("for a fortnight");

    // Set 'be' to 'was' as past tense
    clause.setFeature(Feature.TENSE,Tense.PAST);

    // Add the clause to a sentence.
    DocumentElement sentence1 = docFactory.createSentence(clause);

    // Realise the sentence
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    // Set possessive on the pronoun to make it 'her'
    she.setFeature(Feature.POSSESSIVE, true);

    // Create a noun phrase with the subject lover and the determiner
    // as she
    PhraseElement herLover = phraseFactory.createNounPhrase(she,"lover");
    herLover.setPlural(true);

    // Create the pronoun 'he'
    NLGElement he = phraseFactory.createNounPhrase(LexicalCategory.PRONOUN,"he");
    he.setPlural(true);

    // Create a clause to say 'they be her lovers'
    PhraseElement clause = phraseFactory.createClause(he, "be", herLover);
    clause.setFeature(Feature.POSSESSIVE, true);

    // Add the cue phrase need the comma as orthography
    // currently doesn't handle this.
    // This could be expanded to be a noun phrase with determiner
    // 'two' and noun 'week', set to plural and with a premodifier of
    // 'after'
    clause.setFeature(Feature.CUE_PHRASE, "after two weeks,");

    // Add the 'for a fortnight' as a post modifier. Alternatively
    // this could be added as a prepositional phrase 'for' with a
    // complement of a noun phrase ('a' 'fortnight')
    clause.addPostModifier("for a fortnight");

    // Set 'be' to 'was' as past tense
    clause.setFeature(Feature.TENSE,Tense.PAST);
   
    // Add the clause to a sentence.
    DocumentElement sentence1 = docFactory.createSentence(clause);

    // Realise the sentence
View Full Code Here

Examples of simplenlg.framework.PhraseElement

   */
  @Test
  public void testDavesHouse() {
    this.phraseFactory.setLexicon(this.lexicon);

    PhraseElement born = phraseFactory.createClause("Dave Bus", "be", "born");
    born.setFeature(Feature.TENSE,Tense.PAST);
    born.addPostModifier("in");
    born.setFeature(Feature.COMPLEMENTISER, "which");

    PhraseElement theHouse = phraseFactory.createNounPhrase("the", "house");
    theHouse.addComplement(born);

    PhraseElement clause = phraseFactory.createClause(theHouse, "be", phraseFactory.createPrepositionPhrase("in", "Edinburgh"));
    DocumentElement sentence = docFactory.createSentence(clause);
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());

    // Retrieve the realisation and dump it to the console
View Full Code Here

Examples of simplenlg.framework.PhraseElement

    NLGElement albert = phraseFactory.createWord("Albert", LexicalCategory.NOUN);
   
    CoordinatedPhraseElement coord1 = new CoordinatedPhraseElement(
        dave, albert);
   
    PhraseElement born = phraseFactory.createClause(coord1, "be", "born");
    born.setFeature(Feature.TENSE,Tense.PAST);
    born.addPostModifier("in");
    born.setFeature(Feature.COMPLEMENTISER, "which");

    PhraseElement theHouse = phraseFactory.createNounPhrase("the", "house");
    theHouse.addComplement(born);

    PhraseElement clause = phraseFactory.createClause(theHouse, "be", phraseFactory.createPrepositionPhrase("in", "Edinburgh"));
    DocumentElement sentence = docFactory.createSentence(clause);
   
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  @Test
  public void testEngineerHolidays() {
    this.phraseFactory.setLexicon(this.lexicon);

    // Inner clause is 'I' 'make' 'sentence' 'for'.
    PhraseElement inner = phraseFactory.createClause("I","make", "sentence for");
    // Inner clause set to progressive.
    inner.setFeature(Feature.PROGRESSIVE,true);
   
    //Complementiser on inner clause is 'whom'
    inner.setFeature(Feature.COMPLEMENTISER, "whom");
   
    // create the engineer and add the inner clause as post modifier
    PhraseElement engineer = phraseFactory.createNounPhrase("the engineer");
    engineer.addComplement(inner);
   
    // Outer clause is: 'the engineer' 'go' (preposition 'to' 'holidays')
    PhraseElement outer = phraseFactory.createClause(engineer,"go",phraseFactory.createPrepositionPhrase("to","holidays"));

    // Outer clause tense is Future.
    outer.setFeature(Feature.TENSE, Tense.FUTURE);
   
    // Possibly progressive as well not sure.
    outer.setFeature(Feature.PROGRESSIVE,true);
   
    //Outer clause postmodifier would be 'tomorrow'
    outer.addPostModifier("tomorrow");
    DocumentElement sentence = docFactory.createSentence(outer);
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());

    // Retrieve the realisation and dump it to the console
View Full Code Here

Examples of simplenlg.framework.PhraseElement

  @Test
  public void testHousePoker() {
    setUp();
    this.realiser.setLexicon(this.lexicon);
   
    PhraseElement inner = phraseFactory.createClause("I", "play", "poker");
    inner.setFeature(Feature.TENSE,Tense.PAST);
    inner.setFeature(Feature.COMPLEMENTISER, "where");
   
    PhraseElement house = phraseFactory.createNounPhrase("the", "house");
    house.addComplement(inner);
   
    SPhraseSpec outer = phraseFactory.createClause(null, "abandon", house);
   
    outer.addPostModifier("since 1986");
   
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.