예제 #1
0
        /**
         * Adds a new coordinate to this coordination. If the new coordinate is a
         * <code>NLGElement</code> then it is added directly to the coordination. If
         * the new coordinate is a <code>string</code> a <code>StringElement</code>
         * is created and added to the coordination. <code>StringElement</code>s
         * will have their complementisers suppressed by default. In the case of
         * clauses, complementisers will be suppressed if the clause is not the
         * first element in the coordination.
         *
         * @param newCoordinate
         *            the new coordinate to be added.
         */

        public void addCoordinate(object newCoordinate)
        {
            List <INLGElement> coordinates = getFeatureAsElementList(InternalFeature.COORDINATES.ToString());

            if (coordinates == null)
            {
                coordinates = new List <INLGElement>();
                setFeature(InternalFeature.COORDINATES.ToString(), coordinates);
            }
            else if (coordinates.Count == 0)
            {
                setFeature(InternalFeature.COORDINATES.ToString(), coordinates);
            }
            if (newCoordinate is INLGElement)
            {
                if (((INLGElement)newCoordinate).isA(PhraseCategoryEnum.CLAUSE) &&
                    coordinates.Count > 0)
                {
                    ((INLGElement)newCoordinate).setFeature(
                        Feature.SUPRESSED_COMPLEMENTISER.ToString(), true);
                }
                coordinates.Add((INLGElement)newCoordinate);
            }
            else if (newCoordinate is string)
            {
                INLGElement coordElement = new StringElement((string)newCoordinate);
                coordElement.setFeature(Feature.SUPRESSED_COMPLEMENTISER.ToString(), true);
                coordinates.Add(coordElement);
            }
            setFeature(InternalFeature.COORDINATES.ToString(), coordinates);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
        public override INLGElement realise(INLGElement element)
        {
            INLGElement realisedElement = null;

            if (element is InflectedWordElement)
            {
                realisedElement = doMorphology((InflectedWordElement)element);
            }
            else if (element is StringElement)
            {
                realisedElement = element;
            }
            else if (element is WordElement)
            {
                // AG: now retrieves the default spelling variant, not the baseform
                // string baseForm = ((WordElement) element).getBaseForm();
                var defaultSpell = ((WordElement)element).getDefaultSpellingVariant();

                if (defaultSpell != null)
                {
                    realisedElement = new StringElement(defaultSpell);
                }
            }
            else if (element is DocumentElement)
            {
                List <INLGElement> children = element.getChildren();
                ((DocumentElement)element).setComponents(realise(children));
                realisedElement = element;
            }
            else if (element is ListElement)
            {
                realisedElement = new ListElement();
                ((ListElement)realisedElement).addComponents(realise(element.getChildren()));
            }
            else if (element is CoordinatedPhraseElement)
            {
                List <INLGElement> children = element.getChildren();
                ((CoordinatedPhraseElement)element).clearCoordinates();

                if (children != null && children.size() > 0)
                {
                    ((CoordinatedPhraseElement)element).addCoordinate(realise(children.get(0)));

                    for (var index = 1; index < children.size(); index++)
                    {
                        ((CoordinatedPhraseElement)element).addCoordinate(realise(children.get(index)));
                    }

                    realisedElement = element;
                }
            }
            else if (element != null)
            {
                realisedElement = element;
            }

            return(realisedElement);
        }
예제 #5
0
        /**
         * This is the main method for performing the morphology. It effectively
         * examines the lexical category of the element and calls the relevant set
         * of rules from <code>MorphologyRules</em>.
         *
         * @param element
         *            the <code>InflectedWordElement</code>
         * @return an <code>NLGElement</code> reflecting the correct inflection for
         *         the word.
         */

        private INLGElement doMorphology(InflectedWordElement element)
        {
            INLGElement realisedElement = null;

            if (element.getFeatureAsBoolean(InternalFeature.NON_MORPH.ToString()))
            {
                realisedElement = new StringElement(element.getBaseForm());
                realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                           element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));
            }
            else
            {
                INLGElement baseWord = element.getFeatureAsElement(InternalFeature.BASE_WORD.ToString());

                if (baseWord == null && this.lexicon != null)
                {
                    baseWord = this.lexicon.lookupWord(element.getBaseForm());
                }

                var category = element.getCategory();

                if (category is ILexicalCategory)
                {
                    switch ((LexicalCategoryEnum)category.enumType)
                    {
                    case LexicalCategoryEnum.PRONOUN:
                        realisedElement = MorphologyRules.doPronounMorphology(element);
                        break;

                    case LexicalCategoryEnum.NOUN:
                        realisedElement = MorphologyRules.doNounMorphology(element, (WordElement)baseWord);
                        break;

                    case LexicalCategoryEnum.VERB:
                        realisedElement = MorphologyRules.doVerbMorphology(element, (WordElement)baseWord);
                        break;

                    case LexicalCategoryEnum.ADJECTIVE:
                        realisedElement = MorphologyRules.doAdjectiveMorphology(element, (WordElement)baseWord);
                        break;

                    case LexicalCategoryEnum.ADVERB:
                        realisedElement = MorphologyRules.doAdverbMorphology(element, (WordElement)baseWord);
                        break;

                    default:
                        realisedElement = new StringElement(element.getBaseForm());
                        realisedElement.setFeature(InternalFeature.DISCOURSE_FUNCTION.ToString(),
                                                   element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString()));
                        break;
                    }
                }
            }
            return(realisedElement);
        }
