Exemple #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>.
         */

        public static INLGElement realise(SyntaxProcessor parent, PhraseElement phrase)
        {
            ListElement realisedElement = null;

            if (phrase != null &&
                !phrase.getFeatureAsBoolean(Feature.ELIDED.ToString()))
            {
                realisedElement = new ListElement();

                if (phrase.getFeatureAsBoolean(Feature.PRONOMINAL.ToString()))
                {
                    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.ToString()),
                                             DiscourseFunction.COMPLEMENT);

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

            return(realisedElement);
        }
Exemple #2
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)
        {
            INLGElement specifierElement = phrase
                                           .getFeatureAsElement(InternalFeature.SPECIFIER.ToString());

            if (specifierElement != null &&
                !phrase.getFeatureAsBoolean(InternalFeature.RAISED.ToString()) &&
                !phrase.getFeatureAsBoolean(Feature.ELIDED.ToString()))
            {
                if (!specifierElement.isA(LexicalCategoryEnum.PRONOUN) &&
                    specifierElement.getCategory().enumType != (int)PhraseCategoryEnum.NOUN_PHRASE)
                {
                    specifierElement.setFeature(Feature.NUMBER.ToString(), phrase
                                                .getFeature(Feature.NUMBER.ToString()));
                }

                var currentElement = parent.realise(specifierElement);

                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                              DiscourseFunction.SPECIFIER);
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Exemple #3
0
        /**
         * Realises the subjects of a passive 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 addPassiveSubjects(PhraseElement phrase,
                                               SyntaxProcessor parent,
                                               ListElement realisedElement,
                                               NLGFactory phraseFactory)
        {
            INLGElement currentElement = null;

            if (phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
            {
                var allSubjects = phrase.getFeatureAsElementList(InternalFeature.SUBJECTS.ToString());

                if (allSubjects.size() > 0 || phrase.hasFeature(Feature.INTERROGATIVE_TYPE.ToString()))
                {
                    realisedElement.addComponent(parent.realise(phraseFactory.createPrepositionPhrase("by")));
                }

                foreach (var subject in allSubjects)
                {
                    subject.setFeature(Feature.PASSIVE.ToString(), true);
                    if (subject.isA(PhraseCategoryEnum.NOUN_PHRASE) || subject is CoordinatedPhraseElement)
                    {
                        currentElement = parent.realise(subject);
                        if (currentElement != null)
                        {
                            currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.SUBJECT);
                            realisedElement.addComponent(currentElement);
                        }
                    }
                }
            }
        }
Exemple #4
0
        /**
         * Pushes the modal onto the stack of verb components.
         *
         * @param actualModal
         *            the modal to be used.
         * @param phrase
         *            the <code>PhraseElement</code> representing this noun phrase.
         * @param vgComponents
         *            the stack of verb components in the verb group.
         */

        private static void pushModal(string actualModal, PhraseElement phrase,
                                      Stack <INLGElement> vgComponents)
        {
            if (actualModal != null &&
                !phrase.getFeatureAsBoolean(InternalFeature.IGNORE_MODAL.ToString())
                )
            {
                vgComponents.push(new InflectedWordElement(actualModal,
                                                           new LexicalCategory_MODAL()));
            }
        }
Exemple #5
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);
                }
            }
        }
