Esempio n. 1
0
        internal static IEnumerable <FeatureCover> GetFeatureCovers(ParsedUtterance expression, ComposedGraph graph)
        {
            var features = createFeatures(expression, graph);
            var index    = new FeatureIndex(features);

            return(generateCovers(index, 0, expression));
        }
Esempio n. 2
0
        private static IEnumerable <FeatureCover> generateCovers(FeatureIndex index, int currentPosition, ParsedUtterance expression)
        {
            if (index.Length == 0)
            {
                //there are no possible covers
                return(new FeatureCover[0]);
            }

            if (index.Length - 1 == currentPosition)
            {
                //we are at bottom of recursion
                //we will initiate covers that will be extended later through the recursion

                var newCovers = new List <FeatureCover>();
                foreach (var feature in index.GetFeatures(currentPosition))
                {
                    var cover = new FeatureCover(feature, expression);
                    newCovers.Add(cover);
                }

                return(newCovers);
            }

            //extend covers that we got from deeper recursion
            var previousCovers = generateCovers(index, currentPosition + 1, expression);
            var extendedCovers = new List <FeatureCover>();

            foreach (var cover in previousCovers)
            {
                foreach (var feature in index.GetFeatures(currentPosition))
                {
                    extendedCovers.AddRange(cover.Extend(feature));
                }
            }

            return(extendedCovers);
        }