本文整理汇总了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());
}
}
}
示例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);
}