Ejemplo n.º 1
0
        /**
         * Realises the complements of this phrase.
         *
         * @param parent
         *            the parent <code>SyntaxProcessor</code> that will do the
         *            realisation of the complementiser.
         * @param phrase
         *            the <code>PhraseElement</code> representing this noun phrase.
         * @param realisedElement
         *            the current realisation of the noun phrase.
         */

        private static void realiseComplements(SyntaxProcessor parent,
                                               PhraseElement phrase, ListElement realisedElement)
        {
            var indirects = new ListElement();
            var directs   = new ListElement();
            var unknowns  = new ListElement();

            foreach (INLGElement complement in phrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS.ToString()))
            {
                var discourseValue = complement
                                     .getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());
                var currentElement = parent.realise(complement);
                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                              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 (!InterrogativeTypeExtensions.isIndirectObject(phrase
                                                              .getFeature(Feature.INTERROGATIVE_TYPE.ToString())))
            {
                realisedElement.addComponents(indirects.getChildren());
            }
            if (!phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
            {
                if (!InterrogativeTypeExtensions.isAndObject(phrase
                                                             .getFeature(Feature.INTERROGATIVE_TYPE.ToString())))
                {
                    realisedElement.addComponents(directs.getChildren());
                }
                realisedElement.addComponents(unknowns.getChildren());
            }
        }
Ejemplo n.º 2
0
        /**
         * Iterates through a <code>List</code> of <code>NLGElement</code>s
         * realisation each element and adding it to the on-going realisation of
         * this clause.
         *
         * @param parent
         *            the parent <code>SyntaxProcessor</code> that will do the
         *            realisation of the complementiser.
         * @param realisedElement
         *            the current realisation of the clause.
         * @param elementList
         *            the <code>List</code> of <code>NLGElement</code>s to be
         *            realised.
         * @param function
         *            the <code>DiscourseFunction</code> each element in the list is
         *            to take. If this is <code>null</code> then the function is not
         *            set and any existing discourse function is kept.
         */

        public static void realiseList(SyntaxProcessor parent,
                                       ListElement realisedElement, List <INLGElement> elementList,
                                       DiscourseFunction function)
        {
            // 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.
            var         realisedList   = new ListElement();
            INLGElement currentElement = null;

            foreach (var eachElement in elementList)
            {
                currentElement = parent.realise(eachElement);

                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                              function);

                    if (eachElement.getFeatureAsBoolean(Feature.APPOSITIVE.ToString()))
                    {
                        currentElement.setFeature(Feature.APPOSITIVE.ToString(), true);
                    }

                    // realisedElement.addComponent(currentElement);
                    realisedList.addComponent(currentElement);
                }
            }

            if (!realisedList.getChildren().isEmpty())
            {
                realisedElement.addComponent(realisedList);
            }
        }