示例#1
0
    internal void addOwlEdge(IOwlEdge edge, int cnt, ref int numNull)
    {
        IOwlNode parent = edge.ParentNode;
        IOwlNode child  = edge.ChildNode;

        NodeInstance childNode;
        NodeInstance parentNode;

        m_NodeDictionary.TryGetValue(child.ToString(), out childNode);
        m_NodeDictionary.TryGetValue(parent.ToString(), out parentNode);

        if (childNode == null || parentNode == null)
        {
            //if (childNode == null)
            //{
            //    //Debug.Log("no child node found for edge " + edge.ID);
            //}
            //if (parentNode == null)
            //{
            //    //Debug.Log("no parent node found for edge " + edge.ID);
            //}
            numNull++;
            return;
        }

        Vector3 childPos  = childNode.m_treeNode.mPos;
        Vector3 parentPos = parentNode.m_treeNode.mPos;

        GameObject goEdge = DrawLine(childPos, parentPos, m_lineColor, m_OwlLineParent);

        /*EdgeInstance myEdge =*/ new EdgeInstance(/*edge,*/ childNode, parentNode, goEdge);
    }
示例#2
0
        public MindMapOntology(string fileName)
        {
            Concepts = new Dictionary <string, MindMapConcept>();
            IOwlGraph  graph;
            IOwlParser parser = new OwlXmlParser();
            object     o      = parser.ParseOwl(fileName);

            graph = (IOwlGraph)o;
            foreach (DictionaryEntry entry in graph.Nodes)
            {
                IOwlNode node = (IOwlNode)entry.Value;
                if (node.GetType() == typeof(OwlAnnotationProperty) && node.ID != eMaplex && node.ID != eDefinition)
                {
                    annotations.Add(node.ID, ((string)entry.Key).Substring(eAnnotation.Length));
                }
            }
            foreach (DictionaryEntry entry in graph.Literals)
            {
                IOwlLiteral literal = (IOwlLiteral)entry.Value;
                if (literal.ParentEdges[0].ParentNode.ChildEdges[eLabel, 0] == null || ((IOwlLiteral)(literal.ParentEdges[0].ParentNode.ChildEdges[eLabel, 0].ChildNode)) != literal)
                {
                    continue;
                }
                MindMapConcept concept = new MindMapConcept();
                concept.Name                = literal.ID;
                concept.Defintion           = GetDefinition(literal);
                concept.VisualProperties    = GetVisualFeatures(literal);
                concept.NonVisualProperties = GetNonVisualFeatures(literal);
                concept.Maplex              = GetMaplex(literal);
                if (concept.Name.ToUpper() != "THING" && GetParent(literal) != null)
                {
                    concept.ParentConceptName = GetParent(literal).ID;
                }
                else
                {
                    concept.ParentConceptName = "";
                }
                Concepts.Add(concept.Name, concept);
                //Concepts.Add(concept.Name.Split('^')[0], concept);
            }
            foreach (KeyValuePair <string, MindMapConcept> concept in Concepts)
            {
                if (concept.Value.Name.ToUpper() != "THING" && concept.Value.ParentConceptName != null && concept.Value.ParentConceptName != "")
                {
                    try
                    {
                        concept.Value.Parent = Concepts[concept.Value.ParentConceptName];
                    }
                    catch (Exception)
                    {
                        concept.Value.Parent = null;
                    }
                }
                else
                {
                    concept.Value.Parent = null;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Merges the srcGraph into this graph object
        /// </summary>
        /// <param name="srcGraph">An object that implements the IOwlGraph interace</param>
        /// <param name="skipDuplicateEdges">A flag that indicates whether duplicate edges present in both graphs should be skipped during the merge process.</param>
        public void Merge(IOwlGraph srcGraph, bool skipDuplicateEdges)
        {
            if (srcGraph == null)
            {
                return;
            }
            Hashtable literalsAdded = new Hashtable();
            //go through all the nodes in the source graph
            IDictionaryEnumerator enumerator = (IDictionaryEnumerator)srcGraph.Nodes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                //Console.WriteLine(((IOwlNode)(enumerator.Value)).ID);
                //add this node to the graph
                IOwlNode srcParentNode  = (IOwlNode)enumerator.Value;
                IOwlNode destParentNode = AddNode(srcParentNode.ID);
                //go through all of the src node's child edges
                foreach (IOwlEdge srcChildEdge in srcParentNode.ChildEdges)
                {
                    //for each of the src node's child edges do...
                    IOwlNode destChildNode;
                    if (srcChildEdge.ChildNode is IOwlLiteral)
                    {
                        IOwlLiteral srcChildLiteral = srcChildEdge.ChildNode as IOwlLiteral;
                        literalsAdded[srcChildLiteral] = srcChildLiteral;
                        destChildNode = AddLiteral(srcChildLiteral.Value, srcChildLiteral.LangID, srcChildLiteral.Datatype);
                    }
                    else
                    {
                        destChildNode = AddNode(srcChildEdge.ChildNode.ID);
                    }

                    //Now we have the parent and the child nodes added to the graph..

                    bool edgeExists = false;
                    if (skipDuplicateEdges)
                    {
                        //does the new parent node and the new child node have an edge with the same ID as srcChildEdge?
                        //go through all the child edges of destParentNode
                        foreach (OwlEdge tempEdge in destParentNode.ChildEdges)
                        {
                            if ((tempEdge.ChildNode == destChildNode) && (tempEdge.ID == srcChildEdge.ID))
                            {
                                edgeExists = true;
                                break;
                            }
                        }
                    }
                    if (!skipDuplicateEdges || (skipDuplicateEdges && !edgeExists))
                    {
                        OwlEdge destChildEdge = new OwlEdge(srcChildEdge.ID);
                        destParentNode.AttachChildEdge(destChildEdge);
                        destChildEdge.AttachChildNode(destChildNode);
                        //add the edge to the graph
                        AddEdge(destChildEdge);
                    }
                }
            }
        }
 /// <summary>
 /// Removes a node object from the collection
 /// </summary>
 /// <param name="node">The node to remove</param>
 /// <returns>True if the node was successfully removed</returns>
 ///	<remarks>If the node exists then it is removed by calling the ArrayList.Remove method which is an O(n) operation.</remarks>
 public void Remove(IOwlNode node)
 {
     if (node == null)
     {
         throw (new ArgumentNullException());
     }
     _items.Remove(node);
 }
 /// <summary>
 /// Adds an OwlNode to this collection
 /// </summary>
 /// <param name="newNode">The Node to add.</param>
 /// <exception cref="ArgumentNullException">newNode is a null reference.</exception>
 public void Add(IOwlNode newNode)
 {
     if (newNode == null)
     {
         throw (new ArgumentNullException());
     }
     _items.Add(newNode);
 }
示例#6
0
        /// <summary>
        /// Detaches the child node
        /// </summary>
        /// <returns>The newly detached child node. Returns null if no child node was present</returns>
        public IOwlNode DetachChildNode()
        {
            IOwlNode node = ChildNode;

            if (ChildNode != null)
            {
                ChildNode.DetachParentEdge(this);
            }
            return(node);
        }
示例#7
0
 /// <summary>
 /// Attaches a parent node to this edge
 /// </summary>
 /// <param name="node">The node to attach</param>
 /// <exception cref="ArgumentNullException">The specified node is a null reference</exception>
 public void AttachParentNode(IOwlNode node)
 {
     if (node == null)
     {
         throw (new ArgumentNullException());
     }
     DetachParentNode();
     ParentNode = node;
     node.ChildEdges.Add(this);
 }
示例#8
0
        /// <summary>
        /// Detaches the parent node from this edge
        /// </summary>
        /// <returns>The newly detached parent node. Returns null if no parent node was present</returns>
        public IOwlNode DetachParentNode()
        {
            IOwlNode node = ParentNode;

            if (ParentNode != null)
            {
                ParentNode.DetachChildEdge(this);
            }
            return(node);
        }
示例#9
0
        /// <summary>
        /// Adds a node to the Graph
        /// </summary>
        /// <param name="nodeUri">A string representing the URI of the new node.</param>
        /// <exception cref="UriFormatException">The specified nodeUri is not a well formed URI.</exception>
        /// <returns>An object that implements the IOwlNode interface. This is a reference to the new node added.
        /// This method checks the graph to determine whether the node with the specified URI exists.
        /// If it does then a reference to the existing node is returned. If it does not exist then a new node is created, added
        /// to the graph and returned.</returns>
        public IOwlNode AddNode(string nodeUri)
        {
            IOwlNode node = _nodes[nodeUri];

            if (node == null)
            {
                node            = new OwlNode(nodeUri);
                _nodes[nodeUri] = node;
            }
            return(node);
        }
示例#10
0
 /// <summary>
 /// Gets the node (or literal) with the specified URI
 /// </summary>
 /// <remarks>This method looks for a node that matches the specified URI and returns it.
 /// If the node is not found then the first literal matching this URI (value+langiuageID+datatype URI) is returned.
 /// If neither a node or a literal matching this ID is found then null is returned.</remarks>
 public IOwlNode this[string nodeID]
 {
     get
     {
         IOwlNode node = _nodes[nodeID];
         if (node == null)
         {
             node = _literals[nodeID];
         }
         return(node);
     }
 }
示例#11
0
 /// <summary>
 /// Removes a node from this collection.
 /// </summary>
 /// <param name="node">An object that implements the IOwlNode interface. This is the node to remove.</param>
 /// <returns>True if a node with the same ID was found and removed.</returns>
 /// <exception cref="ArgumentException">node is a null reference.</exception>
 /// <remarks>This method removes the node with the same ID as the specified node.</remarks>
 public bool Remove(IOwlNode node)
 {
     if (node == null)
     {
         throw (new ArgumentNullException());
     }
     if (Contains(node))
     {
         _nodes.Remove(node.ID);
         return(true);
     }
     return(false);
 }
示例#12
0
        /// <summary>
        /// Determines whether the specified node is a member of this collection.
        /// </summary>
        /// <param name="node">An object that implements the IOwlNode interface.</param>
        /// <returns>True if a node with the same ID was found in the collection.</returns>
        public bool Contains(IOwlNode node)
        {
            if (node == null)
            {
                return(false);
            }
            OwlNode rNode = (OwlNode)_nodes[node.ID];

            if (rNode != null)
            {
                return(rNode == node);
            }
            return(false);
        }
示例#13
0
        /// <summary>
        /// Adds a node to the collection.
        /// </summary>
        /// <param name="nodeID">The ID of the node to add.</param>
        /// <param name="newNode">An object that implements the IOwlNode interface. This is a reference to the node to add.</param>
        /// <exception cref="ArgumentException">A node with the specified ID already exists in the collection.</exception>
        /// <exception cref="ArgumentNullException">The specified ID is a null reference.</exception>
        public void Add(string nodeID, IOwlNode newNode)
        {
            if (newNode == null)
            {
                throw (new ArgumentNullException());
            }
            // Added:
            // Check on duplicate keys, if key is already in the dictionary,
            // then we don't to anything.
            // Why: Error coming from Hano Soma
            // Todo: Recheck this if it is correct
            OwlNode rNode = (OwlNode)_nodes[nodeID];

            if (rNode != null)
            {
                return;
            }
            // End
            _nodes.Add(nodeID, newNode);
        }
示例#14
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);
            }
        }
