当前位置: 首页>>代码示例>>C#>>正文


C# Name.ApplyToTerms方法代码示例

本文整理汇总了C#中Name.ApplyToTerms方法的典型用法代码示例。如果您正苦于以下问题:C# Name.ApplyToTerms方法的具体用法?C# Name.ApplyToTerms怎么用?C# Name.ApplyToTerms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Name的用法示例。


在下文中一共展示了Name.ApplyToTerms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: internal_AskPossibleProperties

        private IEnumerable<BeliefPair> internal_AskPossibleProperties(Name property, List<Name> ToMList, IEnumerable<SubstitutionSet> constraints)
        {
            property = RemovePropertyPerspective(property, ToMList);

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            var mind_key = ToMList2Key(ToMList);
            if (!property.IsVariable)
            {
                bool dynamicFound = false;
                foreach (var r in AskDynamicProperties(property, mind_key, constraints))
                {
                    dynamicFound = true;
                    yield return r;
                }
                if (dynamicFound)
                    yield break;
            }

            var group = constraints.GroupBy(property.MakeGround);

            foreach (var g in group)
            {
                if (g.Key.IsPrimitive)
                {
                    yield return Tuples.Create(g.Key, (IEnumerable<SubstitutionSet>)g);
                    continue;
                }

                Name fact;
                try
                {
                    fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));
                }
                catch (Exception)
                {
                    continue;
                }

                var g2 = g.SelectMany(c => m_knowledgeStorage.Unify(fact, c)).GroupBy(r => r.Item1, r => r.Item2);
                foreach (var r in g2)
                {
                    var value = r.Key.GetValueFor(mind_key);
                    if (value == null)
                        continue;
                    yield return Tuples.Create(value, r.Distinct());
                }
            }
        }
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:50,代码来源:KB.cs

示例2: Tell

        public void Tell(Name property, Name value, Name perspective)
        {
            if (property.IsPrimitive)
                throw new ArgumentException("The given property name cannot be a primitive value.",nameof(property));

            if (!property.IsConstant)
                throw new ArgumentException("The given property name is not constant. Only constant names can be stored",nameof(property));

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

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            if (m_dynamicProperties.Unify(property).Any())
                throw new ArgumentException("The given name will be objuscated by a dynamic property", nameof(property));

            var fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));

            KnowledgeEntry entry;
            if (!m_knowledgeStorage.TryGetValue(fact, out entry))
            {
                entry = new KnowledgeEntry();
                m_knowledgeStorage[fact] = entry;
            }

            var mind_key = ToMList2Key(ToMList);
            entry.TellValueFor(mind_key,value);
            if (entry.IsEmpty())
                m_knowledgeStorage.Remove(fact);
        }
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:31,代码来源:KB.cs


注:本文中的Name.ApplyToTerms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。