Example #1
0
        public OntologyDesc GetOntologyDesc()
        {
            // Keywords
            //var searcher = new MetadataCacheSearcher();
            var list = new List<string>();
            var keywordsList = list;//searcher.GetKeywords();
            keywordsList.Add(Constants.RootName);
            var sortedKeywords = new SortedSet<string>(keywordsList);

            // Ontology tree
            var tree = new OntologyTree();
            var parentNode = new OntologyNode(Constants.RootName);
            foreach (var keyword in keywordsList.Where(keyword => keyword != Constants.RootName))
            {
                parentNode.children.Add(new OntologyNode(keyword));
            }
            tree.Nodes.Add(parentNode);

            // Return result
            var result = new OntologyDesc
            {
                Keywords = sortedKeywords,
                OntoloyTree = tree,
            };
            return result;
        }
Example #2
0
        public OntologyDesc GetOntologyDesc()
        {
            // Keywords
            //var searcher = new MetadataCacheSearcher();
            var list         = new List <string>();
            var keywordsList = list;//searcher.GetKeywords();

            keywordsList.Add(Constants.RootName);
            var sortedKeywords = new SortedSet <string>(keywordsList);

            // Ontology tree
            var tree       = new OntologyTree();
            var parentNode = new OntologyNode(Constants.RootName);

            foreach (var keyword in keywordsList.Where(keyword => keyword != Constants.RootName))
            {
                parentNode.children.Add(new OntologyNode(keyword));
            }
            tree.Nodes.Add(parentNode);

            // Return result
            var result = new OntologyDesc
            {
                Keywords    = sortedKeywords,
                OntoloyTree = tree,
            };

            return(result);
        }
Example #3
0
        public string getOntology(string conceptKeyword)
        {
            var dataWorker = new DataWorker();
            var ontologytreeJson = string.Empty;
            keywordsList = new SortedSet<string>();
            json = string.Empty;
            //get ontology from hiscentral

            var getOntologytree = dataWorker.getOntologyTree(conceptKeyword);

            XmlDocument ontologytreeXML = new XmlDocument();

            if (getOntologytree != null)
            {

                ontologytreeXML.LoadXml(getOntologytree);
                //string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc.DocumentElement);
            }

            // Ontology tree
            var tree = new OntologyTree();
            //var tmpxmldoc = ReadOntologyXmlFile();
            FillTree(ontologytreeXML.DocumentElement, tree.Nodes);

            //XmlReader rdr = XmlReader.Create(new System.IO.StringReader(ontologytreeXML));
            //while (rdr.Read())
            //{
            //    if (rdr.NodeType == XmlNodeType.Element)
            //    {
            //        Console.WriteLine(rdr.LocalName);
            //    }
            //}

            if (tree != null)
            {
                //    XmlDocument doc = new XmlDocument();
                //    doc.LoadXml(ontologytreeXml);
                //string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc.DocumentElement);
                ontologytreeJson = Newtonsoft.Json.JsonConvert.SerializeObject(tree.Nodes[0].children,
                    new JsonSerializerSettings
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                        PreserveReferencesHandling = PreserveReferencesHandling.None
                        // PreserveReferencesHandling = PreserveReferencesHandling.Objects
                    }
                    );
            }
            return ontologytreeJson;
        }
