コード例 #1
0
  /**
   * The main method for realising noun phrases.
   *
   * @param parent the <code>SyntaxProcessor</code> that called this method.
   * @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);
        PhraseHelper.realiseList(
            parent,
            realisedElement,
            phrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS),
            DiscourseFunction.COMPLEMENT);

        PhraseHelper.realiseList(
            parent, realisedElement, phrase.getPostModifiers(), DiscourseFunction.POST_MODIFIER);
      }
    }

    return realisedElement;
  }
コード例 #2
0
  /**
   * Realises the pre-modifiers of the noun phrase. Before being realised, pre-modifiers undergo
   * some basic sorting based on adjective ordering.
   *
   * @param phrase the <code>PhraseElement</code> representing this noun phrase.
   * @param parent the parent <code>SyntaxProcessor</code> that will do the realisation of the
   *     complementiser.
   * @param realisedElement the current realisation of the noun phrase.
   */
  private static void realisePreModifiers(
      PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement) {

    List<NLGElement> preModifiers = phrase.getPreModifiers();
    if (phrase.getFeatureAsBoolean(Feature.ADJECTIVE_ORDERING).booleanValue()) {
      preModifiers = sortNPPreModifiers(preModifiers);
    }
    PhraseHelper.realiseList(parent, realisedElement, preModifiers, DiscourseFunction.PRE_MODIFIER);
  }
コード例 #3
0
  /**
   * Realises the specifier of the noun phrase.
   *
   * @param phrase the <code>PhraseElement</code> representing this noun phrase.
   * @param parent the parent <code>SyntaxProcessor</code> that will do the realisation of the
   *     complementiser.
   * @param realisedElement the current realisation of the noun phrase.
   */
  private static void realiseSpecifier(
      PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement) {
    NLGElement specifierElement = phrase.getFeatureAsElement(InternalFeature.SPECIFIER);

    if (specifierElement != null
        && !phrase.getFeatureAsBoolean(InternalFeature.RAISED).booleanValue()
        && !phrase.getFeatureAsBoolean(Feature.ELIDED).booleanValue()) {

      if (!specifierElement.isA(LexicalCategory.PRONOUN)) {
        specifierElement.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER));
      }

      NLGElement currentElement = parent.realise(specifierElement);

      if (currentElement != null) {
        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SPECIFIER);
        realisedElement.addComponent(currentElement);
      }
    }
  }