示例#1
0
        /** sets the adverb (head) of the phrase
         * @param adverb
         */
        public virtual void setAdverb(object adverb)
        {
            if (adverb is NLGElement)
            {
                setHead(adverb);
            }
            else
            {
                // create noun as word
                NLGElement adverbElement = Factory.createWord(adverb, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ADVERB));

                // set head of NP to nounElement
                setHead(adverbElement);
            }
        }
示例#2
0
        /** sets the adjective (head) of the phrase
         * @param adjective
         */
        public virtual void setAdjective(object adjective)
        {
            if (adjective is NLGElement)
            {
                setHead(adjective);
            }
            else
            {
                // create noun as word
                NLGElement adjectiveElement = Factory.createWord(adjective, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ADJECTIVE));

                // set head of NP to nounElement
                setHead(adjectiveElement);
            }
        }
示例#3
0
        /**
         * sets the specifier of a noun phrase. Can be determiner (eg "the"),
         * possessive (eg, "John's")
         *
         * @param specifier
         */
        public virtual void setSpecifier(object specifier)
        {
            if (specifier is NLGElement)
            {
                setFeature(InternalFeature.SPECIFIER, specifier);
                ((NLGElement)specifier).setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SPECIFIER);
            }
            else
            {
                // create specifier as word (assume determiner)
                NLGElement specifierElement = Factory.createWord(specifier, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.DETERMINER));


                // set specifier feature
                if (specifierElement != null)
                {
                    setFeature(InternalFeature.SPECIFIER, specifierElement);
                    specifierElement.setFeature(InternalFeature.DISCOURSE_FUNCTION, DiscourseFunction.SPECIFIER);
                }
            }
        }
示例#4
0
        /**
         * Add a modifier to an NP Use heuristics to decide where it goes
         *
         * @param modifier
         */
        public override void addModifier(object modifier)
        {
            // string which is one lexicographic word is looked up in lexicon,
            // adjective is preModifier
            // Everything else is postModifier
            if (modifier == null)
            {
                return;
            }

            // get modifier as NLGElement if possible
            NLGElement modifierElement = null;

            if (modifier is NLGElement)
            {
                modifierElement = (NLGElement)modifier;
            }
            else if (modifier is string)
            {
                string modifierString = (string)modifier;
                if (modifierString.Length > 0 && !modifierString.Contains(" "))
                {
                    modifierElement = Factory.createWord(modifier, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ANY));
                }
            }

            // if no modifier element, must be a complex string, add as postModifier
            if (modifierElement == null)
            {
                addPostModifier((string)modifier);
                return;
            }

            // AdjP is premodifer
            if (modifierElement is AdjPhraseSpec)
            {
                addPreModifier(modifierElement);
                return;
            }

            // else extract WordElement if modifier is a single word
            WordElement modifierWord = null;

            if (modifierElement != null && modifierElement is WordElement)
            {
                modifierWord = (WordElement)modifierElement;
            }
            else if (modifierElement != null && modifierElement is InflectedWordElement)
            {
                modifierWord = ((InflectedWordElement)modifierElement).BaseWord;
            }
            // check if modifier is an adjective

            if (modifierWord != null && modifierWord.Category == LexicalCategory.LexicalCategoryEnum.ADJECTIVE)
            {
                addPreModifier(modifierWord);
                return;
            }

            // default case
            addPostModifier(modifierElement);
        }
示例#5
0
        /**
         * sets the noun (head) of a noun phrase
         *
         * @param noun
         */
        public virtual void setNoun(object noun)
        {
            NLGElement nounElement = Factory.createNLGElement(noun, new LexicalCategory(LexicalCategory.LexicalCategoryEnum.NOUN));

            setHead(nounElement);
        }