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


C# Context.LookupDefaulted方法代码示例

本文整理汇总了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>());
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:7,代码来源:StarUtilities.cs

示例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();
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:7,代码来源:StarUtilities.cs

示例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;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:11,代码来源:ProgressiveVariableAgent.cs

示例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;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:36,代码来源:ProgressiveVariableAgent.cs

示例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!
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:16,代码来源:Variable.cs

示例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;
            }
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:11,代码来源:Variable.cs

示例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;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:24,代码来源:KnowledgeVariables.cs

示例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);
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:13,代码来源:GrammarVariables.cs

示例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);
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:12,代码来源:GrammarVariables.cs

示例10: GetEventConcepts

 public static List<Concept> GetEventConcepts(Context env)
 {
     return env.LookupDefaulted<List<Concept>>("$concept$%event", new List<Concept>());
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:4,代码来源:GrammarVariables.cs

示例11: GetEventClauses

 public static List<IParsedPhrase> GetEventClauses(Context env)
 {
     return env.LookupDefaulted<List<IParsedPhrase>>("$clause$%event", new List<IParsedPhrase>());
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:4,代码来源:GrammarVariables.cs


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