Exemplo n.º 1
0
        private FeatureCover(FeatureCover previousCover, FeatureInstance extendingFeature)
        {
            OriginalUtterance = previousCover.OriginalUtterance;
            _coveredPositions = previousCover._coveredPositions.ToArray();
            FeatureInstances  = previousCover.FeatureInstances.Concat(new[] { extendingFeature }).OrderBy(f => f.CoveredPositions.First()).ToArray();

            indexPositions(extendingFeature);

            FeatureKey = createFeatureKey();
        }
Exemplo 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);
        }