Package simplenlg.framework

Examples of simplenlg.framework.NLGElement


  public void testCoordinationSameVP2() {
    List<NLGElement> elements = Arrays.asList((NLGElement) this.s3,
        (NLGElement) this.s4, (NLGElement) this.s5);
    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 and the girl kick the dog behind the curtain", //$NON-NLS-1$
            this.realiser.realise(aggregated).getRealisation());
  }
View Full Code Here


  /**
   * Forward conjunction reduction test
   */
  @Test
  public void testForwardConjReduction() {
    NLGElement aggregated = this.fcr.apply(this.s2, this.s3);
    Assert
        .assertEquals(
            "the woman kicks the dog on the rock and kicks the dog behind the curtain", //$NON-NLS-1$
            this.realiser.realise(aggregated).getRealisation());
  }
View Full Code Here

  /**
   * Backward conjunction reduction test
   */
  @Test
  public void testBackwardConjunctionReduction() {
    NLGElement aggregated = this.bcr.apply(this.s3, this.s6);
    Assert
        .assertEquals(
            "the woman kicks and the woman kisses the dog behind the curtain",
            this.realiser.realise(aggregated).getRealisation());
  }
View Full Code Here

    // create a realiser.  Note that a lexicon is specified, this should be
    // the same one used by the NLGFactory
    Realiser realiser = new Realiser(lexicon);
    //realiser.setDebugMode(true);     // uncomment this to print out debug info during realisation
    NLGElement realised = realiser.realise(paragraph);

    System.out.println(realised.getRealisation());

    // end of main example
   
    // second example - using simplenlg just for morphology
    // below is clumsy as direct access to morphology isn't properly supported in V4.2
View Full Code Here

  /**
   * Test the realisation of a simple list
   */
  @Test
  public void testSimpleListOrthography() {
    NLGElement realised = this.realiser.realise(this.list1);
    Assert.assertEquals(this.list1Realisation, realised.getRealisation());
  }
View Full Code Here

  /**
   * Test the realisation of a list with an embedded list
   */
  @Test
  public void testEmbeddedListOrthography() {
    NLGElement realised = this.realiser.realise(this.list2);
    Assert.assertEquals(this.list2Realisation, realised.getRealisation());
  }
View Full Code Here

  /**
   * Test that pronominal args are being correctly cast as NPs.
   */
  public void testPronounArguments() {
    // the subject of s2 should have been cast into a pronominal NP
    NLGElement subj = this.s2.getFeatureAsElementList(
        InternalFeature.SUBJECTS).get(0);
    Assert.assertTrue(subj.isA(PhraseCategory.NOUN_PHRASE));
    // Assert.assertTrue(LexicalCategory.PRONOUN.equals(((PhraseElement)
    // subj)
    // .getCategory()));
  }
View Full Code Here

  @Test
  public void testSection3() {
    Lexicon lexicon = Lexicon.getDefaultLexicon();                         // default simplenlg lexicon
    NLGFactory nlgFactory = new NLGFactory(lexicon);             // factory based on lexicon

    NLGElement s1 = nlgFactory.createSentence("my dog is happy");
   
    Realiser r = new Realiser(lexicon);
   
    String output = r.realiseSentence(s1);
   
View Full Code Here

  /** sets the verb (head) of a verb phrase.
   * Extract particle from verb if necessary
   * @param verb
   */
  public void setVerb(Object verb) {
    NLGElement verbElement;
   
    if (verb instanceof String) { // if String given, check for particle
      int space = ((String) verb).indexOf(' ');
     
      if (space == -1) { // no space, so no particle
View Full Code Here

  /** Sets the direct object of a clause  (assumes this is the only direct object)
   *
   * @param object
   */
  public void setObject(Object object) {
    NLGElement objectPhrase;
    if (object instanceof PhraseElement || object instanceof CoordinatedPhraseElement)
      objectPhrase = (NLGElement) object;
    else
      objectPhrase = getFactory().createNounPhrase(object);

    objectPhrase.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT);
    setComplement(objectPhrase);
  }
View Full Code Here

TOP

Related Classes of simplenlg.framework.NLGElement

Copyright © 2018 www.massapicom. 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.