Ejemplo n.º 1
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)
        {
            NLGElement currentElement = null;

            if (phrase.getFeatureAsBoolean(Feature.PASSIVE))
            {
                IList <NLGElement> allSubjects = phrase.getFeatureAsElementList(InternalFeature.SUBJECTS);

                if (allSubjects.Any() || phrase.hasFeature(Feature.INTERROGATIVE_TYPE))
                {
                    realisedElement.addComponent(parent.realise(phraseFactory.createPrepositionPhrase("by")));                     //$NON-NLS-1$
                }

                foreach (NLGElement subject in allSubjects)
                {
                    subject.setFeature(Feature.PASSIVE, true);
                    if (subject.isA(new PhraseCategory(PhraseCategory.PhraseCategoryEnum.NOUN_PHRASE)) || subject is CoordinatedPhraseElement)
                    {
                        currentElement = parent.realise(subject);
                        if (currentElement != null)
                        {
                            currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SUBJECT);
                            realisedElement.addComponent(currentElement);
                        }
                    }
                }
            }
        }
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.
         */
        internal static void realiseList(SyntaxProcessor parent, ListElement realisedElement, IList <NLGElement> 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.
            ListElement realisedList   = new ListElement();
            NLGElement  currentElement = null;

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

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

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

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

            if (realisedList.Children.Any())
            {
                realisedElement.addComponent(realisedList);
            }
        }
Ejemplo n.º 3
0
 /**
  * Adds <em>to</em> to the end of interrogatives concerning indirect
  * objects. For example, <em>who did John give the flower <b>to</b></em>.
  *
  * @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 addEndingTo(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement, NLGFactory phraseFactory)
 {
     if (InterrogativeType.WHO_INDIRECT_OBJECT.Equals(phrase.getFeature(Feature.INTERROGATIVE_TYPE)))
     {
         NLGElement word = phraseFactory.createWord("to", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PREPOSITION));                 //$NON-NLS-1$
         realisedElement.addComponent(parent.realise(word));
     }
 }
Ejemplo n.º 4
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");             //$NON-NLS-1$

            doPhrase.setFeature(Feature.TENSE, phrase.getFeature(Feature.TENSE));
            doPhrase.setFeature(Feature.PERSON, phrase.getFeature(Feature.PERSON));
            doPhrase.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER));
            realisedElement.addComponent(parent.realise(doPhrase));
        }
Ejemplo n.º 5
0
        /**
         * Realises the cue phrase for the clause if it exists.
         *
         * @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 addCuePhrase(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement)
        {
            NLGElement currentElement = parent.realise(phrase.getFeatureAsElement(Feature.CUE_PHRASE));

            if (currentElement != null)
            {
                currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.CUE_PHRASE);
                realisedElement.addComponent(currentElement);
            }
        }
Ejemplo n.º 6
0
        /**
         * Realises the key word of the interrogative. For example, <em>who</em>,
         * <em>what</em>
         *
         * @param keyWord
         *            the key word of the interrogative.
         * @param cat
         *            the category (usually pronoun, but not in the case of
         *            "how many")
         * @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 realiseInterrogativeKeyWord(string keyWord, LexicalCategory cat, SyntaxProcessor parent, ListElement realisedElement, NLGFactory phraseFactory)
        {
            if (!ReferenceEquals(keyWord, null))
            {
                NLGElement question       = phraseFactory.createWord(keyWord, cat);
                NLGElement currentElement = parent.realise(question);

                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Ejemplo n.º 7
0
        /**
         * Pushes the particles of the main verb onto the verb group stack.
         *
         * @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 vgComponents
         *            the stack of verb components in the verb group.
         */
        private static void pushParticles(PhraseElement phrase, SyntaxProcessor parent, Stack <NLGElement> vgComponents)
        {
            object particle = phrase.getFeature(Feature.PARTICLE);

            if (particle is string)
            {
                vgComponents.Push(new StringElement((string)particle));
            }
            else if (particle is NLGElement)
            {
                vgComponents.Push(parent.realise((NLGElement)particle));
            }
        }