예제 #6
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>
         *
         * @param newComplement
         *            the new complement as a <code>string</code>. It is used to
         *            create a <code>StringElement</code>.
         */

        public virtual void addComplement(string newComplement)
        {
            var newElement  = new StringElement(newComplement);
            var complements = getFeatureAsElementList(InternalFeature.COMPLEMENTS.ToString());

            if (complements == null)
            {
                complements = new List <INLGElement>();
            }
            complements.add(newElement);
            this.setFeature(InternalFeature.COMPLEMENTS.ToString(), complements);
        }
예제 #7
0
        /**
         * Retrieves the value of the feature as a <code>NLGElement</code>. If the
         * value is a string then it is wrapped in a <code>StringElement</code>. If
         * the feature does not exist or is of any other type then <code>null</code>
         * is returned.
         *
         * @param featureName
         *            the name of the feature.
         * @return the <code>NLGElement</code>.
         */

        public virtual INLGElement getFeatureAsElement(string featureName)
        {
            var         value        = getFeature(featureName);
            INLGElement elementValue = null;

            var element = value as INLGElement;

            if (element != null)
            {
                elementValue = element;
            }
            else if (value is string)
            {
                elementValue = new StringElement((string)value);
            }
            return(elementValue);
        }
예제 #8
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);
        }