Exemple #6
0
        /**
         * Adds the subjects to the beginning of the clause unless the clause is
         * infinitive, imperative or passive, or the subjects split the verb.
         *
         * @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 splitVerb
         *            an <code>NLGElement</code> representing the subjects that
         *            should split the verb
         */

        private static void addSubjectsToFront(PhraseElement phrase,
                                               SyntaxProcessor parent,
                                               ListElement realisedElement,
                                               INLGElement splitVerb)
        {
            if (!Form.INFINITIVE.Equals(phrase.getFeature(Feature.FORM.ToString())) &&
                !Form.IMPERATIVE.Equals(phrase.getFeature(Feature.FORM.ToString())) &&
                !phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()) && splitVerb == null)
            {
                realisedElement.addComponents(realiseSubjects(phrase, parent).getChildren());
            }
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
Exemple #9
0
        /**
         * Adds <em>not</em> to the stack if the phrase is negated.
         *
         * @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 hasModal
         *            the phrase has a modal
         * @return the new element for the front of the group.
         */

        private static INLGElement createNot(PhraseElement phrase,
                                             Stack <INLGElement> vgComponents, INLGElement frontVG, bool hasModal)
        {
            var newFront = frontVG;

            if (phrase.getFeatureAsBoolean(Feature.NEGATED.ToString()))
            {
                var factory = phrase.getFactory();

                // before adding "do", check if this is an object WH
                // interrogative
                // in which case, don't add anything as it's already done by
                // ClauseHelper
                var interrType = phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString());
                var addDo      = !(InterrogativeType.WHAT_OBJECT.Equals(interrType) || InterrogativeType.WHO_OBJECT
                                   .Equals(interrType));

                if (!vgComponents.empty() || frontVG != null && isCopular(frontVG))
                {
                    vgComponents.push(new InflectedWordElement(
                                          "not", new LexicalCategory_ADVERB()));
                }
                else
                {
                    if (frontVG != null && !hasModal)
                    {
                        frontVG.setFeature(Feature.NEGATED.ToString(), true);
                        vgComponents.push(frontVG);
                    }

                    vgComponents.push(new InflectedWordElement(
                                          "not", new LexicalCategory_ADVERB()));

                    if (addDo)
                    {
                        if (factory != null)
                        {
                            newFront = factory.createInflectedWord("do",
                                                                   new LexicalCategory_VERB());
                        }
                        else
                        {
                            newFront = new InflectedWordElement(
                                "do", new LexicalCategory_VERB());
                        }
                    }
                }
            }

            return(newFront);
        }
Exemple #10
0
        /**
         * Checks to see if this clause is a subordinate clause. If it is then the
         * complementiser is added as a component to the realised element
         * <b>unless</b> the complementiser has been suppressed.
         *
         * @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.
         */

        private static void addComplementiser(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement)
        {
            INLGElement currentElement;

            if (ClauseStatus.SUBORDINATE.Equals(phrase.getFeature(InternalFeature.CLAUSE_STATUS.ToString())) &&
                !phrase.getFeatureAsBoolean(Feature.SUPRESSED_COMPLEMENTISER.ToString()))
            {
                currentElement = parent.realise(phrase.getFeatureAsElement(Feature.COMPLEMENTISER.ToString()));

                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Exemple #11
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);
        }
Exemple #12
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());
            }
        }
Exemple #13
0
        /**
         * Pushes the front verb on to the stack if the phrase has a modal.
         *
         * @param hasModal
         *            the phrase has a modal
         * @param phrase
         *            the <code>PhraseElement</code> representing this noun phrase.
         * @param frontVG
         *            the first verb in the verb group.
         * @param vgComponents
         *            the stack of verb components in the verb group.
         * @return the new element for the front of the group.
         */

        private static INLGElement pushIfModal(bool hasModal,
                                               PhraseElement phrase, INLGElement frontVG,
                                               Stack <INLGElement> vgComponents)
        {
            var newFront = frontVG;

            if (hasModal &&
                !phrase.getFeatureAsBoolean(InternalFeature.IGNORE_MODAL.ToString())
                )
            {
                if (frontVG != null)
                {
                    frontVG.setFeature(InternalFeature.NON_MORPH.ToString(), true);
                    vgComponents.push(frontVG);
                }
                newFront = null;
            }
            return(newFront);
        }
Exemple #14
0
        /**
         * Realises the subjects for the 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.
         */

        private static ListElement realiseSubjects(PhraseElement phrase, SyntaxProcessor parent)
        {
            INLGElement currentElement  = null;
            var         realisedElement = new ListElement();

            foreach (INLGElement subject in phrase.getFeatureAsElementList(InternalFeature.SUBJECTS.ToString()))
            {
                subject.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(), DiscourseFunction.SUBJECT);
                if (Form.GERUND.Equals(phrase.getFeature(Feature.FORM.ToString())) &&
                    !phrase.getFeatureAsBoolean(Feature.SUPPRESS_GENITIVE_IN_GERUND.ToString()))
                {
                    subject.setFeature(Feature.POSSESSIVE.ToString(), true);
                }
                currentElement = parent.realise(subject);
                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
            return(realisedElement);
        }
