예제 #1
0
        public KeywordListData GetKeywordsListData()
        {
            // Keywords
            var searcher     = new MetadataCacheSearcher();
            var keywordsList = searcher.GetKeywords();

            keywordsList.Add("Hydrosphere");
            var sortedKeywords = new SortedSet <string>(keywordsList);

            // Ontology tree
            var tree       = new OntologyTree();
            var parentNode = new OntologyNode("Hydrosphere");

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

            //------
            var result = new KeywordListData
            {
                Keywords    = sortedKeywords.ToList(),
                OntoloyTree = tree,
            };

            return(result);
        }
예제 #2
0
        public KeywordListData GetKeywordsListData()
        {
            // Synonyms and keywords
            var tmpsyndoc = HdSearchOntologyHelper.ReadOntologySynonymsXmlFile();

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

            foreach (XmlElement elem in root.ChildNodes)
            {
                var ontoPath = new OntologyPath();
                foreach (XmlElement child in elem.ChildNodes)
                {
                    if (child.Name == "conceptID")
                    {
                        int conceptID;
                        if (Int32.TryParse(child.InnerText, out conceptID))
                        {
                            ontoPath.ConceptID = conceptID;
                        }
                    }
                    else if (child.Name == "ConceptName")
                    {
                        ontoPath.ConceptName = child.InnerText;
                    }
                    else if (child.Name == "ConceptPath")
                    {
                        ontoPath.ConceptPath = child.InnerText;
                    }
                    else if (child.Name == "SearchableKeyword")
                    {
                        ontoPath.SearchableKeyword = child.InnerText;
                    }
                }
                synonyms.Add(ontoPath);
                keywordsList.Add(ontoPath.SearchableKeyword);
            }

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

            FillTree(tmpxmldoc.DocumentElement, tree.Nodes);

            //------
            var result = new KeywordListData
            {
                OntoloyTree = tree,
                Keywords    = keywordsList.ToList(),
                Synonyms    = synonyms,
            };

            return(result);
        }