コード例 #1
0
        public ViewGenerator(Dialog dialog, string answerstoreFile)
        {
            Intents     = new List <Intent>();
            answerStore = new AnswerStoreSimulator(answerstoreFile);

            foreach (var intent in dialog.Intents.Values.OrderBy(i => i.Name))
            {
                List <ViewNode> conditions = new List <ViewNode>();

                foreach (var node in intent.ChildrenNodes)
                {
                    conditions.Add(ReadRoot(node));
                }

                Intents.Add(new Intent(intent.Name, conditions, intent.Questions));
            }
        }
コード例 #2
0
        //Constructor
        public ViewNode(DialogNode node, AnswerStoreSimulator answerStore)
        {
            Children      = new List <ViewNode>();
            DisplayValues = new List <DisplayValue>();
            Type          = node.Type;
            List <DialogVariableAssignment> assignList = new List <DialogVariableAssignment>();

            if (node.Type == DialogNodeType.DialogVariableConditions)
            {
                foreach (var condition in ((DialogVariableConditions)node).VariableConditions)
                {
                    //If we force the value of another entity
                    //Extract the assignements
                    if (node.ChildrenNodes != null && node.ChildrenNodes.Count > 0)
                    {
                        foreach (var child in node.ChildrenNodes)
                        {
                            if (child.VariableAssignments != null && child.VariableAssignments.Count > 0)
                            {
                                foreach (var assign in child.VariableAssignments)
                                {
                                    assignList.Add(assign);
                                }
                            }
                        }
                    }


                    if (assignList.Count > 0)
                    {
                        DisplayValues.Add(new DisplayValue(condition, assignList));
                    }
                    else
                    {
                        DisplayValues.Add(new DisplayValue(condition));
                    }
                }
            }
            else
            {
                DisplayValues.Add(new DisplayValue(node, answerStore));
            }
        }
コード例 #3
0
        //Constructor Overload
        public DisplayValue(DialogNode node, AnswerStoreSimulator answerStore)
        {
            Value      = Variable = " ";
            Attributes = new List <Attribute>();

            switch (node.Type)
            {
            case DialogNodeType.DisambiguationQuestion:

                string question = ((DisambiguationQuestion)node).QuestionText;

                if (((DisambiguationQuestion)node).DisambiguationOptions != null)
                {
                    foreach (var option in ((DisambiguationQuestion)node).DisambiguationOptions)
                    {
                        question = question + " \r\n -" + option.Text;
                    }
                }
                else
                {
                    question += "\r\n - Attention, absence d'option de désambiguïsation";
                }

                Value    = "Question";
                Type     = DisplayValueType.Question;
                Variable = " ";
                Attributes.Add(new Attribute("title", question));

                break;

            case DialogNodeType.FatHeadAnswers:

                string[] URI = ((FatHeadAnswers)node).MappingUris;

                Value    = "Réponse";
                Type     = DisplayValueType.Answer;
                Variable = " ";
                string uriattribute = "";
                string reponse      = "";
                int    i            = 0;

                foreach (var uri in URI)
                {
                    if (answerStore.GetAnswerUnitForMappingUri(uri) != null)
                    {
                        reponse = answerStore.GetAnswerUnitForMappingUri(uri).content.plainText;
                    }
                    else
                    {
                        reponse = "introuvable dans l'Answer Store";
                    }

                    if (i > 0)
                    {
                        uriattribute += "<br>" + "URI :  " + uri + " <br>" + "Réponse : <br>" + reponse;
                        HiddenInfo   += "<br>" + "<i>" + uri + "</i>";
                    }
                    else
                    {
                        HiddenInfo  += "<font color = \"#808080\" size = \"2\" >" + "<br>" + "<i>" + uri + "</i>";
                        uriattribute = "<font size = \"2\" >" + "URI : " + uri + "<br>" + "Réponse : <br>" + reponse;
                    }

                    i += 1;
                }

                if (i > 0)
                {
                    uriattribute += "</font>";
                    HiddenInfo   += "</font>";
                }



                Attributes.Add(new Attribute("title", uriattribute + reponse));
                SecondaryInfo = uriattribute + reponse;

                break;

            case DialogNodeType.RedirectToLongTail:

                Value = "Redirection en Long Tail";
                break;

            default:
                Value = "root";
                break;
            }
        }