Ejemplo n.º 8
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)
        {
            NLGElement currentElement;

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

                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Ejemplo n.º 9
0
        /**
         * Realises the verb part of 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.
         * @param splitVerb
         *            an <code>NLGElement</code> representing the subjects that
         *            should split the verb
         * @param verbElement
         *            the <code>NLGElement</code> representing the verb phrase for
         *            this clause.
         * @param whObj
         *            whether the VP is part of an object WH-interrogative
         */
        private static void realiseVerb(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement, NLGElement splitVerb, NLGElement verbElement, bool whObj)
        {
            setVerbFeatures(phrase, verbElement);

            NLGElement currentElement = parent.realise(verbElement);

            if (currentElement != null)
            {
                if (splitVerb == null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.VERB_PHRASE);

                    realisedElement.addComponent(currentElement);
                }
                else
                {
                    if (currentElement is ListElement)
                    {
                        IList <NLGElement> children = currentElement.Children;
                        currentElement = children[0];
                        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.VERB_PHRASE);
                        realisedElement.addComponent(currentElement);
                        realisedElement.addComponent(splitVerb);

                        for (int eachChild = 1; eachChild < children.Count; eachChild++)
                        {
                            currentElement = children[eachChild];
                            currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.VERB_PHRASE);
                            realisedElement.addComponent(currentElement);
                        }
                    }
                    else
                    {
                        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.VERB_PHRASE);

                        if (whObj)
                        {
                            realisedElement.addComponent(currentElement);
                            realisedElement.addComponent(splitVerb);
                        }
                        else
                        {
                            realisedElement.addComponent(splitVerb);
                            realisedElement.addComponent(currentElement);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /**
         * Realises the auxiliary verbs in the verb group.
         *
         * @param parent
         *            the parent <code>SyntaxProcessor</code> that will do the
         *            realisation of the complementiser.
         * @param realisedElement
         *            the current realisation of the noun phrase.
         * @param auxiliaryRealisation
         *            the stack of auxiliary verbs.
         */
        private static void realiseAuxiliaries(SyntaxProcessor parent, ListElement realisedElement, Stack <NLGElement> auxiliaryRealisation)
        {
            NLGElement aux            = null;
            NLGElement currentElement = null;

            while (auxiliaryRealisation.Any())
            {
                aux            = auxiliaryRealisation.Pop();
                currentElement = parent.realise(aux);
                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.AUXILIARY);
                }
            }
        }
Ejemplo n.º 11
0
        /**
         * Realises the main group of verbs in the 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 mainVerbRealisation
         *            the stack of the main verbs in the phrase.
         * @param realisedElement
         *            the current realisation of the noun phrase.
         */
        private static void realiseMainVerb(SyntaxProcessor parent, PhraseElement phrase, Stack <NLGElement> mainVerbRealisation, ListElement realisedElement)
        {
            NLGElement currentElement = null;
            NLGElement main           = null;

            while (mainVerbRealisation.Any())
            {
                main = mainVerbRealisation.Pop();
                main.setFeature(Feature.INTERROGATIVE_TYPE, phrase.getFeature(Feature.INTERROGATIVE_TYPE));
                currentElement = parent.realise(main);

                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Ejemplo n.º 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)
        {
            ListElement indirects      = new ListElement();
            ListElement directs        = new ListElement();
            ListElement unknowns       = new ListElement();
            object      discourseValue = null;
            NLGElement  currentElement = null;

            foreach (NLGElement complement in phrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS))
            {
                discourseValue = complement.getFeature(InternalFeature.DISCOURSE_FUNCTION);
                currentElement = parent.realise(complement);
                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.COMPLEMENT);

                    if (DiscourseFunction.INDIRECT_OBJECT.Equals(discourseValue))
                    {
                        indirects.addComponent(currentElement);
                    }
                    else if (DiscourseFunction.OBJECT.Equals(discourseValue))
                    {
                        directs.addComponent(currentElement);
                    }
                    else
                    {
                        unknowns.addComponent(currentElement);
                    }
                }
            }

            InterrogativeType?interrogativeType = (InterrogativeType?)phrase.getFeature(Feature.INTERROGATIVE_TYPE);

            if (interrogativeType == null || !((InterrogativeType)interrogativeType).isIndirectObject())
            {
                realisedElement.addComponents(indirects.Children);
            }
            if (!phrase.getFeatureAsBoolean(Feature.PASSIVE))
            {
                if (interrogativeType == null || !((InterrogativeType)interrogativeType).isObject())
                {
                    realisedElement.addComponents(directs.Children);
                }
                realisedElement.addComponents(unknowns.Children);
            }
        }
