示例#1
0
        public static FunctionalSet newInstance(DiscourseFunction func, ElementCategory category, Periphery periphery, params NLGElement[] components)
        {
            FunctionalSet pair = null;

            if (components.Length >= 2)
            {
                pair = new FunctionalSet(func, category, periphery, components);
            }

            return(pair);
        }
        public static IList <FunctionalSet> collectFunctionalPairs(NLGElement phrase1, NLGElement phrase2)
        {
            IList <NLGElement>    children1 = getAllChildren(phrase1);
            IList <NLGElement>    children2 = getAllChildren(phrase2);
            IList <FunctionalSet> pairs     = new List <FunctionalSet>();

            if (children1.Count == children2.Count)
            {
                Periphery periph = Periphery.LEFT;

                for (int i = 0; i < children1.Count; i++)
                {
                    NLGElement        child1 = children1[i];
                    NLGElement        child2 = children2[i];
                    ElementCategory   cat1   = child1.Category;
                    ElementCategory   cat2   = child2.Category;
                    DiscourseFunction func1  = (DiscourseFunction)child1.getFeature(InternalFeature.DISCOURSE_FUNCTION);
                    DiscourseFunction func2  = (DiscourseFunction)child2.getFeature(InternalFeature.DISCOURSE_FUNCTION);

                    if (cat1 == cat2 && func1 == func2)
                    {
                        pairs.Add(FunctionalSet.newInstance(func1, cat1, periph, child1, child2));

                        if (cat1 == LexicalCategory.LexicalCategoryEnum.VERB)
                        {
                            periph = Periphery.RIGHT;
                        }
                    }
                    else
                    {
                        pairs.Clear();
                        break;
                    }
                }
            }

            return(pairs);
        }