Esempio n. 1
0
        public void GenerateMappingUris(DialogVariablesSimulator dialogVariables, MappingUriGenerator.MappingUriConfig mappingUriConfig, IDictionary <string, IDictionary <string, IList <string> > > arraysOfAllowedValuesByEntityNameAndFederation)
        {
            EntityVariablesNotExplicitlySet = dialogVariables.ResetEntityVariablesNotExplicitlySet(MappingUriGenerator.GetEntityVariables(mappingUriConfig));
            bool redirectToLongTail;

            MappingUris = MappingUriGenerator.GenerateMappingURIs(dialogVariables, mappingUriConfig, arraysOfAllowedValuesByEntityNameAndFederation, out redirectToLongTail);
            if (redirectToLongTail)
            {
                Type = DialogNodeType.RedirectToLongTail;
            }
        }
Esempio n. 2
0
        // Return a List of pair {URI, Question} from a dialog file and a question file
        private static List <String[]> MapQuestionUri(FileInfo sourceOrDialogFileInfo, FileInfo annotatedQuestionsFileInfo)
        {
            // Load new dialog file
            string sourceOrDialogFileName;
            Dialog dialog = LoadDialogFile(sourceOrDialogFileInfo, out sourceOrDialogFileName);

            List <String[]> resultList = new List <String[]>();

            using (StreamReader sr = new StreamReader(annotatedQuestionsFileInfo.FullName, Encoding.GetEncoding("UTF-8")))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] columns      = line.Split(';');
                    string   questionId   = columns[0];
                    string   questionText = columns[1];
                    string   intentName   = columns[2];

                    // Simulate new dialog execution
                    var result = DialogInterpreter.AnalyzeInitialQuestion(dialog, questionId, questionText, intentName);
                    var type   = result.ExecutionResult != null?result.ExecutionResult.DialogNode.Type.ToString() : "[no result]";

                    if (type == "FatHeadAnswers")
                    {
                        var node = result.ExecutionResult as FatHeadAnswerNodeExecution;

                        if (node != null)
                        {
                            var newURI = node.MappingURI;

                            List <String> listUriWithFederation = MappingUriGenerator.AddFederationsToUri(newURI);
                            foreach (string uriTemp in listUriWithFederation)
                            {
                                string[] temp = { uriTemp, questionText };
                                resultList.Add(temp);
                            }
                        }
                    }
                }
            }

            return(resultList);
        }
Esempio n. 3
0
        private static void ExecuteFatHeadNode(Dialog dialog, IDictionary <string, string> variablesValues, FatHeadAnswers fatHeadAnswerNode, DialogExecutionResult result)
        {
            // Adjust variables values
            ExecuteVariableAssignments(fatHeadAnswerNode, variablesValues);

            // Build the mapping URI
            bool redirectToLongTail;
            bool directAnswserValueNotSupportedInFederation;
            var  mappingUri = MappingUriGenerator.ComputeMappingURI(variablesValues, dialog.MappingUriConfig, out redirectToLongTail, out directAnswserValueNotSupportedInFederation);

            // Store the result of this execution
            DialogNodeExecution nodeExecution = null;

            if (redirectToLongTail || directAnswserValueNotSupportedInFederation || String.IsNullOrEmpty(mappingUri))
            {
                nodeExecution = new DialogNodeExecution(fatHeadAnswerNode);
            }
            else
            {
                nodeExecution = new FatHeadAnswerNodeExecution(fatHeadAnswerNode, mappingUri);
            }
            result.AddDialogNodeExecution(nodeExecution);
        }