本文整理汇总了C#中Context.LookupDefaulted方法的典型用法代码示例。如果您正苦于以下问题:C# Context.LookupDefaulted方法的具体用法?C# Context.LookupDefaulted怎么用?C# Context.LookupDefaulted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.LookupDefaulted方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStarValue
public static List<IContent> GetStarValue(Context context, string name)
{
if (name.Length == 1)
return GetStarValue(context, name + "1");
return context.LookupDefaulted<List<IContent>>(name, new List<IContent>());
}
示例2: NextStarName
public static string NextStarName(Context context, string prefix)
{
string prevStarName = prefix + "#";
int prevStarCount = context.LookupDefaulted<int>(prevStarName, 0);
context.Map[prevStarName] = prevStarCount + 1;
return prefix + (prevStarCount + 1).ToString();
}
示例3: Produce
public override bool Produce(Context context, IContinuation succ, IFailure fail)
{
object var = context.LookupDefaulted<object>("$p$" + name, null);
if (var is IParsedPhrase)
succ.Continue((IParsedPhrase)var, fail);
succ.Continue(null, fail);
return true;
}
示例4: Match
public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
{
if (!(check is IParsedPhrase)) {
fail.Fail("Cannot match a " + check.GetType(), succ);
return true;
}
// Set up main check
IParsedPhrase full = (IParsedPhrase) check;
GroupPhrase sofar = context.LookupDefaulted<GroupPhrase>("$active$" + name, null);
if (sofar != null)
full = sofar.AddBranch(full);
bool? isMatch = IsMatch(full);
if (!isMatch.HasValue) {
List<IContent> contents = new List<IContent>();
contents.Add(new Value(this));
Context tryagain = new Context(context, contents);
tryagain.Map["$active$" + name] = new GroupPhrase(full);
// Continue with same context
succ.Continue(tryagain, fail);
} else {
if (isMatch.Value) {
Propogate(context, full, 1.0);
context.Map[StarUtilities.NextStarName(context, name)] = full.Text;
succ.Continue(context.ChildRange(1), fail);
} else {
fail.Fail("Does not match " + full.Text, succ);
}
}
return true;
}
示例5: Produce
public virtual IParsedPhrase Produce(Context env, POSTagger tagger, GrammarParser parser)
{
object var = env.LookupDefaulted<object>("$p$" + name, null);
if (var is ThreeTuple<GetValue, object, object[]>)
{
ThreeTuple<GetValue, object, object[]> tuple = (ThreeTuple<GetValue, object, object[]>)var;
var = tuple.one(tuple.two, tuple.three);
}
if (var is IParsedPhrase)
return (IParsedPhrase)var;
else if (var is Concept)
return ConceptToPhrase(env, (Concept)var, tagger, parser);
return null; // don't produce anything!
}
示例6: Propogate
public virtual void Propogate(Context env, object matched, double strength)
{
//object myMatched = env.LookupDefaulted<object>("$p$" + name, null);
double myStrength = env.LookupDefaulted<double>("$s$" + name, 0.0);
if (myStrength < strength)
{
env.Map["$p$" + name] = matched;
env.Map["$s$" + name] = strength;
}
}
示例7: CompletePartials
public Concept CompletePartials(Context context)
{
if (context.Contents.Count == 0)
return null;
IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);
if (phrase == null)
{
// cannot do!
context.Map["$knowPartials"] = new List<Datum>();
return null;
}
Concept concept = memory.NewConcept(phrase);
List<Datum> completes = context.LookupAndAdd<List<Datum>>("$knowCompletes", new List<Datum>());
List<Datum> data = context.LookupDefaulted<List<Datum>>("$knowPartials", new List<Datum>());
foreach (Datum datum in data)
completes.Add(memory.Know(concept, datum));
context.Map["$knowPartials"] = new List<Datum>();
return concept;
}
示例8: NextSentence
public void NextSentence(Context context, IContinuation succ, IFailure fail, params object[] args)
{
int? sentenceStart = context.LookupDefaulted<int?>("$sentences.index", null);
TwoTuple<List<IContent>, IContinuation> parts = SplitArguments(context, succ);
List<IContent> chunk = parts.one;
Context first = new Context(context, chunk);
first.Map["$sentences.index"] = sentenceStart + 1;
GroupPhrase groupPhrase = new GroupPhrase((IParsedPhrase) context.Lookup("$sentences.check"));
Matcher.MatchAgainst(salience, first, groupPhrase.GetBranch(sentenceStart.Value), new List<IParsedPhrase>(), parts.two, fail);
}
示例9: ConceptToPhrase
public override IParsedPhrase ConceptToPhrase(Context context, Concept concept, POSTagger tagger, GrammarParser parser)
{
Verbs.Person person = Verbs.Person.ThirdSingle;
object start = context.LookupDefaulted<object>("$check", null);
if (start != null && start is Datum) {
Datum noundat = KnowledgeUtilities.GetClosestDatum(memory, (Datum) start, Relations.Relation.Subject);
person = nouns.GetPerson(noundat.Right.Name);
}
return Relations.ConjugateToPhrase(memory, conjugate, person, concept);
}
示例10: GetEventConcepts
public static List<Concept> GetEventConcepts(Context env)
{
return env.LookupDefaulted<List<Concept>>("$concept$%event", new List<Concept>());
}
示例11: GetEventClauses
public static List<IParsedPhrase> GetEventClauses(Context env)
{
return env.LookupDefaulted<List<IParsedPhrase>>("$clause$%event", new List<IParsedPhrase>());
}