Beispiel #1
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 List <PhraseSet> leftPeriphery(List <INLGElement> sentences)
        {
            var funcsets = new List <PhraseSet>();
            var cue      = new PhraseSet(DiscourseFunction.CUE_PHRASE);
            var front    = new PhraseSet(DiscourseFunction.FRONT_MODIFIER);
            var subj     = new PhraseSet(DiscourseFunction.SUBJECT);

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

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

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

            funcsets.Add(cue);
            funcsets.Add(front);
            funcsets.Add(subj);
            return(funcsets);
        }
Beispiel #2
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 List <PhraseSet> rightPeriphery(List <INLGElement> sentences)
        {
            var funcsets = new List <PhraseSet>();
            var comps    = new PhraseSet(DiscourseFunction.OBJECT);
            // new PhraseSet(DiscourseFunction.INDIRECT_OBJECT);
            var pmods = new PhraseSet(DiscourseFunction.POST_MODIFIER);

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

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

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

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

            funcsets.Add(comps);
            funcsets.Add(pmods);
            return(funcsets);
        }