コード例 #1
0
        /**
         * Creates a stack of verbs for the verb phrase. Additional auxiliary verbs
         * are added as required based on the features of the verb 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.
         * @return the verb group as a <code>Stack</code> of <code>NLGElement</code>
         *         s.
         */

        public static Stack <INLGElement> createVerbGroup(
            SyntaxProcessor parent, PhraseElement phrase)
        {
            string actualModal   = null;
            var    formValue     = phrase.getFeature(Feature.FORM.ToString());
            Tense  tenseValue    = phrase.getFeatureTense(Feature.TENSE.ToString());
            var    modal         = phrase.getFeatureAsString(Feature.MODAL.ToString());
            var    modalPast     = false;
            var    vgComponents  = new Stack <INLGElement>();
            var    interrogative = phrase.hasFeature(Feature.INTERROGATIVE_TYPE.ToString());

            if (Form.GERUND.Equals(formValue) || Form.INFINITIVE.Equals(formValue))
            {
                tenseValue = Tense.PRESENT;
            }

            if (Form.INFINITIVE.Equals(formValue))
            {
                actualModal = "to";
            }
            else if (formValue == null || Form.NORMAL.Equals(formValue))
            {
                if (Tense.FUTURE.Equals(tenseValue) &&
                    modal == null &&
                    ((!(phrase.getHead() is CoordinatedPhraseElement)) || (phrase
                                                                           .getHead() is CoordinatedPhraseElement &&
                                                                           interrogative)))
                {
                    actualModal = "will";
                }
                else if (modal != null)
                {
                    actualModal = modal;

                    if (Tense.PAST.Equals(tenseValue))
                    {
                        modalPast = true;
                    }
                }
            }

            pushParticles(phrase, parent, vgComponents);
            var frontVG = grabHeadVerb(phrase, tenseValue, modal != null);

            checkImperativeInfinitive(formValue, frontVG);

            if (phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
            {
                frontVG = addBe(frontVG, vgComponents, Form.PAST_PARTICIPLE);
            }

            if (phrase.getFeatureAsBoolean(Feature.PROGRESSIVE.ToString()))
            {
                frontVG = addBe(frontVG, vgComponents, Form.PRESENT_PARTICIPLE);
            }

            if (phrase.getFeatureAsBoolean(Feature.PERFECT.ToString()) ||
                modalPast)
            {
                frontVG = addHave(frontVG, vgComponents, modal, tenseValue);
            }

            frontVG = pushIfModal(actualModal != null, phrase, frontVG,
                                  vgComponents);
            frontVG = createNot(phrase, vgComponents, frontVG, modal != null);

            if (frontVG != null)
            {
                pushFrontVerb(phrase, vgComponents, frontVG, formValue,
                              interrogative);
            }

            pushModal(actualModal, phrase, vgComponents);
            return(vgComponents);
        }