Ejemplo n.º 1
0
        private void ClassificationOwlNodes()
        {
            ListOwlClass            = new List <OwlClass>();
            ListOwlProperty         = new List <OwlProperty>();
            ListOwlIndividual       = new List <OwlIndividual>();
            ListOwlDatatypeProperty = new List <OwlDatatypeProperty>();

            IDictionaryEnumerator enumerator = (IDictionaryEnumerator)OwlGraph.Nodes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                OwlNode owlNode = (OwlNode)OwlGraph.Nodes[(string)enumerator.Key];
                if (!owlNode.IsAnonymous())
                {
                    if (owlNode is OwlClass)
                    {
                        ListOwlClass.Add((OwlClass)owlNode);
                    }
                    if (owlNode is OwlProperty)
                    {
                        ListOwlProperty.Add((OwlProperty)owlNode);
                    }
                    if (owlNode is OwlIndividual)
                    {
                        ListOwlIndividual.Add((OwlIndividual)owlNode);
                    }
                    if (owlNode is OwlDatatypeProperty)
                    {
                        ListOwlDatatypeProperty.Add((OwlDatatypeProperty)owlNode);
                    }
                }
            }
            WriteStructure();
        }
Ejemplo n.º 2
0
        public void test3(string file)
        {
            IOwlParser parser = new OwlXmlParser();
            IOwlGraph  graph  = parser.ParseOwl(file);

            Console.WriteLine("The nodes of the graph are:");
            IDictionaryEnumerator nEnumerator = (IDictionaryEnumerator)graph.Nodes.GetEnumerator();

            while (nEnumerator.MoveNext())
            {
                OwlNode node = (OwlNode)graph.Nodes[(nEnumerator.Key).ToString()];
                if (!node.IsAnonymous())
                {
                    Console.WriteLine(node.ID);
                }
            }

            Console.WriteLine(Environment.NewLine);

            Console.WriteLine("Retrieving some specific data:");
            IOwlNode hotelNode = (IOwlNode)graph.Nodes["http://www.owl-ontologies.com/travel.owl#Hotel"];

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("The edges are: ");
            OwlEdgeCollection edges = (OwlEdgeCollection)hotelNode.ChildEdges;

            foreach (OwlEdge e in edges)
            {
                Console.WriteLine(e.ID);
            }

            Console.WriteLine("The subClassOf edges are:");
            IOwlEdgeList subclassEdges = (IOwlEdgeList)hotelNode.ChildEdges["http://www.w3.org/2000/01/rdf-schema#subClassOf"];

            foreach (OwlEdge s in subclassEdges)
            {
                Console.WriteLine(s.ChildNode.ID);
            }
        }
Ejemplo n.º 3
0
    private IEnumerator OpenOwl()
    {
        string     filename = m_OwlFile;
        IOwlParser parser   = new OwlXmlParser();

        m_OwlGraph      = parser.ParseOwl(filename);
        m_numNodes      = m_OwlGraph.Nodes.Count;
        m_winText.text += "There are " + m_numNodes
                          + " node(s) in the ontology '" + m_OwlFile + "'\n";

        string oldText = m_winText.text;

        IDictionaryEnumerator nodeIter = (IDictionaryEnumerator)m_OwlGraph.Nodes.GetEnumerator();

        int cnt = 0;

        while (nodeIter.MoveNext())
        {
            //string owlKey = (nodeIter.Key).ToString();
            string  owlKey  = ((OwlNode)nodeIter.Value).ID;
            OwlNode owlNode = (OwlNode)nodeIter.Value;
            if (owlNode.IsAnonymous())
            {
                continue;
            }

            cnt++;

            NodeInstance graphNode = new NodeInstance();

            graphNode.m_owlNode      = owlNode;
            graphNode.m_pathSegments = new ArrayList();

            //Debug.Log("owlKey  = <" + owlKey + ">");
            //Debug.Log("owlNode = " + owlNode);

            var uri = new Uri(owlKey);
            //Debug.Log("absURI = " + uri.AbsoluteUri);
            //Debug.Log("path = " + uri.PathAndQuery);
            //Debug.Log("host = " + uri.Host);

            // build up the node's path segments
            graphNode.m_pathSegments.Add(uri.Host);
            foreach (string element in uri.Segments)
            {
                //if (element == "/") continue;
                graphNode.m_pathSegments.Add(element);//.TrimEnd('/'));
            }

            if (uri.Fragment != null)
            {
                graphNode.m_pathSegments[graphNode.m_pathSegments.Count - 1] += (uri.Fragment);
            }

            OwlTreeNode owlTreeNode = m_owlNodeTree.addNode(graphNode);
            graphNode.m_treeNode = owlTreeNode;
            //statsElem.mNode = graphNode;
            m_NodeDictionary.Add(owlKey, graphNode);

            if (cnt % m_addElementInterval == 0)
            {
                string[] dots = { ".", "..", "..." };
                for (int jj = 0; jj < 3; jj++)
                {
                    m_winText.text = oldText + "Opening OWL file" + dots[cnt % 3];
                }

                //Debug.Log("cnt = " + cnt);
                if (m_testing)
                {
                    yield break;
                }
                else
                {
                    yield return(null);// new WaitForSeconds(0.052f);
                }
            }
        }

        m_winText.text = oldText;
        yield return(null);
    }