private bool IsBlocked(FeatureStruct realizationalFS, FeatureStruct syntacticFS, HashSet <Tuple <FeatureStruct, FeatureStruct> > visited)
        {
            Tuple <FeatureStruct, FeatureStruct> pair = Tuple.Create(realizationalFS, syntacticFS);

            if (visited.Contains(pair))
            {
                return(true);
            }

            visited.Add(pair);

            foreach (Feature f in realizationalFS.Features)
            {
                if (!syntacticFS.ContainsFeature(f))
                {
                    return(false);
                }

                var cf = f as ComplexFeature;
                if (cf != null)
                {
                    FeatureStruct realFS = realizationalFS.GetValue(cf);
                    FeatureStruct synFS  = syntacticFS.GetValue(cf);
                    if (!IsBlocked(realFS, synFS, visited))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #2
0
파일: Morpher.cs 프로젝트: papeh/hermitcrab
        private bool ContainsFeature(FeatureStruct fs, Feature feature, ISet <FeatureStruct> visited)
        {
            if (visited.Contains(fs))
            {
                return(false);
            }

            if (fs.ContainsFeature(feature))
            {
                return(true);
            }

            if (fs.Features.OfType <ComplexFeature>().Any(cf => ContainsFeature(fs.GetValue(cf), feature, visited)))
            {
                return(true);
            }

            return(false);
        }
예제 #3
0
        private bool ContainsFeature(FeatureStruct fs, Feature feature, ISet<FeatureStruct> visited)
        {
            if (visited.Contains(fs))
                return false;

            if (fs.ContainsFeature(feature))
                return true;

            if (fs.Features.OfType<ComplexFeature>().Any(cf => ContainsFeature(fs.GetValue(cf), feature, visited)))
                return true;

            return false;
        }