Package simplenlg.framework

Examples of simplenlg.framework.ListElement


   * @param phrase
   *            the <code>PhraseElement</code> to be realised.
   * @return the realised <code>NLGElement</code>.
   */
  static NLGElement realise(SyntaxProcessor parent, PhraseElement phrase) {
    ListElement realisedElement = null;
    Stack<NLGElement> vgComponents = null;
    Stack<NLGElement> mainVerbRealisation = new Stack<NLGElement>();
    Stack<NLGElement> auxiliaryRealisation = new Stack<NLGElement>();

    if (phrase != null) {
      vgComponents = createVerbGroup(parent, phrase);
      splitVerbGroup(vgComponents, mainVerbRealisation,
          auxiliaryRealisation);

      realisedElement = new ListElement();

      if (!phrase.hasFeature(InternalFeature.REALISE_AUXILIARY)
          || phrase.getFeatureAsBoolean(
              InternalFeature.REALISE_AUXILIARY).booleanValue()) {

View Full Code Here


   *            the current realisation of the noun phrase.
   */
  private static void realiseComplements(SyntaxProcessor parent,
      PhraseElement phrase, ListElement realisedElement) {

    ListElement indirects = new ListElement();
    ListElement directs = new ListElement();
    ListElement unknowns = new ListElement();
    Object discourseValue = null;
    NLGElement currentElement = null;

    for (NLGElement complement : phrase
        .getFeatureAsElementList(InternalFeature.COMPLEMENTS)) {

      discourseValue = complement
          .getFeature(InternalFeature.DISCOURSE_FUNCTION);
      currentElement = parent.realise(complement);
      if (currentElement != null) {
        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
            DiscourseFunction.COMPLEMENT);

        if (DiscourseFunction.INDIRECT_OBJECT.equals(discourseValue)) {
          indirects.addComponent(currentElement);
        } else if (DiscourseFunction.OBJECT.equals(discourseValue)) {
          directs.addComponent(currentElement);
        } else {
          unknowns.addComponent(currentElement);
        }
      }
    }
    if (!InterrogativeType.isIndirectObject(phrase
        .getFeature(Feature.INTERROGATIVE_TYPE))) {
      realisedElement.addComponents(indirects.getChildren());
    }
    if (!phrase.getFeatureAsBoolean(Feature.PASSIVE).booleanValue()) {
      if (!InterrogativeType.isObject(phrase
          .getFeature(Feature.INTERROGATIVE_TYPE))) {
        realisedElement.addComponents(directs.getChildren());
      }
      realisedElement.addComponents(unknowns.getChildren());
    }
  }
View Full Code Here

      } else if (element instanceof PhraseElement) {
        realisedElement = realisePhraseElement((PhraseElement) element);

      } else if (element instanceof ListElement) {
        realisedElement = new ListElement();
        ((ListElement) realisedElement).addComponents(realise(element
            .getChildren()));

      } else if (element instanceof InflectedWordElement) {
        String baseForm = ((InflectedWordElement) element)
View Full Code Here

   * @param phrase
   *            the <code>PhraseElement</code> to be realised.
   * @return the realised <code>NLGElement</code>.
   */
  static NLGElement realise(SyntaxProcessor parent, PhraseElement phrase) {
    ListElement realisedElement = null;

    if (phrase != null) {
      realisedElement = new ListElement();

      realiseList(parent, realisedElement, phrase.getPreModifiers(),
          DiscourseFunction.PRE_MODIFIER);

      realiseHead(parent, phrase, realisedElement);
View Full Code Here

    // AG: Change here: the original list structure is kept, i.e. rather
    // than taking the elements of the list and putting them in the realised
    // element, we now add the realised elements to a new list and put that
    // in the realised element list. This preserves constituency for
    // orthography and morphology processing later.
    ListElement realisedList = new ListElement();
    NLGElement currentElement = null;
    for (NLGElement eachElement : elementList) {
      currentElement = parent.realise(eachElement);

      if (currentElement != null) {
        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION,
            function);
        // realisedElement.addComponent(currentElement);
        realisedList.addComponent(currentElement);
      }
    }

    if (!realisedList.getChildren().isEmpty()) {
      realisedElement.addComponent(realisedList);
    }
  }
View Full Code Here

        case LIST_ITEM:
          if (components != null && components.size() > 0) {
            // recursively realise whatever's in the list item
            // NB: this will realise embedded lists within list
            // items
            realisedElement = new ListElement(realise(components));
          }
          break;

        default:
          ((DocumentElement) element)
View Full Code Here

   * @param phrase
   *            the <code>PhraseElement</code> representation of the clause.
   * @return the <code>NLGElement</code> representing the realised clause.
   */
  static NLGElement realise(SyntaxProcessor parent, PhraseElement phrase) {
    ListElement realisedElement = null;
    NLGFactory phraseFactory = phrase.getFactory();
    NLGElement splitVerb = null;
    boolean interrogObj = false;

    if (phrase != null) {
      realisedElement = new ListElement();
      NLGElement verbElement = phrase
          .getFeatureAsElement(InternalFeature.VERB_PHRASE);

      if (verbElement == null) {
        verbElement = phrase.getHead();
View Full Code Here

   */
  private static ListElement realiseSubjects(PhraseElement phrase,
      SyntaxProcessor parent) {

    NLGElement currentElement = null;
    ListElement realisedElement = new ListElement();

    for (NLGElement subject : phrase
        .getFeatureAsElementList(InternalFeature.SUBJECTS)) {

      subject.setFeature(InternalFeature.DISCOURSE_FUNCTION,
          DiscourseFunction.SUBJECT);
      if (Form.GERUND.equals(phrase.getFeature(Feature.FORM))
          && !phrase.getFeatureAsBoolean(
              Feature.SUPPRESS_GENITIVE_IN_GERUND).booleanValue()) {
        subject.setFeature(Feature.POSSESSIVE, true);
      }
      currentElement = parent.realise(subject);
      if (currentElement != null) {
        realisedElement.addComponent(currentElement);
      }
    }
    return realisedElement;
  }
View Full Code Here

   * @param phrase
   *            the <code>PhraseElement</code> to be realised.
   * @return the realised <code>NLGElement</code>.
   */
  static NLGElement realise(SyntaxProcessor parent, PhraseElement phrase) {
    ListElement realisedElement = null;

    if (phrase != null
        && !phrase.getFeatureAsBoolean(Feature.ELIDED).booleanValue()) {
      realisedElement = new ListElement();

      if (phrase.getFeatureAsBoolean(Feature.PRONOMINAL).booleanValue()) {
        realisedElement.addComponent(createPronoun(parent, phrase));

      } else {
        realiseSpecifier(phrase, parent, realisedElement);
        realisePreModifiers(phrase, parent, realisedElement);
        realiseHeadNoun(phrase, parent, realisedElement);
View Full Code Here

      List<NLGElement> children = element.getChildren();
      ((DocumentElement) element).setComponents(realise(children));
      realisedElement = element;

    } else if (element instanceof ListElement) {
      realisedElement = new ListElement();
      ((ListElement) realisedElement).addComponents(realise(element
          .getChildren()));

    } else if (element instanceof CoordinatedPhraseElement) {
      List<NLGElement> children = element.getChildren();
View Full Code Here

TOP

Related Classes of simplenlg.framework.ListElement

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.