예제 #1
0
        /**
         * Adds a <em>do</em> verb to the realisation of this clause.
         *
         * @param phrase
         *            the <code>PhraseElement</code> representing 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 phraseFactory
         *            the phrase factory to be used.
         */

        private static void addDoAuxiliary(PhraseElement phrase,
                                           SyntaxProcessor parent,
                                           NLGFactory phraseFactory,
                                           ListElement realisedElement)
        {
            PhraseElement doPhrase = phraseFactory.createVerbPhrase("do");

            doPhrase.setFeature(Feature.TENSE.ToString(), phrase.getFeatureTense(Feature.TENSE.ToString()));
            doPhrase.setFeature(Feature.PERSON.ToString(), phrase.getFeature(Feature.PERSON.ToString()));
            doPhrase.setFeature(Feature.NUMBER.ToString(), phrase.getFeature(Feature.NUMBER.ToString()));
            realisedElement.addComponent(parent.realise(doPhrase));
        }
예제 #2
0
        /**
         * Pushes the front verb onto the stack of verb components.
         *
         * @param phrase
         *            the <code>PhraseElement</code> representing this noun phrase.
         * @param vgComponents
         *            the stack of verb components in the verb group.
         * @param frontVG
         *            the first verb in the verb group.
         * @param formValue
         *            the <code>Form</code> of the phrase.
         * @param interrogative
         *            <code>true</code> if the phrase is interrogative.
         */

        private static void pushFrontVerb(PhraseElement phrase,
                                          Stack <INLGElement> vgComponents, INLGElement frontVG,
                                          object formValue, bool interrogative)
        {
            var interrogType = phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString());

            if (Form.GERUND.Equals(formValue))
            {
                frontVG.setFeature(Feature.FORM.ToString(), Form.PRESENT_PARTICIPLE);
                vgComponents.push(frontVG);
            }
            else if (Form.PAST_PARTICIPLE.Equals(formValue))
            {
                frontVG.setFeature(Feature.FORM.ToString(), Form.PAST_PARTICIPLE);
                vgComponents.push(frontVG);
            }
            else if (Form.PRESENT_PARTICIPLE.Equals(formValue))
            {
                frontVG.setFeature(Feature.FORM.ToString(), Form.PRESENT_PARTICIPLE);
                vgComponents.push(frontVG);
            }
            else if ((!(formValue == null || Form.NORMAL.Equals(formValue)) || interrogative) &&
                     !isCopular(phrase.getHead()) && vgComponents.isEmpty())
            {
                // AG: fix below: if interrogative, only set non-morph feature in
                // case it's not WHO_SUBJECT OR WHAT_SUBJECT
                if (!(InterrogativeType.WHO_SUBJECT.Equals(interrogType) || InterrogativeType.WHAT_SUBJECT
                      .Equals(interrogType)))
                {
                    frontVG.setFeature(InternalFeature.NON_MORPH.ToString(), true);
                }

                vgComponents.push(frontVG);
            }
            else
            {
                var numToUse = determineNumber(phrase.getParent(),
                                               phrase);
                frontVG.setFeature(Feature.TENSE.ToString(), phrase.getFeatureTense(Feature.TENSE.ToString()));
                frontVG.setFeature(Feature.PERSON.ToString(), phrase
                                   .getFeature(Feature.PERSON.ToString()));
                frontVG.setFeature(Feature.NUMBER.ToString(), numToUse);

                //don't push the front VG if it's a negated interrogative WH object question
                if (!(phrase.getFeatureAsBoolean(Feature.NEGATED.ToString()) && (InterrogativeType.WHO_OBJECT
                                                                                 .Equals(interrogType) ||
                                                                                 InterrogativeType.WHAT_OBJECT
                                                                                 .Equals(interrogType))))
                {
                    vgComponents.push(frontVG);
                }
            }
        }
예제 #3
0
        /**
         * Performs the realisation for YES/NO types of questions. This may involve
         * adding an optional <em>do</em> auxiliary verb to the beginning of the
         * clause. The method also determines if there is a subject that will split
         * the verb group of the clause. For example, the clause
         * <em>the man <b>should give</b> the woman the flower</em> has the verb
         * group indicated in <b>bold</b>. The phrase is rearranged as yes/no
         * question as
         * <em><b>should</b> the man <b>give</b> the woman the flower</em> with the
         * subject <em>the man</em> splitting the verb group.
         *
         *
         * @param phrase
         *            the <code>PhraseElement</code> representing 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 phraseFactory
         *            the phrase factory to be used.
         * @param verbElement
         *            the <code>NLGElement</code> representing the verb phrase for
         *            this clause.
         * @param subjects
         *            the <code>List</code> of subjects in the clause.
         * @return an <code>NLGElement</code> representing a subject that should
         *         split the verb
         */

        private static INLGElement realiseYesNo(PhraseElement phrase,
                                                SyntaxProcessor parent,
                                                INLGElement verbElement,
                                                NLGFactory phraseFactory,
                                                ListElement realisedElement)
        {
            INLGElement splitVerb = null;

            if (!(verbElement is VPPhraseSpec && VerbPhraseHelper.isCopular(((VPPhraseSpec)verbElement).getVerb())) &&
                !phrase.getFeatureAsBoolean(Feature.PROGRESSIVE.ToString()) && !phrase.hasFeature(Feature.MODAL.ToString()) &&
                !Tense.FUTURE.Equals(phrase.getFeatureTense(Feature.TENSE.ToString())) &&
                !phrase.getFeatureAsBoolean(Feature.NEGATED.ToString()) &&
                !phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
            {
                addDoAuxiliary(phrase, parent, phraseFactory, realisedElement);
            }
            else
            {
                splitVerb = realiseSubjects(phrase, parent);
            }
            return(splitVerb);
        }
예제 #4
0
        /*
         * Check if a sentence has an auxiliary (needed to relise questions
         * correctly)
         */

        private static bool hasAuxiliary(PhraseElement phrase)
        {
            return(phrase.hasFeature(Feature.MODAL.ToString()) || phrase.getFeatureAsBoolean(Feature.PERFECT.ToString()) ||
                   phrase.getFeatureAsBoolean(Feature.PROGRESSIVE.ToString()) ||
                   Tense.FUTURE.Equals(phrase.getFeatureTense(Feature.TENSE.ToString())));
        }
예제 #5
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);
        }