Esempio n. 1
0
        /**
         * Checks to see if the specifier can be raised and then raises it. In order
         * to be raised the specifier must be the same on all coordinates. For
         * example, <em>the cat and the dog</em> will be realised as
         * <em>the cat and dog</em> while <em>the cat and any dog</em> will remain
         * <em>the cat and any dog</em>.
         *
         * @param children
         *            the <code>List</code> of coordinates in the
         *            <code>CoordinatedPhraseElement</code>
         */
        private static void raiseSpecifier(IList <NLGElement> children)
        {
            bool       allMatch  = true;
            NLGElement child     = children[0];
            NLGElement specifier = null;
            string     test      = null;

            if (child != null)
            {
                specifier = child.getFeatureAsElement(InternalFeature.SPECIFIER);

                if (specifier != null)
                {
                    // AG: this assumes the specifier is an InflectedWordElement or
                    // phrase.
                    // it could be a Wordelement, in which case, we want the
                    // baseform
                    test = (specifier is WordElement) ? ((WordElement)specifier).BaseForm : specifier.getFeatureAsString(LexicalFeature.BASE_FORM);
                }

                if (!ReferenceEquals(test, null))
                {
                    int index = 1;

                    while (index < children.Count && allMatch)
                    {
                        child = children[index];

                        if (child == null)
                        {
                            allMatch = false;
                        }
                        else
                        {
                            specifier = child.getFeatureAsElement(InternalFeature.SPECIFIER);
                            string childForm = (specifier is WordElement) ? ((WordElement)specifier).BaseForm : specifier.getFeatureAsString(LexicalFeature.BASE_FORM);

                            if (!test.Equals(childForm))
                            {
                                allMatch = false;
                            }
                        }
                        index++;
                    }
                    if (allMatch)
                    {
                        for (int eachChild = 1; eachChild < children.Count; eachChild++)
                        {
                            child = children[eachChild];
                            child.setFeature(InternalFeature.RAISED, true);
                        }
                    }
                }
            }
        }