Ejemplo n.º 1
0
        public ArrayList Start()
        {
            Console.WriteLine("Map.DialogueManager: Start");
            Console.WriteLine("contex=" + this._context);
            ArrayList respList = new ArrayList();

            this._planGraph  = new PlanGraph(this._kbase, this._exec);
            this._isRunning  = true;
            this._currDlgAct = null;

            ArrayList actionList = this._kbase.GetTopActions(this._context);

            if (actionList.Count > 0)
            {
                PlainOptionListData respContent = new PlainOptionListData();
                respContent.Opening = "What can I do for you?";
                foreach (Hashtable actionInfo in actionList)
                {
                    respContent.AddOption(new PlainOptionItemData(actionInfo["act_name"].ToString(), actionInfo["description"].ToString()));
                }
                respList.Add(new DialogueResponse(DialogueResponseType.listPlainOptions, respContent));
            }

            return(respList);
        }
Ejemplo n.º 2
0
 public ListPlainOptionsWindow(PlainOptionListData optionListData)
 {
     InitializeComponent();
     this._optionListData      = optionListData;
     this.HeadingTB.Text       = this._optionListData.Opening;
     this.OptionLB.ItemsSource = this._optionListData.Options;
     this._selectedItem        = null;
 }
Ejemplo n.º 3
0
 public ListPlainOptionsWindow(PlainOptionListData optionListData)
 {
     InitializeComponent();
     this._optionListData = optionListData;
     this.HeadingTB.Text = this._optionListData.Opening;
     this.OptionLB.ItemsSource = this._optionListData.Options;
     this._selectedItem = null;
     
 }
Ejemplo n.º 4
0
        public ArrayList Start()
        {
            ArrayList respList = new ArrayList();
            this._planGraph = new PlanGraph(this._kbase, this._exec);
            this._isRunning = true;
            this._currDlgAct = null;

            ArrayList actionList = this._kbase.GetTopActions(this._context);

            if (actionList.Count > 0)
            {
                PlainOptionListData respContent = new PlainOptionListData();
                respContent.Opening = "What can I do for you?";
                foreach (Hashtable actionInfo in actionList)
                {
                    respContent.AddOption(new PlainOptionItemData(actionInfo["act_name"].ToString(), actionInfo["description"].ToString()));
                }
                respList.Add(new DialogueResponse(DialogueResponseType.listPlainOptions, respContent));
            }
            
            return respList;
        }
Ejemplo n.º 5
0
        private ArrayList SelectFromCandidates(ActionNode actionNode, DialogueAct currDlgAct)
        {
            ArrayList respList = new ArrayList();

            if (actionNode.ActState == ActionState.Initiated)
            {
                // change its own state
                actionNode.ActState = ActionState.Executing;

                // do something: generate the candiate list           
                respList.Add(new DialogueResponse(DialogueResponseType.debugInfo, "Basic Action: SelectFromCandidates"));

                ParamNode paramNode = (ParamNode)actionNode.Parent;

                if (paramNode.Name == "admin_area")
                {
                    // fixed at the moment, future work will search the database to generat the list
                    PlainOptionListData respContent = new PlainOptionListData();
                    respContent.Opening = this._generateQuestionString(paramNode);
                    respContent.AddOption(new PlainOptionItemData("City of Oleader", "Matched feature classes: LandUse"));
                    respContent.AddOption(new PlainOptionItemData("City of Rochester", "Matched feature classes: LandUse, Parcels"));
                    respContent.AddOption(new PlainOptionItemData("City of Baltimore", "Matched feature classes: Parcels, Dwelling units"));
                    respList.Add(new DialogueResponse(DialogueResponseType.listPlainOptions, respContent));
                    return respList;
                }                
            }
            // if the action is executing, try to check whether the current input answers the question
            else if (actionNode.ActState == ActionState.Executing)
            {
                ParamNode paramNode = (ParamNode)actionNode.Parent;
                foreach (string phrase in currDlgAct.SpeechContext.Keys)
                {
                    if (phrase.ToLower() == paramNode.Name.ToLower())
                    {
                        object newValue = this._parseValueFromSpeech(paramNode, currDlgAct.SpeechContext[phrase]);
                        if (newValue != null)
                        {
                            this._addValueToParam(paramNode, newValue);

                            // change its own state
                            actionNode.ActState = ActionState.Complete;

                            // generate response 
                            
                            if (paramNode.ParamType == "data_source")
                            {
                                // fixed at the moment
                                string dataSourcePath = @"..\..\..\Data\GISLAB\Data\";
                                foreach (string value in paramNode.Values)
                                {
                                    string filePath = System.IO.Path.Combine(dataSourcePath, value + ".mxd");
                                    if (System.IO.File.Exists(filePath))
                                    {
                                        respList.Add(new DialogueResponse(DialogueResponseType.mapDocumentOpened, filePath));
                                        respList.Add(new DialogueResponse(DialogueResponseType.speechInfo, "The map of " + value + " is loaded!"));
                                        break;
                                    }
                                }
                            }
                            return respList;
                        }
                    }
                }   
            }

            
            // change its own state
            actionNode.ActState = ActionState.Complete;
            // generate response 
            return respList;
        }