Example #4
0
 public bool HasChild(string name)
 {
     return(OntologyTree.FindNode(name, children) != null);
 }
        public OntologyDesc GetOntologyDesc()
        {
            // Synonyms and keywords
            var tmpsyndoc = ReadOntologySynonymsXmlFile();
            keywordsList = new SortedSet<string>();
            var synonyms = new List<OntologyPath>();
            var root = tmpsyndoc.DocumentElement;
            foreach (XmlElement elem in root.ChildNodes)
            {
                var ontoPath = new OntologyPath();
                foreach (XmlElement child in elem.ChildNodes)
                {
                    var text = child.InnerText.Trim();
                    if (child.Name == "conceptID")
                    {
                        int conceptID;
                        if (Int32.TryParse(text, out conceptID))
                            ontoPath.ConceptID = conceptID;
                    }
                    else if (child.Name == "ConceptName")
                    {
                        ontoPath.ConceptName = text;
                    }
                    else if (child.Name == "ConceptPath")
                    {
                        ontoPath.ConceptPath = text;
                    }
                    else if (child.Name == "SearchableKeyword")
                    {
                        ontoPath.SearchableKeyword = text;
                    }
                }
                // Add to sysnonyms, only if SearchableKeyword != ConceptName
                if (!string.Equals(ontoPath.SearchableKeyword, ontoPath.ConceptName) &&
                    !string.IsNullOrEmpty(ontoPath.SearchableKeyword))
                {
                    synonyms.Add(ontoPath);
                }
                if (!String.IsNullOrWhiteSpace(ontoPath.SearchableKeyword))
                {
                    keywordsList.Add(ontoPath.SearchableKeyword);
                }
            }

            // Ontology tree
            var tree = new OntologyTree();
            var tmpxmldoc = ReadOntologyXmlFile();
            FillTree(tmpxmldoc.DocumentElement, tree.Nodes);

            // Replace Hydroshpere with All
            keywordsList.Remove("Hydrosphere");
            keywordsList.Add(Constants.RootName);
            if (tree.Nodes.Count > 0)
            {
                tree.Nodes[0].title = Constants.RootName;
            }

            // Return result
            var result = new OntologyDesc
            {
                OntoloyTree = tree,
                Keywords = keywordsList,
                Synonyms = synonyms,
            };
            return result;
        }
        public OntologyDesc GetOntologyDesc()
        {
            // Synonyms and keywords
            var tmpsyndoc = ReadOntologySynonymsXmlFile();

            keywordsList = new SortedSet <string>();
            var synonyms = new List <OntologyPath>();
            var root     = tmpsyndoc.DocumentElement;

            foreach (XmlElement elem in root.ChildNodes)
            {
                var ontoPath = new OntologyPath();
                foreach (XmlElement child in elem.ChildNodes)
                {
                    var text = child.InnerText.Trim();
                    if (child.Name == "conceptID")
                    {
                        int conceptID;
                        if (Int32.TryParse(text, out conceptID))
                        {
                            ontoPath.ConceptID = conceptID;
                        }
                    }
                    else if (child.Name == "ConceptName")
                    {
                        ontoPath.ConceptName = text;
                    }
                    else if (child.Name == "ConceptPath")
                    {
                        ontoPath.ConceptPath = text;
                    }
                    else if (child.Name == "SearchableKeyword")
                    {
                        ontoPath.SearchableKeyword = text;
                    }
                }
                // Add to sysnonyms, only if SearchableKeyword != ConceptName
                if (!string.Equals(ontoPath.SearchableKeyword, ontoPath.ConceptName) &&
                    !string.IsNullOrEmpty(ontoPath.SearchableKeyword))
                {
                    synonyms.Add(ontoPath);
                }
                if (!String.IsNullOrWhiteSpace(ontoPath.SearchableKeyword))
                {
                    keywordsList.Add(ontoPath.SearchableKeyword);
                }
            }

            // Ontology tree
            var tree      = new OntologyTree();
            var tmpxmldoc = ReadOntologyXmlFile();

            FillTree(tmpxmldoc.DocumentElement, tree.Nodes);

            // Replace Hydroshpere with All
            keywordsList.Remove("Hydrosphere");
            keywordsList.Add(Constants.RootName);
            if (tree.Nodes.Count > 0)
            {
                tree.Nodes[0].title = Constants.RootName;
            }

            // Return result
            var result = new OntologyDesc
            {
                OntoloyTree = tree,
                Keywords    = keywordsList,
                Synonyms    = synonyms,
            };

            return(result);
        }