예제 #1
0
        /**
         * <p>
         * Adds a new complement to the phrase element. Complements will be realised
         * in the syntax after the head element of the phrase. Complements differ
         * from post-modifiers in that complements are crucial to the understanding
         * of a phrase whereas post-modifiers are optional.
         * </p>
         *
         * <p>
         * If the new complement being added is a <em>clause</em> or a
         * <code>CoordinatedPhraseElement</code> then its clause status feature is
         * set to <code>ClauseStatus.SUBORDINATE</code> and it's discourse function
         * is set to <code>DiscourseFunction.OBJECT</code> by default unless an
         * existing discourse function exists on the complement.
         * </p>
         *
         * <p>
         * Complements can have different functions. For example, the phrase <I>John
         * gave Mary a flower</I> has two complements, one a direct object and one
         * indirect. If a complement is not specified for its discourse function,
         * then this is automatically set to <code>DiscourseFunction.OBJECT</code>.
         * </p>
         *
         * @param newComplement
         *            the new complement as an <code>NLGElement</code>.
         */
        public virtual void addComplement(NLGElement newComplement)
        {
            IList <NLGElement> complements = getFeatureAsElementList(InternalFeature.COMPLEMENTS);

            if (complements == null)
            {
                complements = new List <NLGElement>();
            }

            // check if the new complement has a discourse function; if not, assume object
            if (!newComplement.hasFeature(InternalFeature.DISCOURSE_FUNCTION))
            {
                newComplement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT);
            }

            complements.Add(newComplement);
            setFeature(InternalFeature.COMPLEMENTS, complements);
            if (newComplement.isA(new PhraseCategory(PhraseCategory.PhraseCategoryEnum.CLAUSE)) || newComplement is CoordinatedPhraseElement)
            {
                newComplement.setFeature(InternalFeature.CLAUSE_STATUS, ClauseStatus.SUBORDINATE);

                if (!newComplement.hasFeature(InternalFeature.DISCOURSE_FUNCTION))
                {
                    newComplement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.OBJECT);
                }
            }
        }
예제 #2
0
        /**
         * Adds a new post-modifier to the phrase element. Post-modifiers will be
         * realised in the syntax after the complements.
         *
         * @param newPostModifier
         *            the new post-modifier as an <code>NLGElement</code>.
         */
        public virtual void addPostModifier(NLGElement newPostModifier)
        {
            IList <NLGElement> postModifiers = getFeatureAsElementList(InternalFeature.POSTMODIFIERS);

            if (postModifiers == null)
            {
                postModifiers = new List <NLGElement>();
            }
            newPostModifier.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.POST_MODIFIER);
            postModifiers.Add(newPostModifier);
            setFeature(InternalFeature.POSTMODIFIERS, postModifiers);
        }
예제 #3
0
        /**
         * A helper method to look up the lexicon for the given word.
         *
         * @param category
         *            the <code>LexicalCategory</code> of the word.
         * @param word
         *            the base form of the word.
         * @param wordElement
         *            the created element representing the word.
         */
        private void doLexiconLookUp(LexicalCategory category, string word, NLGElement wordElement)
        {
            WordElement baseWord = null;

            if (category.GetLexicalCategory() == LexicalCategory.LexicalCategoryEnum.NOUN && lexicon.hasWord(word, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN)))
            {
                baseWord = lexicon.lookupWord(word, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN));

                if (baseWord != null)
                {
                    wordElement.setFeature(InternalFeature.BASE_WORD, baseWord);
                    wordElement.Category = new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN);
                    if (!PRONOUNS.Contains(word))
                    {
                        wordElement.setFeature(InternalFeature.NON_MORPH, true);
                    }
                }
            }
            else
            {
                baseWord = lexicon.lookupWord(word, category);
                wordElement.setFeature(InternalFeature.BASE_WORD, baseWord);
            }
        }
예제 #4
0
        /**
         * A helper method to set the features on newly created pronoun words.
         *
         * @param wordElement
         *            the created element representing the pronoun.
         * @param word
         *            the base word for the pronoun.
         */
        private void setPronounFeatures(NLGElement wordElement, string word)
        {
            wordElement.Category = new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN);
            if (FIRST_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(Feature.PERSON, Person.FIRST);
            }
            else if (SECOND_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(Feature.PERSON, Person.SECOND);

                if ("yourself".Equals(word, StringComparison.OrdinalIgnoreCase))
                {                 //$NON-NLS-1$
                    wordElement.Plural = false;
                }
                else if ("yourselves".Equals(word, StringComparison.OrdinalIgnoreCase))
                {                 //$NON-NLS-1$
                    wordElement.Plural = true;
                }
                else
                {
                    wordElement.setFeature(Feature.NUMBER, NumberAgreement.BOTH);
                }
            }
            else
            {
                wordElement.setFeature(Feature.PERSON, Person.THIRD);
            }
            if (REFLEXIVE_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(LexicalFeature.REFLEXIVE, true);
            }
            else
            {
                wordElement.setFeature(LexicalFeature.REFLEXIVE, false);
            }
            if (MASCULINE_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(LexicalFeature.GENDER, Gender.MASCULINE);
            }
            else if (FEMININE_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(LexicalFeature.GENDER, Gender.FEMININE);
            }
            else
            {
                wordElement.setFeature(LexicalFeature.GENDER, Gender.NEUTER);
            }

            if (POSSESSIVE_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(Feature.POSSESSIVE, true);
            }
            else
            {
                wordElement.setFeature(Feature.POSSESSIVE, false);
            }

            if (PLURAL_PRONOUNS.Contains(word) && !SECOND_PRONOUNS.Contains(word))
            {
                wordElement.Plural = true;
            }
            else if (!EITHER_NUMBER_PRONOUNS.Contains(word))
            {
                wordElement.Plural = false;
            }

            if (EXPLETIVE_PRONOUNS.Contains(word))
            {
                wordElement.setFeature(InternalFeature.NON_MORPH, true);
                wordElement.setFeature(LexicalFeature.EXPLETIVE_SUBJECT, true);
            }
            wordElement.setFeature(Feature.IS_CAPITALIZED, false);             //added by GJdV, some default value
        }