示例#15
0
 /// <summary>
 /// Adds a new node to the graph.
 /// </summary>
 /// <param name="node">An object that implements the IOwlNode interface. This is the new node to add.</param>
 /// <exception cref="ArgumentException">A node with the same ID already exists in the Graph.</exception>
 public void AddNode(IOwlNode node)
 {
     _nodes.Add((OwlNode)node);
 }
 /// <summary>
 /// Removes a node from this collection.
 /// </summary>
 /// <param name="node">An object that implements the IOwlNode interface. This is the node to remove.</param>
 /// <returns>True if a node with the same ID was found and removed.</returns>
 /// <exception cref="ArgumentException">node is a null reference.</exception>
 /// <remarks>This method removes the node with the same ID as the specified node.</remarks>
 public bool Remove(IOwlNode node)
 {
     if(node == null)
         throw (new ArgumentNullException());
     if(Contains(node))
     {
         _nodes.Remove(node.ID);
         return true;
     }
     return false;
 }
示例#17
0
 /// <summary>
 /// Adds a new node to the graph.
 /// </summary>
 /// <param name="node">An object that implements the IOwlNode interface. This is the new node to add.</param>
 /// <exception cref="ArgumentException">A node with the same ID already exists in the Graph.</exception>
 public void AddNode(IOwlNode node)
 {
     _nodes.Add((OwlNode)node);
 }
 /// <summary>
 /// Adds an OwlNode to this collection
 /// </summary>
 /// <param name="newNode">The Node to add.</param>
 /// <exception cref="ArgumentNullException">newNode is a null reference.</exception>
 public void Add(IOwlNode newNode)
 {
     if(newNode == null)
         throw (new ArgumentNullException());
     _items.Add(newNode);
 }
 /// <summary>
 /// Removes a node object from the collection
 /// </summary>
 /// <param name="node">The node to remove</param>
 /// <returns>True if the node was successfully removed</returns>
 ///	<remarks>If the node exists then it is removed by calling the ArrayList.Remove method which is an O(n) operation.</remarks>
 public void Remove(IOwlNode node)
 {
     if(node == null)
         throw (new ArgumentNullException());
     _items.Remove(node);
 }
 /// <summary>
 /// Determines whether the specified node is a member of this collection.
 /// </summary>
 /// <param name="node">An object that implements the IOwlNode interface.</param>
 /// <returns>True if a node with the same ID was found in the collection.</returns>
 public bool Contains(IOwlNode node)
 {
     if(node == null)
         return false;
     OwlNode rNode = (OwlNode)_nodes[node.ID];
     if(rNode != null)
         return (rNode == node);
     return false;
 }
