Example #1
0
        public virtual bool formIdentical()
        {
            bool       ident        = true;
            NLGElement firstElement = components[0];

            for (int i = 1; i < components.Count && ident; i++)
            {
                ident = firstElement.Equals(components[i]);
            }

            return(ident);
        }
Example #2
0
        /**
         * Check whether the phrases in this set are identical in form. This method
         * returns true if for every pair of phrases <code>p1</code> and <p2>,
         * <code>p1.equals(p2)</code>.
         *
         * @return <code>true</code> if all phrases in the set are form-identical
         */
        public virtual bool formIdentical()
        {
            bool ident = phrases.Any();

            for (int i = 1; i < phrases.Count && ident; i++)
            {
                NLGElement left  = phrases[i - 1];
                NLGElement right = phrases[i];

                if (left != null && right != null)
                {
                    ident = left.Equals(right);
                }
            }

            return(ident);
        }
Example #3
0
        /**
         * Check whether the phrases are lemma identical. This method returns
         * <code>true</code> in the following cases:
         *
         * <OL>
         * <LI>All phrases are {@link simplenlg.framework.NLGElement}s and they
         * have the same lexical head, irrespective of inflectional variations.</LI>
         * </OL>
         *
         * @return <code>true</code> if the pair is lemma identical
         */
        public virtual bool lemmaIdentical()
        {
            bool ident = phrases.Any();

            for (int i = 1; i < phrases.Count && ident; i++)
            {
                NLGElement left  = phrases[i - 1];
                NLGElement right = phrases[i];


                if (left != null && right != null)
                {
                    NLGElement leftHead  = left.getFeatureAsElement(InternalFeature.HEAD);
                    NLGElement rightHead = right.getFeatureAsElement(InternalFeature.HEAD);
                    ident = (leftHead == rightHead || leftHead.Equals(rightHead));
                }
            }

            return(ident);
        }
        /**
         * Check that a list of sentences have the same verb
         *
         * @param sentences
         *            the sentences
         * @return <code>true</code> if for every pair of sentences <code>s1</code>
         *         and <code>s2</code>
         *         <code>s1.getVerbPhrase().getHead().equals(s2.getVerbPhrase().getHead())</code>
         */
        public static bool sameVPHead(params NLGElement[] sentences)
        {
            bool equal = sentences.Length >= 2;

            for (int i = 1; i < sentences.Length && equal; i++)
            {
                NLGElement vp1 = sentences[i - 1].getFeatureAsElement(InternalFeature.VERB_PHRASE);
                NLGElement vp2 = sentences[i].getFeatureAsElement(InternalFeature.VERB_PHRASE);

                if (vp1 != null && vp2 != null)
                {
                    NLGElement h1 = vp1.getFeatureAsElement(InternalFeature.HEAD);
                    NLGElement h2 = vp2.getFeatureAsElement(InternalFeature.HEAD);
                    equal = h1 != null && h2 != null?h1.Equals(h2) : false;
                }
                else
                {
                    equal = false;
                }
            }

            return(equal);
        }