Пример #1
0
        /**
         * This method performs the morphology for adjectives.
         *
         * @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 INLGElement doAdjectiveMorphology(InflectedWordElement element, WordElement baseWord)
        {
            string realised     = null;
            var    patternValue = element.getFeature(LexicalFeature.DEFAULT_INFL);

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

            if (element.getFeatureAsBoolean(Feature.IS_COMPARATIVE.ToString()))
            {
                realised = element.getFeatureAsString(LexicalFeature.COMPARATIVE);

                if (realised == null && baseWord != null)
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.COMPARATIVE);
                }
                if (realised == null)
                {
                    if (Inflection.REGULAR_DOUBLE.Equals(patternValue))
                    {
                        realised = buildDoubleCompAdjective(baseForm);
                    }
                    else
                    {
                        realised = buildRegularComparative(baseForm);
                    }
                }
            }
            else if (element.getFeatureAsBoolean(Feature.IS_SUPERLATIVE.ToString()))
            {
                realised = element.getFeatureAsString(LexicalFeature.SUPERLATIVE);

                if (realised == null && baseWord != null)
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.SUPERLATIVE);
                }
                if (realised == null)
                {
                    if (Inflection.REGULAR_DOUBLE.Equals(patternValue))
                    {
                        realised = buildDoubleSuperAdjective(baseForm);
                    }
                    else
                    {
                        realised = buildRegularSuperlative(baseForm);
                    }
                }
            }
            else
            {
                realised = baseForm;
            }
            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 adverbs.
         *
         * @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 INLGElement doAdverbMorphology(InflectedWordElement element, WordElement baseWord)
        {
            string realised = null;

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

            if (element.getFeatureAsBoolean(Feature.IS_COMPARATIVE.ToString()))
            {
                realised = element.getFeatureAsString(LexicalFeature.COMPARATIVE);

                if (realised == null && baseWord != null)
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.COMPARATIVE);
                }
                if (realised == null)
                {
                    realised = buildRegularComparative(baseForm);
                }
            }
            else if (element.getFeatureAsBoolean(Feature.IS_SUPERLATIVE.ToString()))
            {
                realised = element.getFeatureAsString(LexicalFeature.SUPERLATIVE);

                if (realised == null && baseWord != null)
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.SUPERLATIVE);
                }
                if (realised == null)
                {
                    realised = buildRegularSuperlative(baseForm);
                }
            }
            else
            {
                realised = baseForm;
            }
            var realisedElement = new StringElement(realised);

            realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                       element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));
            return(realisedElement);
        }
Пример #3
0
        /**
         * This method performs the morphology for verbs.
         *
         * @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 INLGElement doVerbMorphology(InflectedWordElement element, WordElement baseWord)
        {
            string realised    = null;
            var    numberValue = element.getFeature(Feature.NUMBER.ToString());
            var    personValue = element.getFeature(Feature.PERSON.ToString());
            var    tenseValue  = element.getFeatureTense(Feature.TENSE.ToString());


            var formValue    = element.getFeature(Feature.FORM.ToString());
            var patternValue = element.getFeature(LexicalFeature.DEFAULT_INFL);

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

            if (element.getFeatureAsBoolean(Feature.NEGATED.ToString()) || Form.BARE_INFINITIVE.Equals(formValue))
            {
                realised = baseForm;
            }
            else if (Form.PRESENT_PARTICIPLE.Equals(formValue))
            {
                realised = element.getFeatureAsString(LexicalFeature.PRESENT_PARTICIPLE);

                if (realised == null && baseWord != null)
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.PRESENT_PARTICIPLE);
                }

                if (realised == null)
                {
                    if (Inflection.REGULAR_DOUBLE.Equals(patternValue))
                    {
                        realised = buildDoublePresPartVerb(baseForm);
                    }
                    else
                    {
                        realised = buildRegularPresPartVerb(baseForm);
                    }
                }
            }
            else if (Tense.PAST.Equals(tenseValue) || Form.PAST_PARTICIPLE.Equals(formValue))
            {
                if (Form.PAST_PARTICIPLE.Equals(formValue))
                {
                    realised = element.getFeatureAsString(LexicalFeature.PAST_PARTICIPLE);

                    if (realised == null && baseWord != null)
                    {
                        realised = baseWord.getFeatureAsString(LexicalFeature.PAST_PARTICIPLE);
                    }

                    if (realised == null)
                    {
                        if ("be".equalsIgnoreCase(baseForm))
                        {
                            realised = "been";
                        }
                        else if (Inflection.REGULAR_DOUBLE.Equals(patternValue))
                        {
                            realised = buildDoublePastVerb(baseForm);
                        }
                        else
                        {
                            realised = buildRegularPastVerb(baseForm, numberValue, personValue);
                        }
                    }
                }
                else
                {
                    realised = element.getFeatureAsString(LexicalFeature.PAST);

                    if (realised == null && baseWord != null)
                    {
                        realised = baseWord.getFeatureAsString(LexicalFeature.PAST);
                    }

                    if (realised == null)
                    {
                        if (Inflection.REGULAR_DOUBLE.Equals(patternValue))
                        {
                            realised = buildDoublePastVerb(baseForm);
                        }
                        else
                        {
                            realised = buildRegularPastVerb(baseForm, numberValue, personValue);
                        }
                    }
                }
            }
            else if ((numberValue == null || NumberAgreement.SINGULAR.Equals(numberValue)) && (personValue == null ||
                                                                                               Person.THIRD.Equals(
                                                                                                   personValue)) &&
                     (Tense.PRESENT.Equals(tenseValue)))
            {
                realised = element.getFeatureAsString(LexicalFeature.PRESENT3S);

                if (realised == null && baseWord != null && !"be".equalsIgnoreCase(baseForm))
                {
                    realised = baseWord.getFeatureAsString(LexicalFeature.PRESENT3S);
                }
                if (realised == null)
                {
                    realised = buildPresent3SVerb(baseForm);
                }
            }
            else
            {
                if ("be".equalsIgnoreCase(baseForm))
                {
                    if (Person.FIRST.Equals(personValue) && (NumberAgreement.SINGULAR.Equals(numberValue) ||
                                                             numberValue == null))
                    {
                        realised = "am";
                    }
                    else
                    {
                        realised = "are";
                    }
                }
                else
                {
                    realised = baseForm;
                }
            }
            var realisedElement = new StringElement(realised);

            realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                       element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));
            return(realisedElement);
        }
Пример #4
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);
        }