コード例 #1
0
        public static FunctionalSet newInstance(DiscourseFunction func,
                                                IElementCategory category,
                                                Periphery periphery,
                                                List <INLGElement> components)
        {
            FunctionalSet pair = null;

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

            return(pair);
        }
コード例 #2
0
        public static List <FunctionalSet> collectFunctionalPairs(
            INLGElement phrase1, INLGElement phrase2)
        {
            var children1 = getAllChildren(phrase1);
            var children2 = getAllChildren(phrase2);
            var pairs     = new List <FunctionalSet>();

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

                for (var i = 0; i < children1.Count; i++)
                {
                    var child1 = children1[i];
                    var child2 = children2[i];
                    var cat1   = child1.getCategory();
                    var cat2   = child2.getCategory();
                    var func1  = (DiscourseFunction)child1
                                 .getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());
                    var func2 = (DiscourseFunction)child2
                                .getFeature(InternalFeature.DISCOURSE_FUNCTION.ToString());

                    if (cat1 == cat2 && func1 == func2)
                    {
                        pairs.Add(FunctionalSet.newInstance(func1, cat1, periph, new List <INLGElement> {
                            child1, child2
                        }));

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

            return(pairs);
        }