示例#21
0
 /// <summary>
 /// Attaches a parent node to this edge
 /// </summary>
 /// <param name="node">The node to attach</param>
 /// <exception cref="ArgumentNullException">The specified node is a null reference</exception>
 public void AttachParentNode(IOwlNode node)
 {
     if(node == null)
         throw (new ArgumentNullException());
     DetachParentNode();
     ParentNode = node;
     node.ChildEdges.Add(this);
 }
 /// <summary>
 /// Adds a node to the collection.
 /// </summary>
 /// <param name="newNode">An object that implements the IOwlNode interface. This is a reference to the node to add.</param>
 /// <exception cref="ArgumentException">A node with the same ID already exists in the collection.</exception>
 /// <exception cref="ArgumentNullException">The ID of the specified node is a null Reference.</exception>
 public void Add(IOwlNode newNode)
 {
     Add(newNode.ID,newNode);
 }
 /// <summary>
 /// Adds a node to the collection.
 /// </summary>
 /// <param name="nodeID">The ID of the node to add.</param>
 /// <param name="newNode">An object that implements the IOwlNode interface. This is a reference to the node to add.</param>
 /// <exception cref="ArgumentException">A node with the specified ID already exists in the collection.</exception>
 /// <exception cref="ArgumentNullException">The specified ID is a null reference.</exception>
 public void Add(string nodeID, IOwlNode newNode)
 {
     if(newNode == null)
         throw (new ArgumentNullException());
     // Added:
     // Check on duplicate keys, if key is already in the dictionary,
     // then we don't to anything.
     // Why: Error coming from Hano Soma
     // Todo: Recheck this if it is correct
     OwlNode rNode = (OwlNode)_nodes[nodeID];
     if(rNode != null)
         return;
     // End
     _nodes.Add(nodeID,newNode);
 }
示例#24
0
 /// <summary>
 /// Adds a node to the collection.
 /// </summary>
 /// <param name="newNode">An object that implements the IOwlNode interface. This is a reference to the node to add.</param>
 /// <exception cref="ArgumentException">A node with the same ID already exists in the collection.</exception>
 /// <exception cref="ArgumentNullException">The ID of the specified node is a null Reference.</exception>
 public void Add(IOwlNode newNode)
 {
     Add(newNode.ID, newNode);
 }