Example #1
0
        /// <summary>
        /// Load a Social Importance Asset definition from a DTO object.
        /// </summary>
        /// <remarks>
        /// Use this to procedurally configure the asset.
        /// </remarks>
        /// <param name="dto">
        /// The DTO containing the data to load
        /// </param>
        public void LoadFromDTO(SocialImportanceDTO dto)
        {
            m_attributionRules.Clear();
            m_attributionRules.UnionWith(dto.AttributionRules.Select(adto => new AttributionRule(adto)));

            m_claimTree.Clear();
        }
        public void LoadFromDTO(SocialImportanceDTO dto)
        {
            m_attributionRules = dto.AttributionRules.Select(adto => new AttributionRule(adto)).ToArray();

            m_claimTree.Clear();
            if (dto.Claims != null)
            {
                foreach (var c in dto.Claims)
                {
                    var n = Name.BuildName(c.ActionTemplate);
                    m_claimTree.Add(n, c.ClaimSI);
                }
            }

            //TODO load the rest
        }
Example #3
0
        private static SocialImportanceAsset BuildAsset()
        {
            var ea = new EmotionalAppraisalAsset("Matt");

            #region Set KB

            ea.Kb.Tell((Name)"IsPerson(Matt)", true, Name.UNIVERSAL_SYMBOL);
            ea.Kb.Tell((Name)"IsPerson(Mary)", true, Name.UNIVERSAL_SYMBOL);
            ea.Kb.Tell((Name)"IsPerson(Diego)", true, Name.UNIVERSAL_SYMBOL);
            ea.Kb.Tell((Name)"IsPerson(Thomas)", true, Name.UNIVERSAL_SYMBOL);
            ea.Kb.Tell((Name)"IsPerson(Robot)", true, (Name)"Diego");
            ea.Kb.Tell((Name)"IsOutsider(Diego)", true, Name.UNIVERSAL_SYMBOL);
            ea.Kb.Tell((Name)"IsOutsider(Diego)", false, (Name)"Robot");
            ea.Kb.Tell((Name)"AreFriends(Self,Mary)", true, Name.SELF_SYMBOL);
            ea.Kb.Tell((Name)"AreFriends(Self,Matt)", true, (Name)"Mary");
            ea.Kb.Tell((Name)"AreFriends(Self,Thomas)", true, Name.SELF_SYMBOL);

            #endregion
            #region SI DTO especification
            var siDTO = new SocialImportanceDTO
            {
                AttributionRules = new[]
                {
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = 20,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "IsPerson([target]) = true"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "[target] != Self"
                                }
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = -1,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "IsOutsider([target]) = true"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "[target] != Self"
                                }
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = 15,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "AreFriends(Self,[target]) = true"
                                }
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = 10,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "IsClient([target]) = true"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "IsBartender(Self) = true"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "[target] != Self"
                                }
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = 1,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "IsElder([target]) = true"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "IsElder(Self) = false"
                                }
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = "[target]",
                        Value      = -1,
                        Conditions = new ConditionSetDTO()
                        {
                            Set = new []
                            {
                                new ConditionDTO()
                                {
                                    Condition = "IsElder([target]) = false"
                                },
                                new ConditionDTO()
                                {
                                    Condition = "IsElder(Self) = true"
                                }
                            }
                        }
                    }
                }
            };
            #endregion
            var si = new SocialImportanceAsset();
            si.LoadFromDTO(siDTO);

            si.RegisterEmotionalAppraisalAsset(ea);
            return(si);
        }
Example #4
0
        private static SocialImportanceAsset BuildAsset()
        {
            var kb = new KB((Name)"Matt");

            #region Set KB
            kb.Tell((Name)"IsPerson(Matt)", (Name)"true", (Name)"*");
            kb.Tell((Name)"IsPerson(Mary)", (Name)"true", (Name)"*");
            kb.Tell((Name)"IsPerson(Thomas)", (Name)"true", (Name)"*");
            kb.Tell((Name)"IsPerson(Diego)", (Name)"true", (Name)"*");
            kb.Tell((Name)"IsPerson(Robot)", (Name)"true", (Name)"Diego");
            kb.Tell((Name)"IsOutsider(Diego)", (Name)"true", (Name)"*");
            kb.Tell((Name)"IsOutsider(Diego)", (Name)"false", (Name)"Robot");
            kb.Tell((Name)"AreFriends(SELF,Mary)", (Name)"true", (Name)"SELF");
            kb.Tell((Name)"AreFriends(SELF,Matt)", (Name)"true", (Name)"Mary");
            kb.Tell((Name)"AreFriends(SELF,Thomas)", (Name)"true", (Name)"SELF");
            kb.Tell((Name)"IsBartender(Matt)", (Name)"true", (Name)"*");

            #endregion

            #region SI DTO especification
            var siDTO = new SocialImportanceDTO
            {
                AttributionRules = new[]
                {
                    new AttributionRuleDTO()
                    {
                        Target     = (Name)"[target]",
                        Value      = (Name)"[v]",
                        Conditions = new ConditionSetDTO()
                        {
                            ConditionSet = new []
                            {
                                "IsPerson([target]) = true",
                                "[target] != Self",
                                "[v] = 20"
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = (Name)"[target]",
                        Value      = (Name)"-1",
                        Conditions = new ConditionSetDTO()
                        {
                            ConditionSet = new []
                            {
                                "IsOutsider([target]) = true",
                                "[target] != Self"
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = (Name)"[target]",
                        Value      = (Name)"15",
                        Conditions = new ConditionSetDTO()
                        {
                            ConditionSet = new []
                            {
                                "AreFriends(Self,[target]) = true"
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = (Name)"[target]",
                        Value      = (Name)"10",
                        Conditions = new ConditionSetDTO()
                        {
                            ConditionSet = new []
                            {
                                "IsClient([target]) = true",
                                "IsBartender(Self) = true",
                                "[target] != Self"
                            }
                        }
                    },
                    new AttributionRuleDTO()
                    {
                        Target     = (Name)"[target]",
                        Value      = (Name)"1",
                        Conditions = new ConditionSetDTO()
                        {
                            ConditionSet = new []
                            {
                                "IsElder([target]) = true",
                                "IsElder(Self) = false"
                            }
                        }
                    }
                }
            };
            #endregion
            var si = new SocialImportanceAsset();
            si.RegisterKnowledgeBase(kb);
            return(si);
        }