예제 #1
0
        /**
         * This method performs the morphology for pronouns.
         *
         * @param element
         *            the <code>InflectedWordElement</code>.
         * @return a <code>StringElement</code> representing the word after
         *         inflection.
         */

        public static INLGElement doPronounMorphology(InflectedWordElement element)
        {
            string realised = null;

            if (!element.getFeatureAsBoolean(InternalFeature.NON_MORPH.ToString()) && !isWHPronoun(element))
            {
                var genderValue    = element.getFeature(LexicalFeature.GENDER);
                var personValue    = element.getFeature(Feature.PERSON.ToString());
                var discourseValue = element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());

                var numberIndex = element.isPlural() ? 1 : 0;
                var genderIndex = (genderValue is Gender) ? ((Gender)genderValue).ordinal() : 2;

                var personIndex = (personValue is Person) ? ((Person)personValue).ordinal() : 2;

                if (personIndex == 2)
                {
                    personIndex += genderIndex;
                }

                var positionIndex = 0;

                if (element.getFeatureAsBoolean(LexicalFeature.REFLEXIVE))
                {
                    positionIndex = 2;
                }
                else if (element.getFeatureAsBoolean(Feature.POSSESSIVE.ToString()))
                {
                    positionIndex = 3;
                    if (DiscourseFunction.SPECIFIER.Equals(discourseValue))
                    {
                        positionIndex++;
                    }
                }
                else
                {
                    positionIndex = (DiscourseFunction.SUBJECT.Equals(discourseValue) && !element.getFeatureAsBoolean(
                                         Feature.PASSIVE.ToString())) ||
                                    (DiscourseFunction.OBJECT.Equals(discourseValue) &&
                                     element.getFeatureAsBoolean(Feature.PASSIVE.ToString())) ||
                                    DiscourseFunction.SPECIFIER.Equals(discourseValue) || (
                        DiscourseFunction.COMPLEMENT.Equals(discourseValue) &&
                        element.getFeatureAsBoolean(Feature.PASSIVE.ToString()))
                        ? 0
                        : 1;
                }
                realised = PRONOUNS[numberIndex][positionIndex][personIndex];
            }
            else
            {
                realised = element.getBaseForm();
            }
            var realisedElement = new StringElement(realised);

            realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                       element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));

            return(realisedElement);
        }
예제 #2
0
        /**
         * This method performs the morphology for nouns.
         *
         * @param element
         *            the <code>InflectedWordElement</code>.
         * @param baseWord
         *            the <code>WordElement</code> as created from the lexicon
         *            entry.
         * @return a <code>StringElement</code> representing the word after
         *         inflection.
         */

        public static StringElement doNounMorphology(InflectedWordElement element, WordElement baseWord)
        {
            var realised = new StringBuilder();

            // base form from baseWord if it exists, otherwise from element
            var baseForm = getBaseForm(element, baseWord);

            if (element.isPlural() && !element.getFeatureAsBoolean(LexicalFeature.PROPER))
            {
                string pluralForm = null;

                // AG changed: now check if default infl is uncount
                // if (element.getFeatureAsBoolean(LexicalFeature.NON_COUNT)
                // ) {
                // pluralForm = baseForm;
                var elementDefaultInfl = element.getFeature(LexicalFeature.DEFAULT_INFL);

                if (elementDefaultInfl != null && Inflection.UNCOUNT.Equals(elementDefaultInfl))
                {
                    pluralForm = baseForm;
                }
                else
                {
                    pluralForm = element.getFeatureAsString(LexicalFeature.PLURAL);
                }

                if (pluralForm == null && baseWord != null)
                {
                    // AG changed: now check if default infl is uncount
                    // if (baseWord.getFeatureAsBoolean(LexicalFeature.NON_COUNT)
                    // ) {
                    // pluralForm = baseForm;
                    var baseDefaultInfl = baseWord.getFeatureAsString(LexicalFeature.DEFAULT_INFL);
                    if (baseDefaultInfl != null && baseDefaultInfl.Equals("uncount"))
                    {
                        pluralForm = baseForm;
                    }
                    else
                    {
                        pluralForm = baseWord.getFeatureAsString(LexicalFeature.PLURAL);
                    }
                }

                if (pluralForm == null)
                {
                    var pattern = element.getFeature(LexicalFeature.DEFAULT_INFL);
                    if (Inflection.GRECO_LATIN_REGULAR.Equals(pattern))
                    {
                        pluralForm = buildGrecoLatinPluralNoun(baseForm);
                    }
                    else
                    {
                        pluralForm = buildRegularPluralNoun(baseForm);
                    }
                }
                realised.append(pluralForm);
            }
            else
            {
                realised.append(baseForm);
            }

            checkPossessive(element, realised);
            var realisedElement = new StringElement(realised.ToString());

            realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                       element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));
            return(realisedElement);
        }