Esempio n. 1
0
        /**
         * The main method for realising verb 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>.
         */

        public static INLGElement realise(SyntaxProcessor parent, PhraseElement phrase)
        {
            ListElement realisedElement      = null;
            var         mainVerbRealisation  = new Stack <INLGElement>();
            var         auxiliaryRealisation = new Stack <INLGElement>();

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

                realisedElement = new ListElement();

                if (!phrase.hasFeature(InternalFeature.REALISE_AUXILIARY.ToString()) ||
                    phrase.getFeatureAsBoolean(
                        InternalFeature.REALISE_AUXILIARY.ToString()))
                {
                    realiseAuxiliaries(parent, realisedElement,
                                       auxiliaryRealisation);

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

                    realiseMainVerb(parent, phrase, mainVerbRealisation,
                                    realisedElement);
                }
                else if (isCopular(phrase.getHead()))
                {
                    realiseMainVerb(parent, phrase, mainVerbRealisation,
                                    realisedElement);
                    PhraseHelper.realiseList(parent, realisedElement, phrase
                                             .getPreModifiers(), DiscourseFunction.PRE_MODIFIER);
                }
                else
                {
                    PhraseHelper.realiseList(parent, realisedElement, phrase
                                             .getPreModifiers(), DiscourseFunction.PRE_MODIFIER);
                    realiseMainVerb(parent, phrase, mainVerbRealisation,
                                    realisedElement);
                }
                realiseComplements(parent, phrase, realisedElement);
                PhraseHelper.realiseList(parent, realisedElement, phrase
                                         .getPostModifiers(), DiscourseFunction.POST_MODIFIER);
            }

            return(realisedElement);
        }
Esempio n. 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)
        {
            var preModifiers = phrase.getPreModifiers();

            if (phrase.getFeatureAsBoolean(Feature.ADJECTIVE_ORDERING.ToString())
                )
            {
                preModifiers = sortNPPreModifiers(preModifiers);
            }
            PhraseHelper.realiseList(parent, realisedElement, preModifiers,
                                     DiscourseFunction.PRE_MODIFIER);
        }
Esempio n. 3
0
        /**
         * The main method for realising 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>.
         */

        public static INLGElement 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);
                realiseComplements(parent, phrase, realisedElement);

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

            return(realisedElement);
        }