예제 #9
0
        /**
         * Sets the head, or main component, of this current phrase. For example,
         * the head for a verb phrase should be a verb while the head of a noun
         * phrase should be a noun. <code>string</code>s are converted to
         * <code>StringElement</code>s. If <code>null</code> is passed in as the new
         * head then the head feature is removed.
         *
         * @param newHead
         *            the new value for the head of this phrase.
         */

        public virtual void setHead(object newHead)
        {
            if (newHead == null)
            {
                removeFeature(InternalFeature.HEAD.ToString());
                return;
            }
            INLGElement headElement;

            if (newHead is INLGElement)
            {
                headElement = (INLGElement)newHead;
            }
            else
            {
                headElement = new StringElement(newHead.ToString());
            }

            setFeature(InternalFeature.HEAD.ToString(), headElement);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        public override INLGElement realise(INLGElement element)
        {
            INLGElement realisedElement = null;
            object      function        = null; //the element's discourse function

            //get the element's function first
            if (element is ListElement)
            {
                List <INLGElement> children = element.getChildren();
                if (!children.isEmpty())
                {
                    var firstChild = children.get(0);
                    function = firstChild.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());
                }
            }
            else
            {
                if (element != null)
                {
                    function = element.getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());
                }
            }

            if (element != null)
            {
                var category = element.getCategory();

                if (category is IDocumentCategory && element is DocumentElement)
                {
                    var components = ((DocumentElement)element).getComponents();

                    switch ((DocumentCategoryEnum)category.enumType)
                    {
                    case DocumentCategoryEnum.SENTENCE:
                        realisedElement = realiseSentence(components, element);
                        break;

                    case DocumentCategoryEnum.LIST_ITEM:
                        if (components != null && components.size() > 0)
                        {
                            // recursively realise whatever is in the list item
                            // NB: this will realise embedded lists within list
                            // items
                            realisedElement = new ListElement(realise(components));
                            realisedElement.setParent(element.getParent());
                        }
                        break;

                    default:
                        ((DocumentElement)element).setComponents(realise(components));
                        realisedElement = element;
                        break;
                    }
                }
                else if (element is ListElement)
                {
                    // AG: changes here: if we have a premodifier, then we ask the
                    // realiseList method to separate with a comma.
                    // if it's a postmod, we need commas at the start and end only
                    // if it's appositive
                    var buffer = new StringBuilder();

                    if (DiscourseFunction.PRE_MODIFIER.Equals(function))
                    {
                        var all_appositives = true;
                        foreach (NLGElement child in element.getChildren())
                        {
                            all_appositives = all_appositives && child.getFeatureAsBoolean(Feature.APPOSITIVE.ToString());
                        }

                        // TODO: unless this is the end of the sentence
                        if (all_appositives)
                        {
                            buffer.append(", ");
                        }
                        realiseList(buffer, element.getChildren(), this.commaSepPremodifiers ? "," : "");
                        if (all_appositives)
                        {
                            buffer.append(", ");
                        }
                    }
                    else if (DiscourseFunction.POST_MODIFIER.Equals(function))
                    {
// &&
                        // appositive)
                        // {
                        List <INLGElement> postmods = element.getChildren();
                        // bug fix due to Owen Bennett
                        var len = postmods.size();

                        for (var i = 0; i < len; i++)
                        {
                            // for(NLGElement postmod: element.getChildren()) {
                            var postmod = postmods.get(i);

                            // if the postmod is appositive, it's sandwiched in
                            // commas
                            if (postmod.getFeatureAsBoolean(Feature.APPOSITIVE.ToString()))
                            {
                                buffer.append(", ");
                                buffer.append(realise(postmod).ToString());

                                if (i < len - 1)
                                {
                                    buffer.append(", ");
                                }
                            }
                            else
                            {
                                buffer.append(realise(postmod).ToString());
                                if (postmod is ListElement ||
                                    (postmod.getRealisation() != null && !postmod.getRealisation().Equals("")))
                                {
                                    buffer.append(" ");
                                }
                            }
                        }
                    }
                    else if ((DiscourseFunction.CUE_PHRASE.Equals(function) ||
                              DiscourseFunction.FRONT_MODIFIER.Equals(function)) &&
                             this.commaSepCuephrase)
                    {
                        realiseList(buffer, element.getChildren(), this.commaSepCuephrase ? "," : "");
                    }
                    else
                    {
                        realiseList(buffer, element.getChildren(), "");
                    }

                    // realiseList(buffer, element.getChildren(), "");
                    realisedElement = new StringElement(buffer.ToString());
                }
                else if (element is CoordinatedPhraseElement)
                {
                    realisedElement = realiseCoordinatedPhrase(element.getChildren());
                }
                else
                {
                    realisedElement = element;
                }

                // make the realised element inherit the original category
                // essential if list items are to be properly formatted later
                if (realisedElement != null)
                {
                    realisedElement.setCategory(category);
                }

                //check if this is a cue phrase; if param is set, postfix a comma
                if ((DiscourseFunction.CUE_PHRASE.Equals(function) || DiscourseFunction.FRONT_MODIFIER.Equals(function)) &&
                    this.commaSepCuephrase)
                {
                    var realisation = realisedElement.getRealisation();

                    if (!realisation.endsWith(","))
                    {
                        realisation = realisation + ",";
                    }

                    realisedElement.setRealisation(realisation);
                }
            }

            //remove preceding and trailing whitespace from internal punctuation
            removePunctSpace(realisedElement);
            return(realisedElement);
        }