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


C# IContinuation.Continue方法代码示例

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


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

示例1: 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

示例2: Produce

        public override bool Produce(Context context, IContinuation succ, IFailure fail)
        {
            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);
            if (phrase == null)
            {
                succ.Continue(new Context(context, new List<IContent>()), fail);
                return true; // cannot do!
            }

            KnowPhrase(phrase, context, memory);

            succ.Continue(new Context(context, new List<IContent>()), fail);
            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:14,代码来源:KnowledgeVariables.cs

示例3: Call

        public override bool Call(object value, IContinuation succ, IFailure fail)
        {
            if (breakpointCall)
                Console.WriteLine("Breakpoint in MatchProduceAgent");
            Context context = (Context) value;
            bool production = context.LookupDefaulted<bool>("$production", false);
            if (!production)
            {
                object check = context.LookupDefaulted<object>("$check", null);

                if (check == null)
                {
                    // Matcher did not call us
                    List<IContent> contents = new List<IContent>();
                    Context child = new Context(context, contents);
                    // Put us into content stream, for matcher to find
                    contents.Add(new Value(this));
                    // Save this context-- we'll use it later!
                    child.Map["$argctx"] = context;

                    succ.Continue(child, fail);
                    return true;
                }

                Context argctx = context.LookupDefaulted<Context>("$argctx", context);
                // Add our context, shadowing variables in argctx
                Context argctxchild = argctx.ChildRange(0);
                argctxchild.AddMappings(context);

                return Match(check, argctxchild, succ, fail);
            }
            else
                return Produce(context, succ, fail);
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:34,代码来源:MatchProduceAgent.cs

示例4: Continue

 public int Continue(IContinuation cont, double salience, object value, IFailure fail)
 {
     // Clone it!
     cont = (IContinuation)cont.Clone();
     if (cont is IAgent)
         ((IAgent)cont).Initialize(this, salience);
     if (salience > 0)
         return cont.Continue(value, fail);
     return 1;
 }
开发者ID:sarang25491,项目名称:Virsona-ChatBot-Tools,代码行数:10,代码来源:ImmediateArena.cs

示例5: PrintContents

        public static bool PrintContents(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            PluginEnvironment plugenv = (PluginEnvironment) args[0];
            POSTagger tagger = new POSTagger(plugenv);
            GrammarParser parser = new GrammarParser(plugenv);

            Console.WriteLine(StarUtilities.ProducedCode(context, tagger, parser));
            succ.Continue(new Context(context, new List<IContent>()), fail);
            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:10,代码来源:OutputVariables.cs

示例6: 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

示例7: DefineInNoArgRule

        public static bool DefineInNoArgRule(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            double salience = (double) args[0];

            List<IContent> contents = context.Contents;
            string name = contents[0].Name;

            Context definition = context.ChildRange(1);
            context.Map.Add(name, new CallAgentWrapper(EvaluateDefinition, ArgumentMode.NoArugments, salience, definition.Size, 10, salience, definition));

            Context empty = new Context(context, new List<IContent>());
            succ.Continue(empty, fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:15,代码来源:ProgramVariables.cs

示例8: Call

        public override bool Call(object value, IContinuation succ, IFailure fail)
        {
            Context context = (Context) value;

            double result = 0;

            foreach (IContent content in context.Contents)
            {
                double term = 0;
                if (content is Word && double.TryParse(content.Name, out term))
                    result += term;
                else
                {
                    fail.Fail("Argument isn't number", succ);
                    return true;
                }
            }

            List<IContent> cntres = new List<IContent>();
            cntres.Add(new Word(result.ToString()));
            succ.Continue(new Context(context, cntres), fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:24,代码来源:MathVariables.cs

示例9: ConstructSentence

        public bool ConstructSentence(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            // Need to produce all my contents!
            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);
            if (phrase == null)
            {
                // oops, we failed to produce
                fail.Fail("Context could not be produced", succ);
                return true;
            }

            if (!(phrase.Part == "=P"))
            {
                if (phrase.Part == "FRAG" || phrase.Part == "S" || phrase.Part == "SBARQ")
                {
                    if (final != null)
                    {
                        GroupPhrase groupPhrase = new GroupPhrase(phrase);
                        IParsedPhrase last = groupPhrase.GetBranch(groupPhrase.Count - 1);
                        if (!(last.Part == "." || last.Part == "!" || last.Part == "?")) {
                            List<IParsedPhrase> branches = new List<IParsedPhrase>();
                            branches.AddRange(phrase.Branches);
                            branches.Add((IParsedPhrase)final.Clone());
                            phrase = new GroupPhrase(phrase.Part, branches);
                        }
                    }
                }
                else
                {
                    List<IParsedPhrase> branches = new List<IParsedPhrase>();
                    branches.Add(phrase);
                    if (final != null)
                        branches.Add((IParsedPhrase)final.Clone());
                    phrase = new GroupPhrase("FRAG", branches);
                }
            }

            List<IContent> contents = new List<IContent>();
            contents.Add(new Word(phrase.Text));
            Context child = new Context(context, contents);
            succ.Continue(child, fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:44,代码来源:GrammarVariables.cs

示例10: PropogateOnClear

        // This will call success either way, but only propogate if context is empty
        public bool PropogateOnClear(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            if (context.IsEmpty || (context.Contents.Count == 1 && context.Contents[0].Name.StartsWith("*")))
            {
                string name = (string) args[0];
                object check = args[1];

                Variable dummy = new Variable(name);
                dummy.Propogate(context, check, context.Weight);
            }

            succ.Continue(context, fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:16,代码来源:MatchProduceAgent.cs

示例11: DefinePhraseChoiceVariable

        public static bool DefinePhraseChoiceVariable(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            List<IContent> contents = context.Contents;
            string name = contents[0].Name;
            PluginEnvironment plugenv = (PluginEnvironment) args[0];

            List<List<string>> options = new List<List<string>>();
            List<string> curropt = new List<string>();
            for (int ii = 1; ii < contents.Count; ii++) {
                if (contents[ii] == Special.ArgDelimSpecial) {
                    options.Add(curropt);
                    curropt = new List<string>();
                } else
                    curropt.Add(contents[ii].Name.ToLower());
            }
            options.Add(curropt);

            context.Map.Add(name, new PhraseChoiceVariable(name, options, plugenv, (WordComparer) context.LookupSimple("$Compare")));

            Context empty = new Context(context, new List<IContent>());
            succ.Continue(empty, fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:24,代码来源:ProgramVariables.cs

示例12: DefineWordChoiceVariable

        public static bool DefineWordChoiceVariable(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            List<IContent> contents = context.Contents;
            string name = contents[0].Name;
            bool isVerbChoice = (bool) args[0];
            PluginEnvironment plugenv = (PluginEnvironment) args[1];

            List<string> options = new List<string>();
            for (int ii = 1; ii < contents.Count; ii++)
                options.Add(contents[ii].Name.ToLower());

            if (isVerbChoice)
                context.Map.Add(name, new VerbChoiceVariable(name, options, plugenv, (WordComparer) context.LookupSimple("$Compare")));
            else
                context.Map.Add(name, new WordChoiceVariable(name, options, (WordComparer) context.LookupSimple("$Compare")));

            Context empty = new Context(context, new List<IContent>());
            succ.Continue(empty, fail);

            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:21,代码来源:ProgramVariables.cs

示例13: Match

        public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            Concept concept = (Concept) context.Lookup("$knowConcept");
            if (context.Contents.Count == 1)
            {
                if (context.Contents[0] is Variable)
                {
                    Variable left = (Variable)context.Contents[0];
                    if (left.Match(context, concept))
                        succ.Continue(new Context(context, new List<IContent>()), fail);
                    else
                        fail.Fail("Left doesn't match context", succ);
                    return true;
                }
                else if (context.Contents[0].Name == "*" || context.Contents[0].Name == "_")
                {
                    List<IContent> words = new List<IContent>();
                    words.Add(new Word(concept.Name));
                    context.Map.Add(StarUtilities.NextStarName(context, context.Contents[0].Name), words);

                    succ.Continue(new Context(context, new List<IContent>()), fail);
                    return true;
                }
            }

            fail.Fail("Know given multiple values", succ);
            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:28,代码来源:KnowledgeVariables.cs

示例14: Call

        public override bool Call(object value, IContinuation succ, IFailure fail)
        {
            Context context = (Context) value;
            if (principleSource == null || assertionSource == null) {
                fail.Fail("ConceptNet sources missing", succ);
                return true;
            }

            Notion concept;
            if (!principleSource.TryGetValue(StarUtilities.ContentsCode(context, tagger, parser), out concept))
            {
                fail.Fail("Could not find produced in ConceptNet", succ);
                return true;
            }

            List<Assertion> assertions;
            if (!assertionSource.TryGetValue(new KeyValuePair<Notion, string>(concept, relation), out assertions))
                assertions = new List<Assertion>();

            List<IContent> contents = new List<IContent>();

            foreach (Assertion assertion in assertions)
            {
                contents.Add(new Word(assertion.Sentence));
                contents.Add(new Word(" ."));
            }

            succ.Continue(new Context(context, contents), fail);
            return true;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:30,代码来源:AbstractVariables.cs


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