示例#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
        /**
         * Collect a list of pairs of constituents with the same syntactic function
         * from the left periphery of two sentences. The left periphery encompasses
         * the subjects, front modifiers and cue phrases of the sentences.
         *
         * @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> leftPeriphery(params NLGElement[] sentences)
        {
            IList <PhraseSet> funcsets = new List <PhraseSet>();
            PhraseSet         cue      = new PhraseSet(DiscourseFunction.CUE_PHRASE);
            PhraseSet         front    = new PhraseSet(DiscourseFunction.FRONT_MODIFIER);
            PhraseSet         subj     = new PhraseSet(DiscourseFunction.SUBJECT);

            foreach (NLGElement s in sentences)
            {
                if (s.hasFeature(Feature.CUE_PHRASE))
                {
                    cue.addPhrases(s.getFeatureAsElementList(Feature.CUE_PHRASE));
                }

                if (s.hasFeature(InternalFeature.FRONT_MODIFIERS))
                {
                    front.addPhrases(s.getFeatureAsElementList(InternalFeature.FRONT_MODIFIERS));
                }

                if (s.hasFeature(InternalFeature.SUBJECTS))
                {
                    subj.addPhrases(s.getFeatureAsElementList(InternalFeature.SUBJECTS));
                }
            }

            funcsets.Add(cue);
            funcsets.Add(front);
            funcsets.Add(subj);
            return(funcsets);
        }