コード例 #1
0
        /**
         * Applies forward conjunction reduction to two NLGElements e1 and e2,
         * succeeding only if they are clauses (that is, e1.getCategory() ==
         * e2.getCategory == {@link simplenlg.framework.PhraseCategory#CLAUSE}) and
         * the clauses are not passive.
         *
         * @param previous
         *            the first phrase
         * @param next
         *            the second phrase
         * @return a coordinate phrase if aggregation is successful,
         *         <code>null</code> otherwise
         */

        public override INLGElement apply(INLGElement previous, INLGElement next)
        {
            var success = false;

            if (previous.getCategory().enumType == (int)PhraseCategoryEnum.CLAUSE &&
                previous.getCategory().enumType == (int)PhraseCategoryEnum.CLAUSE &&
                PhraseChecker.nonePassive(new List <INLGElement>()
            {
                previous, next
            }))
            {
                var leftPeriphery = PhraseChecker.leftPeriphery(new List <INLGElement>()
                {
                    previous, next
                });

                foreach (var pair in leftPeriphery)
                {
                    if (pair.lemmaIdentical())
                    {
                        pair.elideRightmost();
                        success = true;
                    }
                }
            }

            return(success
                ? factory.createCoordinatedPhrase(previous, next)
                : null);
        }