public TreeFrom(FeatureGraph featGraph, bool flag)
 {
     this.canDisplay = true;
     this.featGraph = featGraph;
     this.flag = flag;
     InitializeComponent();
     refreshTreeView();
 }
Пример #2
0
        public Form1()
        {
            queryCounter = 0;
            selectedIndex = -1;
            featGraph = new FeatureGraph();
            toChange = null;
            currentFileName = "";
            updateFlag = false;

            InitializeComponent();

            //set up tooltip
            toolTip1 = new ToolTip();
            toolTip1.AutoPopDelay = 5000;
            toolTip1.InitialDelay = 1000;
            toolTip1.ReshowDelay = 500;
            toolTip1.ShowAlways = true;

            //Add enter method
            textBox1.KeyDown += new KeyEventHandler(this.featureCreateTextBox1_KeyDown);
            //Add tooltip method to childrenCheckedListBox
            childrenCheckedListBox.MouseHover += new EventHandler(childrenCheckedListBox_MouseHover);
            childrenCheckedListBox.MouseMove += new MouseEventHandler(childrenCheckedListBox_MouseMove);
            //check event handle
            childrenCheckedListBox.ItemCheck += new ItemCheckEventHandler(childrenCheckedListBox_ItemCheck);
            //right click event for adding relationship
            childrenCheckedListBox.MouseDown += new MouseEventHandler(childrenCheckedListBox_RightClick);
            //Add shortcuts
            textBox7.KeyUp += new KeyEventHandler(this.textBox7_KeyUp);

            //Add lostFocuse Method
            firstArgumentTextBox.LostFocus += textBoxFocusLost;
            thirdArgumentTextBox.LostFocus += textBoxFocusLost;

            //Add closing method
            this.FormClosing += Window_Closing;
            shouldIgnoreCheckEvent = true;
            if (backgroundWorker1.IsBusy != true)
            {
                backgroundWorker1.RunWorkerAsync();
            }

            //sorted list
            sortedChildrenComboBox.SelectedIndexChanged += new EventHandler(SortedChildrenComboBox_SelectedIndexChanged);
            sortedFeatureComboBox.SelectedIndexChanged += new EventHandler(SortedFeatureComboBox_SelectedIndexChanged);
            featureEditorListBox.Sorted = true;
            childrenCheckedListBox.Sorted = true;

            openDefaultXMLFile();
            openDefaultConstraintFile();

            //Open the query window
            openQueryWindow();
        }
 public FeatureSpeaker(FeatureGraph featG,List<TemporalConstraint> myTemporalConstraintList)
 {
     setFilterNodes();
     //define dramaticFunction manually here
     this.temporalConstraintList = new List<TemporalConstraint>();
     for (int x = 0; x < myTemporalConstraintList.Count(); x++)
     {
         this.temporalConstraintList.Add(new TemporalConstraint(myTemporalConstraintList[x].FirstArgument,
             myTemporalConstraintList[x].SecondArgument, myTemporalConstraintList[x].ThirdArgument,
             myTemporalConstraintList[x].FourthArgument, myTemporalConstraintList[x].FifthArgument));
     }
     this.featGraph = featG;
     expectedDramaticV = new double[20] { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
 }
 public FeatureSpeaker(FeatureGraph featG, List<TemporalConstraint> myTemporalConstraintList,string prevSpatial,List<string> topicH)
 {
     setFilterNodes();
     this.temporalConstraintList = new List<TemporalConstraint>();
     for (int x = 0; x < myTemporalConstraintList.Count();x++ )
     {
         this.temporalConstraintList.Add(new TemporalConstraint(myTemporalConstraintList[x].FirstArgument,
             myTemporalConstraintList[x].SecondArgument, myTemporalConstraintList[x].ThirdArgument,
             myTemporalConstraintList[x].FourthArgument,myTemporalConstraintList[x].FifthArgument));
     }
     this.featGraph = featG;
     previousSpatial = prevSpatial;
     this.topicHistory = new List<string>(topicH);
     //define dramaticFunction manually here
     expectedDramaticV = new double[20] { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
 }
Пример #5
0
 public Form2(FeatureGraph myGraph, List<TemporalConstraint> myTemporalConstraintList)
 {
     InitializeComponent();
     //pre-process shortest distance
     myGraph.getMaxDistance();
     this.featGraph = myGraph;
     this.temporalConstraintList = myTemporalConstraintList;
     //clear discussedAmount
     for (int x = 0; x < featGraph.Features.Count(); x++)
     {
         featGraph.Features[x].DiscussedAmount = 0;
     }
     featureWeight = .6f;
     tagKeyWeight = .2f;
     chatBox.AppendText("Hello, and Welcome to the Query. \r\n");
     inputBox.KeyDown += new KeyEventHandler(this.inputBox_KeyDown);
     this.FormClosing += Window_Closing;
 }
 public Searcher(FeatureGraph newGraph, Form1 parent)
 {
     myParent = parent;
     featGraph = newGraph;
     InitializeComponent();
 }
Пример #7
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.Title = "Choose the XML file you want to load";
     openFileDialog1.FileName = "";
     openFileDialog1.Multiselect = false;
     openFileDialog1.CheckFileExists = true;
     openFileDialog1.Filter = "XML File|*.xml|All Files|*";
     openFileDialog1.ShowDialog();
     if (openFileDialog1.FileName != "" && openFileDialog1.CheckFileExists)
     {
         currentFileName = openFileDialog1.FileName;
         featGraph = XMLFilerForFeatureGraph.readFeatureGraph(openFileDialog1.FileName);
         selectedIndex = -1;
         refreshAllButUpdateFeature();
         tagListBox.Items.Clear();
         listBox3.Items.Clear();
         childrenCheckedListBox.Items.Clear();
         clearAllTextBoxes();
         this.Text = "Data Entry - Concept Graph : " + currentFileName;
     }
 }
Пример #8
0
 //Open the default file
 private void openDefaultXMLFile()
 {
     string defaultFile = Directory.GetCurrentDirectory() + defaultFilename;
     Console.WriteLine(defaultFile);
     if (File.Exists(defaultFile))
     {
         //Open it
         currentFileName = defaultFile;
         featGraph = XMLFilerForFeatureGraph.readFeatureGraph(currentFileName);
         selectedIndex = -1;
         refreshAllButUpdateFeature();
         tagListBox.Items.Clear();
         listBox3.Items.Clear();
         childrenCheckedListBox.Items.Clear();
         clearAllTextBoxes();
         this.Text = "Data Entry - Concept Graph : " + currentFileName;
     }
 }
Пример #9
0
 //All of the operations for the File dropdown menu
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     featGraph = new FeatureGraph();
     toChange = null;
     selectedIndex = -1;
     editorFeatureSelected = "";
     currentFileName = "";
     refreshAll();
 }
