Пример #1
0
        /**
         * Collect a list of pairs of constituents with the same syntactic function
         * from the right periphery of two sentences. The right periphery
         * encompasses the complements of the main verb, and its postmodifiers.
         *
         * @param sentences
         *            the list of sentences
         * @return a list of pairs of constituents with the same function, if any
         *         are found
         */
        public static IList <PhraseSet> rightPeriphery(params NLGElement[] sentences)
        {
            IList <PhraseSet> funcsets = new List <PhraseSet>();
            PhraseSet         comps    = new PhraseSet(DiscourseFunction.OBJECT);
            // new PhraseSet(DiscourseFunction.INDIRECT_OBJECT);
            PhraseSet pmods = new PhraseSet(DiscourseFunction.POST_MODIFIER);

            foreach (NLGElement s in sentences)
            {
                NLGElement vp = s.getFeatureAsElement(InternalFeature.VERB_PHRASE);

                if (vp != null)
                {
                    if (vp.hasFeature(InternalFeature.COMPLEMENTS))
                    {
                        comps.addPhrases(vp.getFeatureAsElementList(InternalFeature.COMPLEMENTS));
                    }

                    if (vp.hasFeature(InternalFeature.POSTMODIFIERS))
                    {
                        pmods.addPhrases(vp.getFeatureAsElementList(InternalFeature.POSTMODIFIERS));
                    }
                }

                if (s.hasFeature(InternalFeature.POSTMODIFIERS))
                {
                    pmods.addPhrases(s.getFeatureAsElementList(InternalFeature.POSTMODIFIERS));
                }
            }

            funcsets.Add(comps);
            funcsets.Add(pmods);
            return(funcsets);
        }
Пример #2
0
 /**
  * Utility method to set the discourse function for phrase components,
  * unless set by user
  *
  * @param function
  *            the function
  * @param phrase
  *            the phrase
  */
 private void checkFunction(DiscourseFunction function, NLGElement phrase)
 {
     if (!phrase.hasFeature(InternalFeature.DISCOURSE_FUNCTION))
     {
         phrase.setFeature(InternalFeature.DISCOURSE_FUNCTION, function);
     }
 }
Пример #3
0
        /**
         * ~Set the features for a sentence. This method also checks whether any
         * features have been set on the VP, in which case, they are set if they
         * haven't been set on the S
         *
         * @param wp
         *            the xml SPhraseSpec object
         * @param sp
         *            the sentence.
         * @param vp
         *            the verb phrase.
         */
        private void setSFeatures(wrapper.XmlSPhraseSpec wp, SPhraseSpec sp, NLGElement vp)
        {
            if (wp.CLAUSESTATUS != null)
            {
                Enum.TryParse(wp.CLAUSESTATUS.ToString(), out ClauseStatus clauseStatus);
                sp.setFeature(InternalFeature.CLAUSE_STATUS, clauseStatus);
            }

            if (wp.PERSON != null)
            {
                Enum.TryParse(wp.PERSON.ToString(), out Person person);
                sp.setFeature(Feature.PERSON, person);
            }

            if (wp.FORM != null)
            {
                Enum.TryParse(wp.FORM.ToString(), out Form form);
                sp.setFeature(Feature.FORM, form);
            }

            if (wp.TENSE != null)
            {
                Enum.TryParse(wp.TENSE.ToString(), out Form tense);
                sp.setFeature(Feature.TENSE, tense);
            }
            else if (vp != null && vp.hasFeature(Feature.TENSE))
            {
                sp.setFeature(Feature.TENSE, vp.getFeature(Feature.TENSE));
            }

            // modal -- set on S or inherited from VP
            if (wp.MODAL != null)
            {
                sp.setFeature(Feature.MODAL, wp.MODAL);
            }
            else if (vp != null && vp.hasFeature(Feature.MODAL))
            {
                sp.setFeature(Feature.MODAL, vp.getFeature(Feature.MODAL));
            }

            // interrogative
            if (wp.INTERROGATIVETYPE != null)
            {
                Enum.TryParse(wp.INTERROGATIVETYPE.ToString(), out InterrogativeType interrogativeType);
                sp.setFeature(Feature.INTERROGATIVE_TYPE, interrogativeType);
            }
            else if (vp != null && vp.hasFeature(Feature.INTERROGATIVE_TYPE))
            {
                sp.setFeature(Feature.INTERROGATIVE_TYPE, vp.getFeature(Feature.INTERROGATIVE_TYPE));
            }

            // set on clauses.
            bool sAggregateAuxiliary = wp.AGGREGATEAUXILIARY ?? false;
            bool vAggregateAuxiliary = vp?.getFeatureAsBoolean(Feature.AGGREGATE_AUXILIARY) ?? false;

            sp.setFeature(Feature.AGGREGATE_AUXILIARY, sAggregateAuxiliary || vAggregateAuxiliary);

            // passive: can be set on S or VP
            bool sPass = wp.PASSIVE ?? false;
            bool vPass = vp?.getFeatureAsBoolean(Feature.PASSIVE) ?? false;

            sp.setFeature(Feature.PASSIVE, sPass || vPass);

            // progressive: can be set on S or VP
            bool sProg = wp.PROGRESSIVE ?? false;
            bool vProg = vp?.getFeatureAsBoolean(Feature.PROGRESSIVE) ?? false;

            sp.setFeature(Feature.PROGRESSIVE, sProg || vProg);

            // perfect: can be set on S or VP
            bool sPerf = wp.PERFECT ?? false;
            bool vPerf = vp?.getFeatureAsBoolean(Feature.PERFECT) ?? false;

            sp.setFeature(Feature.PERFECT, sPerf || vPerf);

            // negation: can be set on S or VP
            bool sNeg = wp.NEGATED ?? false;
            bool vNeg = vp?.getFeatureAsBoolean(Feature.NEGATED) ?? false;

            sp.setFeature(Feature.NEGATED, sNeg || vNeg);

            // set on clauses.
            bool ssgg = wp.SUPPRESSGENITIVEINGERUND ?? false;
            bool vsgg = vp?.getFeatureAsBoolean(Feature.SUPPRESS_GENITIVE_IN_GERUND) ?? false;

            sp.setFeature(Feature.SUPPRESS_GENITIVE_IN_GERUND, ssgg || vsgg);

            // set on clauses.
            bool ssc = wp.SUPRESSEDCOMPLEMENTISER ?? false;
            bool vsc = vp?.getFeatureAsBoolean(Feature.SUPRESSED_COMPLEMENTISER) ?? false;

            sp.setFeature(Feature.SUPRESSED_COMPLEMENTISER, ssc || vsc);
        }