Examples of NLGElement


Examples of simplenlg.framework.NLGElement

  public void testHerLover() {
    this.phraseFactory.setLexicon(this.lexicon);
    this.realiser.setLexicon(this.lexicon);
   
    // Create the pronoun 'she'
    NLGElement she = phraseFactory.createWord("she",LexicalCategory.PRONOUN);

    // 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
    NLGElement realised = this.realiser.realise(sentence1);

    // Retrieve the realisation and dump it to the console
//    System.out.println(realised.getRealisation());    
    Assert.assertEquals("After two weeks, he was her lover for a fortnight.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

    this.woman.clearComplements();

    CoordinatedPhraseElement cnp1 = new CoordinatedPhraseElement(this.dog,
        this.woman);
    cnp1.setFeature(Feature.RAISE_SPECIFIER, true);
    NLGElement realised = this.realiser.realise(cnp1);
    Assert.assertEquals("the dog and woman", realised.getRealisation());

    this.dog.addComplement(this.onTheRock);
    this.woman.addComplement(this.behindTheCurtain);

    CoordinatedPhraseElement cnp2 = new CoordinatedPhraseElement(this.dog,
        this.woman);

    this.woman.setFeature(InternalFeature.RAISED, false);
    Assert.assertEquals(
        "the dog on the rock and the woman behind the curtain", //$NON-NLS-1$
        this.realiser.realise(cnp2).getRealisation());

    // complementised coordinates + outer pp modifier
    cnp2.addPostModifier(this.inTheRoom);
    Assert
        .assertEquals(
            "the dog on the rock and the woman behind the curtain in the room", //$NON-NLS-1$
            this.realiser.realise(cnp2).getRealisation());

    // set the specifier for this cnp; should unset specifiers for all inner
    // coordinates
    NLGElement every = this.phraseFactory.createWord(
        "every", LexicalCategory.DETERMINER); //$NON-NLS-1$

    cnp2.setFeature(InternalFeature.SPECIFIER, every);

    Assert
View Full Code Here

Examples of simplenlg.framework.NLGElement

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

    // Create the pronoun 'she'
    NLGElement she = phraseFactory.createWord("she",LexicalCategory.PRONOUN);

    // 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
    NLGElement realised = this.realiser.realise(sentence1);

    // Retrieve the realisation and dump it to the console
//    System.out.println(realised.getRealisation());

    Assert.assertEquals("After two weeks, they were her lovers for a fortnight.", //$NON-NLS-1$
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

    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
    Assert.assertEquals("The house which Dave Bus was born in is in Edinburgh.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

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

    NLGElement dave = phraseFactory.createWord("Dave Bus", LexicalCategory.NOUN);
    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());

    // Retrieve the realisation and dump it to the console
    Assert.assertEquals("The house which Dave Bus and Albert were born in is in Edinburgh.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

    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
    Assert.assertEquals("The engineer whom I am making sentence for will be going to holidays tomorrow.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

   
    outer.setFeature(Feature.PASSIVE, true);
    outer.setFeature(Feature.PERFECT, true);
   
    DocumentElement sentence = docFactory.createSentence(outer);
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());

    // Retrieve the realisation and dump it to the console
    Assert.assertEquals("The house where I played poker has been abandoned since 1986.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

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

    NLGElement sandwich = phraseFactory.createNounPhrase(LexicalCategory.NOUN, "sandwich");
    sandwich.setPlural(true);
    //
    PhraseElement first = phraseFactory.createClause("I", "make", sandwich);
    first.setFeature(Feature.TENSE,Tense.PAST);
    first.setFeature(Feature.PROGRESSIVE,true);
    first.setPlural(false);
   
    PhraseElement second = phraseFactory.createClause("the mayonnaise", "run out");
    second.setFeature(Feature.TENSE,Tense.PAST);
    //
    second.setFeature(Feature.COMPLEMENTISER, "when");
   
    first.addComplement(second);
   
    DocumentElement sentence = docFactory.createSentence(first);
    NLGElement realised = realiser.realise(sentence);
//    System.out.println(realised.getRealisation());

    // Retrieve the realisation and dump it to the console
    Assert.assertEquals("I was making sandwiches when the mayonnaise ran out.",
        realised.getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

  public void testCoordinationSameVP() {
    List<NLGElement> elements = Arrays.asList((NLGElement) this.s3,
        (NLGElement) this.s4);
    List<NLGElement> result = this.coord.apply(elements);
    Assert.assertTrue(result.size() == 1); // should only be one sentence
    NLGElement aggregated = result.get(0);
    Assert.assertEquals(
        "the woman and the man kick the dog behind the curtain", //$NON-NLS-1$
        this.realiser.realise(aggregated).getRealisation());
  }
View Full Code Here

Examples of simplenlg.framework.NLGElement

        .createAdverbPhrase("however"));
    List<NLGElement> elements = Arrays.asList((NLGElement) this.s3,
        (NLGElement) this.s4);
    List<NLGElement> result = this.coord.apply(elements);
    Assert.assertTrue(result.size() == 1); // should only be one sentence
    NLGElement aggregated = result.get(0);
    Assert
        .assertEquals(
            "however the woman and the man kick the dog behind the curtain", //$NON-NLS-1$
            this.realiser.realise(aggregated).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.