Exemple #15
0
        /**
         * Controls the realisation of <em>wh</em> object questions.
         *
         * @param keyword
         *            the wh word
         * @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 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 realiseObjectWHInterrogative(string keyword,
                                                                PhraseElement phrase,
                                                                SyntaxProcessor parent,
                                                                ListElement realisedElement,
                                                                NLGFactory phraseFactory)
        {
            INLGElement splitVerb = null;

            realiseInterrogativeKeyWord(keyword, new LexicalCategory_PRONOUN(), parent, realisedElement,
                                        phraseFactory);

            // if (!Tense.FUTURE.Equals(phrase.getFeature(Feature.TENSE)) &&
            // !copular) {
            if (!hasAuxiliary(phrase) && !VerbPhraseHelper.isCopular(phrase))
            {
                addDoAuxiliary(phrase, parent, phraseFactory, realisedElement);
            }
            else if (!phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
            {
                splitVerb = realiseSubjects(phrase, parent);
            }

            return(splitVerb);
        }
Exemple #16
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())));
        }
Exemple #17
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);
        }
Exemple #18
0
        /**
         * Realises the complements of passive clauses; also sets number, person for
         * passive
         *
         * @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 verbElement
         *            the <code>NLGElement</code> representing the verb phrase for
         *            this clause.
         */

        private static INLGElement addPassiveComplementsNumberPerson(PhraseElement phrase,
                                                                     SyntaxProcessor parent,
                                                                     ListElement realisedElement,
                                                                     INLGElement verbElement)
        {
            object      passiveNumber  = null;
            object      passivePerson  = null;
            INLGElement currentElement = null;
            INLGElement splitVerb      = null;
            var         verbPhrase     = phrase.getFeatureAsElement(InternalFeature.VERB_PHRASE.ToString());

            // count complements to set plural feature if more than one
            var numComps  = 0;
            var coordSubj = false;

            if (phrase.getFeatureAsBoolean(Feature.PASSIVE.ToString()) && verbPhrase != null &&
                !InterrogativeType.WHAT_OBJECT.Equals(phrase.getFeature(Feature.INTERROGATIVE_TYPE.ToString())))
            {
                // complements of a clause are stored in the VPPhraseSpec
                foreach (var subject in verbPhrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS.ToString()))
                {
                    // AG: complement needn't be an NP
                    // subject.isA(PhraseCategory.NOUN_PHRASE) &&
                    if (DiscourseFunction.OBJECT.Equals(subject.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString())))
                    {
                        subject.setFeature(Feature.PASSIVE.ToString(), true);
                        numComps++;
                        currentElement = parent.realise(subject);

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

                            if (phrase.hasFeature(Feature.INTERROGATIVE_TYPE.ToString()))
                            {
                                splitVerb = currentElement;
                            }
                            else
                            {
                                realisedElement.addComponent(currentElement);
                            }
                        }

                        // flag if passive subject is coordinated with an "and"
                        if (!coordSubj && subject is CoordinatedPhraseElement)
                        {
                            var conj = ((CoordinatedPhraseElement)subject).getConjunction();
                            coordSubj = (conj != null && conj.Equals("and"));
                        }

                        if (passiveNumber == null)
                        {
                            passiveNumber = subject.getFeature(Feature.NUMBER.ToString());
                        }
                        else
                        {
                            passiveNumber = NumberAgreement.PLURAL;
                        }

                        if (Person.FIRST.Equals(subject.getFeature(Feature.PERSON.ToString())))
                        {
                            passivePerson = Person.FIRST;
                        }
                        else if (Person.SECOND.Equals(subject.getFeature(Feature.PERSON.ToString())) &&
                                 !Person.FIRST.Equals(passivePerson))
                        {
                            passivePerson = Person.SECOND;
                        }
                        else if (passivePerson == null)
                        {
                            passivePerson = Person.THIRD;
                        }

                        if (Form.GERUND.Equals(phrase.getFeature(Feature.FORM.ToString())) &&
                            !phrase.getFeatureAsBoolean(Feature.SUPPRESS_GENITIVE_IN_GERUND.ToString()))
                        {
                            subject.setFeature(Feature.POSSESSIVE.ToString(), true);
                        }
                    }
                }
            }

            if (verbElement != null)
            {
                if (passivePerson != null)
                {
                    verbElement.setFeature(Feature.PERSON.ToString(), passivePerson);
                    // below commented out. for non-passive, number and person set
                    // by checkSubjectNumberPerson
                    // } else {
                    // verbElement.setFeature(Feature.PERSON, phrase
                    // .getFeature(Feature.PERSON));
                }

                if (numComps > 1 || coordSubj)
                {
                    verbElement.setFeature(Feature.NUMBER.ToString(), NumberAgreement.PLURAL);
                }
                else if (passiveNumber != null)
                {
                    verbElement.setFeature(Feature.NUMBER.ToString(), passiveNumber);
                }
            }
            return(splitVerb);
        }