KnowledgeBase.KB.AskPossibleProperties C# (CSharp) Method

AskPossibleProperties() public method

public AskPossibleProperties ( Name property, Name perspective, IEnumerable constraints ) : IEnumerable
property Name
perspective Name
constraints IEnumerable
return IEnumerable
        public IEnumerable<BeliefPair> AskPossibleProperties(Name property, Name perspective, IEnumerable<SubstitutionSet> constraints)
        {
            if (constraints == null)
                constraints = new[] { new SubstitutionSet() };

            if (property.IsPrimitive)
            {
                if (property == Name.SELF_SYMBOL)
                    property = Perspective;

                return new[] { Tuples.Create(property, constraints) };
            }

            var ToMList = AssertPerspective(perspective, nameof(perspective));

            return internal_AskPossibleProperties(property, ToMList, constraints);
        }

Usage Example

Example #1
0
        private static IEnumerable <Pair <PrimitiveValue, SubstitutionSet> > CountPropertyCalculator(KB kb, Name perspective, IDictionary <string, Name> args, IEnumerable <SubstitutionSet> constraints)
        {
            var arg = args["x"];

            var            set   = kb.AskPossibleProperties(arg, perspective, constraints).ToList();
            PrimitiveValue count = set.Count;
            IEnumerable <SubstitutionSet> sets;

            if (set.Count == 0)
            {
                sets = constraints;
            }
            else
            {
                sets = set.SelectMany(s => s.Item2).Distinct();
            }

            foreach (var d in sets)
            {
                yield return(Tuples.Create(count, d));
            }
        }