Пример #10
0
        private void mergeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Choose the XML file you want to merge";
            openFileDialog1.FileName = "";
            openFileDialog1.Multiselect = false;
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.Filter = "XML File|*.xml|All Files|*";
            openFileDialog1.ShowDialog();
            if (openFileDialog1.FileName != "" && openFileDialog1.CheckFileExists)
            {
                currentFileName = openFileDialog1.FileName;

                featGraph = XMLFilerForFeatureGraph.readFeatureGraph2(openFileDialog1.FileName);
                refreshAllButUpdateFeature();
                tagListBox.Items.Clear();
                childrenCheckedListBox.Items.Clear();
                clearAllTextBoxes();
            }
        }
Пример #11
0
 private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (currentFileName != "")
     {
         featGraph = XMLFilerForFeatureGraph.readFeatureGraph(currentFileName);
         refreshAllButUpdateFeature();
         tagListBox.Items.Clear();
         childrenCheckedListBox.Items.Clear();
         clearAllTextBoxes();
     }
 }
        /// <summary>
        /// Create a converter for the specified XML file
        /// </summary>
        /// <param name="xmlFilename"></param>
        public QueryHandler(FeatureGraph graph, List<TemporalConstraint> myTemporalConstraintList)
        {
            // Load the AIML Bot
            this.bot = new Bot();
            this.temporalConstraintList = myTemporalConstraintList;
            bot.loadSettings();
            bot.isAcceptingUserInput = false;
            bot.loadAIMLFromFiles();
            bot.isAcceptingUserInput = true;
            this.user = new User("user", this.bot);

            // Load the Feature Graph
            this.graph = graph;

            // Feature Names, with which to index the graph
            this.features = graph.getFeatureNames();

            this.turn = 1;
            this.topic = null;

            //Build lists of equivalent relationships
            //is, are, was, is a kind of, is a
            equivalent_relationships.Add(new List<string>() { "is", "are", "was", "is a kind of", "is a" });
            //was a member of, is a member of
            equivalent_relationships.Add(new List<string>() { "was a member of", "is a member of" });
            //won a gold medal in, won
            equivalent_relationships.Add(new List<string>() { "won a gold medal in", "won" });
            //is one of, was one of the, was one of
            equivalent_relationships.Add(new List<string>() { "is one of", "was one of the", "was one of" });
            //include, includes, included
            equivalent_relationships.Add(new List<string>() { "include", "includes", "included" });
            //took place on
            equivalent_relationships.Add(new List<string>() { "took place on" });
            //took place at
            equivalent_relationships.Add(new List<string>() { "took place at" });
            //has, had
            equivalent_relationships.Add(new List<string>() { "has", "had" });
            //includes event
            equivalent_relationships.Add(new List<string>() { "includes event" });
            //includes member, included member
            equivalent_relationships.Add(new List<string>() { "includes member", "included member" });
            //include athlete
            equivalent_relationships.Add(new List<string>() { "include athlete" });
            //is southwest of, is southeast of, is northeast of, is north of,
            //is west of, is east of, is south of, is northwest of
            equivalent_relationships.Add(new List<string>() { "is southwest of", "is southeast of"
                , "is northeast of", "is north of", "is west of", "is east of", "is south of", "is northwest of" });

            //Build list of filter nodes.
            //Each filter node is identified by its Data values in the XML
            filter_nodes.Add("Male");
            filter_nodes.Add("Female");
            filter_nodes.Add("Cities");
            filter_nodes.Add("Sports");
            filter_nodes.Add("Gold Medallists");
            filter_nodes.Add("Venues");
            filter_nodes.Add("Time");
            filter_nodes.Add("Aug. 8th, 2008");
            filter_nodes.Add("Aug. 24th, 2008");
            filter_nodes.Add("Aug. 9th, 2008");
            filter_nodes.Add("Aug. 10th, 2008");
            filter_nodes.Add("Aug. 11th, 2008");
            filter_nodes.Add("Aug. 12th, 2008");
            filter_nodes.Add("Aug. 13th, 2008");
            filter_nodes.Add("Aug. 14th, 2008");
            filter_nodes.Add("Aug. 15th, 2008");
            filter_nodes.Add("Aug. 16th, 2008");
            filter_nodes.Add("Aug. 17th, 2008");
            filter_nodes.Add("Aug. 18th, 2008");
            filter_nodes.Add("Aug. 19th, 2008");
            filter_nodes.Add("Aug. 20th, 2008");
            filter_nodes.Add("Aug. 21st, 2008");
            filter_nodes.Add("Aug. 22nd, 2008");
            filter_nodes.Add("Aug. 23rd, 2008");

            //Build list of relationships which should not be used in analogies.
            no_analogy_relationships.Add("occurred before");
            no_analogy_relationships.Add("occurred after");
            no_analogy_relationships.Add("include");
            no_analogy_relationships.Add("includes");
            no_analogy_relationships.Add("included");
            no_analogy_relationships.Add("has");
            no_analogy_relationships.Add("had");
        }
 public static bool writeFeatureGraph(FeatureGraph toWrite, string fileName)
 {
     try
     {
         StreamWriter writer = new StreamWriter(fileName);
         writer.WriteLine("<AIMind>");
         if (toWrite.Root != null)
         {
             writer.WriteLine("<Root id=\"" + toWrite.getFeatureIndex(toWrite.Root.Data) + "\"/>");
         }
         for (int x = 0; x < toWrite.Features.Count; x++)
         {
             Feature tmp = toWrite.Features[x];
             writer.WriteLine("<Feature id=\"" + x + "\" data=\"" + escapeInvalidXML(tmp.Data) + "\">");
             //Neighbor
             for (int y = 0; y < tmp.Neighbors.Count; y++)
             {
                 int id = toWrite.getFeatureIndex(tmp.Neighbors[y].Item1.Data);
                 writer.WriteLine("<neighbor dest=\"" + id + "\" weight=\"" + tmp.Neighbors[y].Item2 + "\" relationship=\"" + escapeInvalidXML(tmp.Neighbors[y].Item3) + "\"/>");
             }
             //Parent
             for (int y = 0; y < tmp.Parents.Count; y++)
             {
                 int id = toWrite.getFeatureIndex(tmp.Parents[y].Item1.Data);
                 writer.WriteLine("<parent dest=\"" + id + "\" weight=\"" + tmp.Parents[y].Item2 + "\" relationship=\"" + escapeInvalidXML(tmp.Parents[y].Item3) + "\"/>");
             }
             //Tag
             List<Tuple<string, string, string>> tags = tmp.Tags;
             for (int y = 0; y < tags.Count; y++)
             {
                 string toWriteTag = "<tag key=\"" + escapeInvalidXML(tags[y].Item1);
                 toWriteTag += "\" value=\"" + escapeInvalidXML(tags[y].Item2);
                 toWriteTag += "\" type=\"" + escapeInvalidXML(tags[y].Item3) + "\"/>";
                 writer.WriteLine(toWriteTag);
             }
             //Speak
             List<string> speaks = tmp.Speaks;
             for (int y = 0; y < speaks.Count; y++)
             {
                 writer.WriteLine("<speak value=\"" + escapeInvalidXML(speaks[y]) + "\"/>");
             }
             writer.WriteLine("</Feature>");
         }
         writer.WriteLine("</AIMind>");
         writer.Close();
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return false;
     }
 }
        public static FeatureGraph readFeatureGraph(string toReadPath)
        {
            try
            {
                FeatureGraph result = new FeatureGraph();
                XmlDocument doc = new XmlDocument();
                doc.Load(toReadPath);
                docOld = doc;
                XmlNodeList features = doc.SelectNodes("AIMind");
                features = features[0].SelectNodes("Feature");
                foreach (XmlNode node in features)
                {
                    string data = unEscapeInvalidXML(node.Attributes["data"].Value);
                    result.addFeature(new Feature(data));
                }
                foreach (XmlNode node in features)
                {
                    Feature tmp = result.getFeature(node.Attributes["data"].Value);
                    //Neighbor
                    XmlNodeList neighbors = node.SelectNodes("neighbor");
                    foreach (XmlNode neighborNode in neighbors)
                    {
                        int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);
                        double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                        string relationship = "";
                        if (neighborNode.Attributes["relationship"] != null)
                        {
                            relationship = unEscapeInvalidXML(Convert.ToString(neighborNode.Attributes["relationship"].Value));
                        }
                        tmp.addNeighbor(result.Features[id], weight,relationship);

                        //pre-process in case no parent exist
                        foreach (XmlNode tempNode in features)
                        {
                            if (tempNode.Attributes["data"].Value == result.Features[id].Data)
                            {
                                XmlNodeList tempParents = tempNode.SelectNodes("parent");
                                if (tempParents.Count == 0)
                                {
                                    result.Features[id].addParent(tmp);
                                }
                            }
                        }
                        //result.Features[id].addNeighbor(tmp,weight);
                    }
                    //Parent
                    XmlNodeList parents = node.SelectNodes("parent");
                    foreach (XmlNode parentNode in parents)
                    {
                        int id = Convert.ToInt32(parentNode.Attributes["dest"].Value);
                        double weight = Convert.ToDouble(parentNode.Attributes["weight"].Value);
                        string relationship = "";
                        if (parentNode.Attributes["relationship"] != null)
                        {
                            relationship = unEscapeInvalidXML(Convert.ToString(parentNode.Attributes["relationship"].Value));
                        }
                        tmp.addParent(result.Features[id], weight, relationship);
                    }
                    //Tag
                    XmlNodeList tags = node.SelectNodes("tag");
                    foreach (XmlNode tag in tags)
                    {
                        string key = unEscapeInvalidXML(tag.Attributes["key"].Value);
                        string val = unEscapeInvalidXML(tag.Attributes["value"].Value);
                        string type = unEscapeInvalidXML(tag.Attributes["type"].Value);
                        tmp.addTag(key, val, type);
                    }
                    //Speak
                    XmlNodeList speaks = node.SelectNodes("speak");
                    foreach (XmlNode speak in speaks)
                    {
                        tmp.addSpeak(unEscapeInvalidXML(speak.Attributes["value"].Value));
                    }
                }
                int rootId = -1;
                try
                {
                    features = doc.SelectNodes("AIMind");
                    rootId = Convert.ToInt32(features[0].SelectNodes("Root")[0].Attributes["id"].Value);
                }
                catch (Exception) { }
                if (rootId != -1) { result.Root = result.getFeature(rootId); }
                return result;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return null;
            }
        }
        /* merge two files*/
        public static FeatureGraph readFeatureGraph2(string toReadPath)
        {
            try
            {
                FeatureGraph result = new FeatureGraph();
                XmlDocument doc = new XmlDocument();//doc is the second document, the one selected to merge with after a file has been opened
                doc.Load(toReadPath);
                XmlNodeList features = doc.SelectNodes("AIMind");
                features = features[0].SelectNodes("Feature");
                int countUp = 0;
                int countUp2 = 0;
                int countD = 0;
                XmlNodeList features2 = docOld.SelectNodes("AIMind");

                if (features2[0] != null)
                {//if the first document opened has features{
                    features2 = features2[0].SelectNodes("Feature");///this is put here because it would cause a crash outside if there were no features
                    foreach (XmlNode node in features2)
                    {
                        string data = node.Attributes["data"].Value;
                        result.addFeature(new Feature(data));
                        countD++;
                    }
                }
                foreach (XmlNode node in features){
                        bool checkifDuplicatesExist = false;
                        foreach (XmlNode nodePrime in features2){
                            string dataa = node.Attributes["data"].Value;
                            string data2 = nodePrime.Attributes["data"].Value;
                            if (dataa == data2)                    //if there are two datas with the same name, merge them
                            {
                                checkifDuplicatesExist = true;
                            }
                        }
                    if (checkifDuplicatesExist == false){//if there doesn't exist a version of the feature, add one
                        countUp++;
                        string data = node.Attributes["data"].Value;
                        result.addFeature(new Feature(data));
                        Feature tmp = result.getFeature(node.Attributes["data"].Value);
                         XmlNodeList neighbors = node.SelectNodes("neighbor");
                        foreach (XmlNode neighborNode in neighbors){
                                int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);// +countUp;// + countUp);
                                double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                                tmp.addNeighbor(result.Features[id], weight);
                                result.Features[id].addParent(tmp);
                                //result.Features[id].addNeighbor(tmp, weight);
                        }
                        XmlNodeList tags = node.SelectNodes("tag");
                            foreach (XmlNode tag in tags)
                            {
                                string key = tag.Attributes["key"].Value;
                                string val = tag.Attributes["value"].Value;
                                string type = "0";
                                if (tag.Attributes["type"].Value == null)
                                {
                                    type = "0";
                                }
                                else
                                {
                                    type = tag.Attributes["type"].Value;
                                }
                                tmp.addTag(key, val, type);
                            }
                            XmlNodeList speaks = node.SelectNodes("speak");

                        foreach (XmlNode speak in speaks){
                                tmp.addSpeak(speak.Attributes["value"].Value);
                            }

                    }
                    else
                    {
                        countUp++;
                        Feature tmp = result.getFeature(node.Attributes["data"].Value);

                        XmlNodeList neighbors = node.SelectNodes("neighbor");
                        foreach (XmlNode neighborNode in neighbors)
                        {
                            int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);// +countUp;// + countUp);
                            double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                            tmp.addNeighbor(result.Features[id], weight);
                            result.Features[id].addParent(tmp);
                            //result.Features[id].addNeighbor(tmp,weight);
                        }

                        XmlNodeList tags = node.SelectNodes("tag");
                        foreach (XmlNode tag in tags)
                        {
                            string key = tag.Attributes["key"].Value;
                            string val = tag.Attributes["value"].Value;
                            string type = "0";
                            if (tag.Attributes["type"].Value == null)
                            {
                                type = "0";
                            }
                            else
                            {
                                type = tag.Attributes["type"].Value;
                            }
                            tmp.addTag(key, val, type);
                        }

                    }

                }

                docOld = doc;
                //after loading the data from the two documents, run through the nodes found
                foreach (XmlNode node in features2)///add the features from the second file
                {
                    Feature tmp = result.getFeature(node.Attributes["data"].Value);
                    XmlNodeList neighbors = node.SelectNodes("neighbor");

                   string secDet = Convert.ToString(Convert.ToInt32(node.Attributes["id"].Value) + countUp);

                    foreach (XmlNode neighborNode in neighbors)
                    {
                        int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value) +countUp;// +0 + 1;
                        double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);

                          tmp.addNeighbor(result.Features[id], weight);
                          result.Features[id].addParent(tmp);//add neighbors to node
                        //result.Features[id].addNeighbor(tmp,weight);
                    }
                    XmlNodeList tags = node.SelectNodes("tag");
                    foreach (XmlNode tag in tags)
                    {
                        string key = tag.Attributes["key"].Value;
                        string val = tag.Attributes["value"].Value;
                        string type = "0";
                        if (tag.Attributes["type"].Value == null)
                        {
                            type = "0";
                        }
                        else
                        {
                            type = tag.Attributes["type"].Value;
                        }
                        tmp.addTag(key, val, type);
                    }
                    XmlNodeList speaks = node.SelectNodes("speak");
                    foreach (XmlNode speak in speaks)
                    {
                        tmp.addSpeak(speak.Attributes["value"].Value);
                    }
                }

                foreach (XmlNode node in features2)
                {

                }

             /*   foreach (XmlNode node in features)
                {
                    foreach (XmlNode node2 in features2)
                    {
                        if (node.Attributes["data"] != null && node2.Attributes["data"] != null)
                        {
                            string data = node.Attributes["data"].Value;
                            string data2 = node2.Attributes["data"].Value;

                            if (data == data2)
                            {
                                XmlNode nodea = node.CloneNode(true);
                                string dataa = nodea.Attributes["data"].Value;
                                Feature tmp = result.getFeature(nodea.Attributes["data"].Value);
                                result.addFeature(new Feature(dataa));

                                node.RemoveAll();
                                node2.RemoveAll();
                                result.removeDouble(data);
                                result.removeDouble(data2);
                                XmlNodeList neighbors = nodea.SelectNodes("neighbor");
                                foreach (XmlNode neighborNode in neighbors){
                                    int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);// +countUp;// + countUp);
                                    double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                                    tmp.addNeighbor(result.Features[id], weight);
                                    result.Features[id].Parents.Add(tmp);
                                }
                                XmlNodeList tags = nodea.SelectNodes("tag");
                                foreach (XmlNode tag in tags){
                                    string key = tag.Attributes["key"].Value;
                                    string val = tag.Attributes["value"].Value;
                                    string type = "0";
                                    type = tag.Attributes["type"].Value;
                                    tmp.removeTag(key);
                                    tmp.addTag(key, val, type);
                                }

                            }
                        }
                    }
                }
                /*
                bool doneWithMerge = false;
                foreach (XmlNode node in features){
                    foreach (XmlNode node2 in features2){
                        if (node.Attributes["data"] != null && node2.Attributes["data"] != null){
                        string data = node.Attributes["data"].Value;
                        string data2 = node2.Attributes["data"].Value;

                        if (data == data2 && doneWithMerge == false)
                        {//if the node is found in both

                            int idb = 0;
                            int idb2 = 0;
                            idb = Convert.ToInt32(node.Attributes["id"].Value);
                            idb2 = Convert.ToInt32(node2.Attributes["id"].Value);
                            string[] keys1a = new string[100];
                            string[] vals1a = new string[100];
                            string[] types1a = new string[100];
                            int countTheTag = 0;
                            string da = " ";
                            Feature tmp = new Feature(da);/// = result.getFeature(node.Attributes["data"].Value);
                          /*  XmlNodeList neighbors = node.SelectNodes("neighbor");
                            foreach (XmlNode neighborNode in neighbors)
                            {
                                int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);// +countUp;// + countUp)
                                double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                                tmp.addNeighbor(result.Features[id], weight);
                                result.Features[id].Parents.Add(tmp);
                            }
                            neighbors = node2.SelectNodes("neighbor");
                            foreach (XmlNode neighborNode in neighbors)
                            {
                                int id = Convert.ToInt32(neighborNode.Attributes["dest"].Value);// +countUp;// + countUp);
                                double weight = Convert.ToDouble(neighborNode.Attributes["weight"].Value);
                                tmp.addNeighbor(result.Features[id], weight);
                                result.Features[id].Parents.Add(tmp);
                            }
                              XmlNodeList tags = node.SelectNodes("tag");
                                      foreach (XmlNode tag in tags)
                                      {
                                          string key = tag.Attributes["key"].Value;
                                          string val = tag.Attributes["value"].Value;
                                          string type = "0";
                                          if (tag.Attributes["type"].Value == null)
                                          {
                                              type = "0";
                                          }
                                          else
                                          {
                                              type = tag.Attributes["type"].Value;
                                          }
                                          ///tmp.editExistingTag(key, val, type, false);
                                         // tmp.addTag(key, val, type);
                                          keys1a[countTheTag] = key;
                                          vals1a[countTheTag] = val;
                                          types1a[countTheTag] = type;
                                          countTheTag++;
                                      }
                                      XmlNodeList tags2 = node2.SelectNodes("tag");
                                      foreach (XmlNode tag2 in tags2)
                                      {
                                          string key = tag2.Attributes["key"].Value;
                                          string val = tag2.Attributes["value"].Value;
                                          string type = "0";
                                          if (tag2.Attributes["type"].Value == null)
                                          {
                                              type = "0";
                                          }
                                          else
                                          {
                                              type = tag2.Attributes["type"].Value;
                                          }
                                         /// tmp.editExistingTag(key, val, type, false);
                                          ///tmp.addTag(key, val, type);
                                          keys1a[countTheTag] = key;
                                          vals1a[countTheTag] = val;
                                          types1a[countTheTag] = type;
                                          countTheTag++;
                                      }

                            XmlNodeList speaks = node.SelectNodes("speak");
                            foreach (XmlNode speak in speaks)
                            {
                                tmp.addSpeak(speak.Attributes["value"].Value);
                            }
                            speaks = node2.SelectNodes("speak");
                            foreach (XmlNode speak in speaks)
                            {
                                tmp.addSpeak(speak.Attributes["value"].Value);
                            }

                            //     result.removeDouble(data);
                            //   result.removeDouble(data2);
                            string da2 = " ";
                            Feature tmp2 = new Feature(da2);

                            for (int i = 0; i < countTheTag; i++)
                            {
                                // tmp2.addTag(keys1a[i], vals1a[i], types1a[i]);

                            }
                            node.Attributes["data"].Value = null;
                            node.Attributes["id"].Value = null;
                            //  result.removeDouble(data);
                            node.RemoveAll();
                            node2.RemoveAll();
                        }
                        }
                    }
                }

                 */

                int rootId = -1;
                try
                {
                    features = doc.SelectNodes("AIMind");
                    rootId = Convert.ToInt32(features[0].SelectNodes("Root")[0].Attributes["id"].Value);
                }
                catch (Exception) { }
                if (rootId != -1) { result.Root = result.getFeature(rootId); }
                return result;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return null;
            }
        }