コード例 #1
0
        /**
         * Sets coordinated phrase features.
         *
         * @param wp
         *            The xml CoordinatedPhraseElement object.
         * @param p
         *            the internal CoordinatedPhraseElement object to get the features.
         */
        private void setCoordinatedPhraseFeatures(wrapper.XmlCoordinatedPhraseElement wp, CoordinatedPhraseElement p)
        {
            if (wp.PERSON != null)
            {
                p.setFeature(Feature.PERSON, wp.PERSON);
            }

            if (wp.TENSE != null)
            {
                Enum.TryParse(wp.TENSE.ToString(), out Tense tense);
                p.setFeature(Feature.TENSE, tense);
            }

            if (wp.MODAL != null)
            {
                p.setFeature(Feature.MODAL, wp.MODAL);
            }

            if (wp.NUMBER != null)
            {             // map number feature from wrapper ~NumberAgr to actual NumberAgr
                string numString = wp.NUMBER.ToString();
                Enum.TryParse(numString, out NumberAgreement simplenlgNum);
                // p.setFeature(Feature.NUMBER, wp.getNUMBER());
                p.setFeature(Feature.NUMBER, simplenlgNum);
            }

            if (wp.PERSON != null)
            {             // map person feature from wrapper Person to actual Person
                string perString = wp.PERSON.ToString();
                Enum.TryParse(perString, out Person simplenlgPers);
                p.setFeature(Feature.PERSON, simplenlgPers);
            }

            // boolean features.
            p.setFeature(Feature.APPOSITIVE, wp.APPOSITIVE);
            p.setFeature(Feature.NEGATED, wp.NEGATED);
            p.setFeature(Feature.POSSESSIVE, wp.POSSESSIVE);
            p.setFeature(Feature.PROGRESSIVE, wp.PROGRESSIVE);
            p.setFeature(Feature.RAISE_SPECIFIER, wp.RAISESPECIFIER);
            p.setFeature(Feature.SUPRESSED_COMPLEMENTISER, wp.SUPRESSEDCOMPLEMENTISER);
        }
コード例 #2
0
        /**
         * Unwraps a coordinate phrase.
         *
         * @param wps
         *            the <code>simplenlg.xmlrealiser.wrapper.NLGElement</code>
         *            representing the phrase
         * @return a <code>simplenlg.framework.CoordinatedPhraseElement</code> or
         *         <code>null</code> if the wrapper element is not a coordinate
         *         phrase.
         */
        public virtual NLGElement UnwrapCoordinatePhraseSpec(wrapper.XmlNLGElement wps)
        {
            NLGElement ret = null;

            // CoordinatedPhraseElement
            if (wps is wrapper.XmlCoordinatedPhraseElement)
            {
                wrapper.XmlCoordinatedPhraseElement wp = (wrapper.XmlCoordinatedPhraseElement)wps;
                CoordinatedPhraseElement            cp = new CoordinatedPhraseElement();
                ElementCategory cat = UnwrapCategory(wp.Cat);

                if (cat != null && cat is PhraseCategory)
                {
                    cp.Category = cat;
                }
                if (wp.Conj != null)
                {
                    string s = wp.Conj;
                    if (!ReferenceEquals(s, null))
                    {
                        cp.Conjunction = s;
                    }
                }

                setCoordinatedPhraseFeatures(wp, cp);

                foreach (wrapper.XmlNLGElement p in wp.Coord)
                {
                    NLGElement p1 = UnwrapNLGElement(p);
                    if (p1 != null)
                    {
                        cp.addCoordinate(p1);
                    }
                }
                ret = cp;
            }

            return(ret);
        }