Ejemplo n.º 13
0
        /**
         * Adds the front modifiers to the end of the clause when dealing with
         * interrogatives.
         *
         * @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 addInterrogativeFrontModifiers(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement)
        {
            NLGElement currentElement = null;

            if (phrase.hasFeature(Feature.INTERROGATIVE_TYPE))
            {
                foreach (NLGElement subject in phrase.getFeatureAsElementList(InternalFeature.FRONT_MODIFIERS))
                {
                    currentElement = parent.realise(subject);
                    if (currentElement != null)
                    {
                        currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.FRONT_MODIFIER);

                        realisedElement.addComponent(currentElement);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /**
         * Realises the head element of the 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 realiseHead(SyntaxProcessor parent, PhraseElement phrase, ListElement realisedElement)
        {
            NLGElement head = phrase.getHead();

            if (head != null)
            {
                if (phrase.hasFeature(Feature.IS_COMPARATIVE))
                {
                    head.setFeature(Feature.IS_COMPARATIVE, phrase.getFeature(Feature.IS_COMPARATIVE));
                }
                else if (phrase.hasFeature(Feature.IS_SUPERLATIVE))
                {
                    head.setFeature(Feature.IS_SUPERLATIVE, phrase.getFeature(Feature.IS_SUPERLATIVE));
                }
                head = parent.realise(head);
                head.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.HEAD);
                realisedElement.addComponent(head);
            }
        }
Ejemplo n.º 15
0
        /**
         * Realises the head noun 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 realiseHeadNoun(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement)
        {
            NLGElement headElement = phrase.getHead();

            if (headElement != null)
            {
                headElement.setFeature(Feature.ELIDED, phrase.getFeature(Feature.ELIDED));
                headElement.setFeature(LexicalFeature.GENDER, phrase.getFeature(LexicalFeature.GENDER));
                headElement.setFeature(InternalFeature.ACRONYM, phrase.getFeature(InternalFeature.ACRONYM));
                headElement.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER));
                headElement.setFeature(Feature.PERSON, phrase.getFeature(Feature.PERSON));
                headElement.setFeature(Feature.POSSESSIVE, phrase.getFeature(Feature.POSSESSIVE));
                headElement.setFeature(Feature.PASSIVE, phrase.getFeature(Feature.PASSIVE));
                headElement.setFeature(Feature.IS_CAPITALIZED, phrase.getFeature(Feature.IS_CAPITALIZED));
                NLGElement currentElement = parent.realise(headElement);
                currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SUBJECT);
                realisedElement.addComponent(currentElement);
            }
        }
Ejemplo n.º 16
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)
        {
            NLGElement  currentElement  = null;
            ListElement realisedElement = new ListElement();

            foreach (NLGElement subject in phrase.getFeatureAsElementList(InternalFeature.SUBJECTS))
            {
                subject.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SUBJECT);
                if (Form.GERUND.Equals(phrase.getFeature(Feature.FORM)) && !phrase.getFeatureAsBoolean(Feature.SUPPRESS_GENITIVE_IN_GERUND))
                {
                    subject.setFeature(Feature.POSSESSIVE, true);
                }
                currentElement = parent.realise(subject);
                if (currentElement != null)
                {
                    realisedElement.addComponent(currentElement);
                }
            }
            return(realisedElement);
        }
Ejemplo n.º 17
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)
        {
            NLGElement specifierElement = phrase.getFeatureAsElement(InternalFeature.SPECIFIER);

            if (specifierElement != null && !phrase.getFeatureAsBoolean(InternalFeature.RAISED) && !phrase.getFeatureAsBoolean(Feature.ELIDED))
            {
                if (!specifierElement.isA(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN)) && specifierElement.Category != PhraseCategory.PhraseCategoryEnum.NOUN_PHRASE)
                {
                    specifierElement.setFeature(Feature.NUMBER, phrase.getFeature(Feature.NUMBER));
                }

                NLGElement currentElement = parent.realise(specifierElement);

                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SPECIFIER);
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Ejemplo n.º 18
0
        /**
         * Realises the complements of the phrase adding <em>and</em> where
         * appropriate.
         *
         * @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)
        {
            bool       firstProcessed = false;
            NLGElement currentElement = null;

            foreach (NLGElement complement in phrase.getFeatureAsElementList(InternalFeature.COMPLEMENTS))
            {
                currentElement = parent.realise(complement);
                if (currentElement != null)
                {
                    currentElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.COMPLEMENT);
                    if (firstProcessed)
                    {
                        realisedElement.addComponent(new InflectedWordElement("and", new LexicalCategory(LexicalCategory.LexicalCategoryEnum.CONJUNCTION)));                         //$NON-NLS-1$
                    }
                    else
                    {
                        firstProcessed = true;
                    }
                    realisedElement.addComponent(currentElement);
                }
            }
        }
Ejemplo n.º 19
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 NLGElement addPassiveComplementsNumberPerson(PhraseElement phrase, SyntaxProcessor parent, ListElement realisedElement, NLGElement verbElement)
        {
            object     passiveNumber  = null;
            object     passivePerson  = null;
            NLGElement currentElement = null;
            NLGElement splitVerb      = null;
            NLGElement verbPhrase     = phrase.getFeatureAsElement(InternalFeature.VERB_PHRASE);

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

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

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

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

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

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

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

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

            if (verbElement != null)
            {
                if (passivePerson != null)
                {
                    verbElement.setFeature(Feature.PERSON, 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, NumberAgreement.PLURAL);
                }
                else if (passiveNumber != null)
                {
                    verbElement.setFeature(Feature.NUMBER, passiveNumber);
                }
            }
            return(splitVerb);
        }
Ejemplo n.º 20
0
        /**
         * The main method for realising coordinated phrases.
         *
         * @param parent
         *            the <code>SyntaxProcessor</code> that called this method.
         * @param phrase
         *            the <code>CoordinatedPhrase</code> to be realised.
         * @return the realised <code>NLGElement</code>.
         */
        internal static NLGElement realise(SyntaxProcessor parent, CoordinatedPhraseElement phrase)
        {
            ListElement realisedElement = null;

            if (phrase != null)
            {
                realisedElement = new ListElement();
                PhraseHelper.realiseList(parent, realisedElement, phrase.PreModifiers, DiscourseFunction.PRE_MODIFIER);

                CoordinatedPhraseElement coordinated = new CoordinatedPhraseElement();

                IList <NLGElement> children    = phrase.Children;
                string             conjunction = phrase.getFeatureAsString(Feature.CONJUNCTION);
                coordinated.setFeature(Feature.CONJUNCTION, conjunction);
                coordinated.setFeature(Feature.CONJUNCTION_TYPE, phrase.getFeature(Feature.CONJUNCTION_TYPE));

                InflectedWordElement conjunctionElement = null;

                if (children != null && children.Any())
                {
                    if (phrase.getFeatureAsBoolean(Feature.RAISE_SPECIFIER))
                    {
                        raiseSpecifier(children);
                    }

                    NLGElement child = phrase.LastCoordinate;
                    child.setFeature(Feature.POSSESSIVE, phrase.getFeature(Feature.POSSESSIVE));

                    child = children[0];

                    setChildFeatures(phrase, child);

                    coordinated.addCoordinate(parent.realise(child));
                    for (int index = 1; index < children.Count; index++)
                    {
                        child = children[index];
                        setChildFeatures(phrase, child);
                        if (phrase.getFeatureAsBoolean(Feature.AGGREGATE_AUXILIARY))
                        {
                            child.setFeature(InternalFeature.REALISE_AUXILIARY, false);
                        }

                        if (child.isA(new PhraseCategory(PhraseCategory.PhraseCategoryEnum.CLAUSE)))
                        {
                            child.setFeature(Feature.SUPRESSED_COMPLEMENTISER, phrase.getFeature(Feature.SUPRESSED_COMPLEMENTISER));
                        }

                        //skip conjunction if it's null or empty string
                        if (!ReferenceEquals(conjunction, null) && conjunction.Length > 0)
                        {
                            conjunctionElement = new InflectedWordElement(conjunction, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.CONJUNCTION));
                            conjunctionElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.CONJUNCTION);
                            coordinated.addCoordinate(conjunctionElement);
                        }

                        coordinated.addCoordinate(parent.realise(child));
                    }
                    realisedElement.addComponent(coordinated);
                }

                PhraseHelper.realiseList(parent, realisedElement, phrase.PostModifiers, DiscourseFunction.POST_MODIFIER);
                PhraseHelper.realiseList(parent, realisedElement, phrase.Complements, DiscourseFunction.COMPLEMENT);
            }
            return(realisedElement);
        }