Package simplenlg.framework

Examples of simplenlg.framework.InflectedWordElement


    // hopefully will be better supported in later versions
 
    // get word element for "child"
    WordElement word = (WordElement) nlgFactory.createWord("child", LexicalCategory.NOUN);
    // create InflectedWordElement from word element
    InflectedWordElement inflectedWord = new InflectedWordElement(word);
    // set the inflected word to plural
    inflectedWord.setPlural(true);
    // realise the inflected word
    String result = realiser.realise(inflectedWord).getRealisation();
   
    System.out.println(result);
  }
View Full Code Here


  private static void pushModal(String actualModal, PhraseElement phrase,
      Stack<NLGElement> vgComponents) {
    if (actualModal != null
        && !phrase.getFeatureAsBoolean(InternalFeature.IGNORE_MODAL)
            .booleanValue()) {
      vgComponents.push(new InflectedWordElement(actualModal,
          LexicalCategory.MODAL));
    }
  }
View Full Code Here

    if (phrase.getFeatureAsBoolean(Feature.NEGATED).booleanValue()) {
      NLGFactory factory = phrase.getFactory();

      if (!vgComponents.empty() || frontVG != null && isCopular(frontVG)) {
        vgComponents.push(new InflectedWordElement(
            "not", LexicalCategory.ADVERB)); //$NON-NLS-1$
      } else {
        if (frontVG != null && !hasModal) {
          frontVG.setFeature(Feature.NEGATED, true);
          vgComponents.push(frontVG);
        }

        vgComponents.push(new InflectedWordElement(
            "not", LexicalCategory.ADVERB)); //$NON-NLS-1$

        if (factory != null) {
          newFront = factory.createInflectedWord("do",
              LexicalCategory.VERB);

        } else {
          newFront = new InflectedWordElement(
              "do", LexicalCategory.VERB); //$NON-NLS-1$
        }
      }
    }
    return newFront;
View Full Code Here

    if (frontVG != null) {
      frontVG.setFeature(Feature.FORM, Form.PAST_PARTICIPLE);
      vgComponents.push(frontVG);
    }
    newFront = new InflectedWordElement("have", LexicalCategory.VERB); //$NON-NLS-1$
    newFront.setFeature(Feature.TENSE, tenseValue);
    if (modal != null) {
      newFront.setFeature(InternalFeature.NON_MORPH, true);
    }
    return newFront;
View Full Code Here

    if (frontVG != null) {
      frontVG.setFeature(Feature.FORM, frontForm);
      vgComponents.push(frontVG);
    }
    return new InflectedWordElement("be", LexicalCategory.VERB); //$NON-NLS-1$
  }
View Full Code Here

      Tense tenseValue, boolean hasModal) {
    NLGElement frontVG = phrase.getHead();

    if (frontVG != null) {
      if (frontVG instanceof WordElement) {
        frontVG = new InflectedWordElement((WordElement) frontVG);
      }

      //AG: tense value should always be set on frontVG
      if (tenseValue != null) {
        frontVG.setFeature(Feature.TENSE, tenseValue);
View Full Code Here

        realisedElement = element;

      } else if (element instanceof WordElement) {
        // AG: need to check if it's a word element, in which case it
        // needs to be marked for inflection
        InflectedWordElement infl = new InflectedWordElement(
            (WordElement) element);

        // // the inflected word inherits all features from the base
        // word
        for (String feature : element.getAllFeatureNames()) {
          infl.setFeature(feature, element.getFeature(feature));
        }

        realisedElement = realise(infl);

      } else if (element instanceof CoordinatedPhraseElement) {
View Full Code Here

      currentElement = parent.realise(complement);
      if (currentElement != null) {
        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
            DiscourseFunction.COMPLEMENT);
        if (firstProcessed) {
          realisedElement.addComponent(new InflectedWordElement(
              "and", LexicalCategory.CONJUNCTION)); //$NON-NLS-1$
        } else {
          firstProcessed = true;
        }
        realisedElement.addComponent(currentElement);
View Full Code Here

    WordElement word = lexicon.getWord("lie", LexicalCategory.VERB);
    Assert.assertEquals(Inflection.REGULAR, word
        .getDefaultInflectionalVariant());

    // default past is "lied"
    InflectedWordElement infl = new InflectedWordElement(word);
    infl.setFeature(Feature.TENSE, Tense.PAST);
    String past = realiser.realise(infl).getRealisation();
    Assert.assertEquals("lied", past);

    // switch to irregular
    word.setDefaultInflectionalVariant(Inflection.IRREGULAR);
    infl = new InflectedWordElement(word);
    infl.setFeature(Feature.TENSE, Tense.PAST);
    past = realiser.realise(infl).getRealisation();
    Assert.assertEquals("lay", past);

    // switch back to regular
    word.setDefaultInflectionalVariant(Inflection.REGULAR);
    Assert.assertEquals(null, word.getFeature(LexicalFeature.PAST));
    infl = new InflectedWordElement(word);
    infl.setFeature(Feature.TENSE, Tense.PAST);
    past = realiser.realise(infl).getRealisation();
    Assert.assertEquals("lied", past);
  }
View Full Code Here

    Assert.assertEquals(Inflection.REGULAR, word
        .getDefaultInflectionalVariant());

    // reg plural shouldn't be stored
    Assert.assertEquals(null, word.getFeature(LexicalFeature.PLURAL));
    InflectedWordElement infl = new InflectedWordElement(word);
    infl.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    String plur = realiser.realise(infl).getRealisation();
    Assert.assertEquals("sanctums", plur);

    // switch to glreg
    word.setDefaultInflectionalVariant(Inflection.GRECO_LATIN_REGULAR);
    infl = new InflectedWordElement(word);
    infl.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    plur = realiser.realise(infl).getRealisation();
    Assert.assertEquals("sancta", plur);

    // and back to reg
    word.setDefaultInflectionalVariant(Inflection.REGULAR);
    infl = new InflectedWordElement(word);
    infl.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
    plur = realiser.realise(infl).getRealisation();
    Assert.assertEquals("sanctums", plur);
  }
View Full Code Here

TOP

Related Classes of simplenlg.framework.InflectedWordElement

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.