SemanticNetwork
Class SemanticNetwork

java.lang.Object
  |
  +--SemanticNetwork.SemanticNetwork

public class SemanticNetwork
extends java.lang.Object

Defines a semantic network of concept instances. Each contains an arbitrary number of attribute and relationship instances that describe it and relate it to other concept instances, respectively. It also contains a concept node that binds it to a knowledge base to provide implicit background details.

Version:
Created 25 August 2003
Author:
Dan Tappan
See Also:
KnowledgeBase

Field Summary
private  java.util.HashMap m_concept_instances
           
private  java.lang.String m_description
           
private  KnowledgeBase m_knowledge_base
           
private  java.lang.String m_name
           
 
Constructor Summary
SemanticNetwork(java.lang.String name, java.lang.String description)
          Creates a new empty semantic network.
 
Method Summary
 void addAttributeInstance(AttributeInstance attribute_instance)
          Adds an attribute instance to this semantic network and binds it to a concept instance.
 void addConceptInstance(ConceptInstance concept_instance)
          Adds a concept instance to this semantic network and binds it to a concept instance.
 void addRelationshipInstance(RelationshipInstance relationship_instance)
          Adds a relationship instance to this semantic network and binds it to a concept instance.
 void exportToVisioViewer(java.lang.String filename)
          Exports the semantic network to a file that the Visio viewer can depict.
 SemanticNetwork getClone(java.lang.String name, java.lang.String description)
          Returns a mixed deep and shallow clone of this semantic network.
 ConceptInstance getConceptInstance(java.lang.String concept_label)
          Returns a concept instance in this semantic network.
 java.util.Set getConceptInstanceNames()
          Returns a list of concept instance names in this semantic network.
 java.util.Collection getConceptInstances()
          Returns a list of concept instances in this semantic network.
 java.lang.String getDescription()
          Returns the description of this semantic network.
 KnowledgeBase getKnowledgeBase()
          Returns the knowledge base this semantic network is linked to.
 java.lang.String getName()
          Returns the name of this semantic network.
 void linkKnowledgeBase(KnowledgeBase knowledge_base)
          Links this semantic network to the knowledge base supporting it.
 java.lang.String serialize()
          Returns a serialized representation of this semantic network.
 java.lang.String toHTMLString()
          Returns an indented HTML string representation of this object to be displayed by the Representation Viewer.
 java.lang.String toString()
          Returns a string representation of this object.
 void validate()
          Verifies that all concept instances are connected to a concept node in the knowledge base and that all concept instances each relationship instance is directed to are present in this semantic network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_name

private java.lang.String m_name

m_description

private java.lang.String m_description

m_concept_instances

private java.util.HashMap m_concept_instances

m_knowledge_base

private KnowledgeBase m_knowledge_base
Constructor Detail

SemanticNetwork

public SemanticNetwork(java.lang.String name,
                       java.lang.String description)
Creates a new empty semantic network.

Parameters:
name - - the name of the network
description - - an optional description
Method Detail

addAttributeInstance

public void addAttributeInstance(AttributeInstance attribute_instance)
                          throws java.lang.Exception
Adds an attribute instance to this semantic network and binds it to a concept instance. Call validate() after all instances have been added to verify that the semantic network was properly built.

Parameters:
attribute_instance - - the attribute instance
Throws:
java.lang.Exception - - if the attribute instance is already present in the concept instance or the concept instance is not present in the semantic network
See Also:
validate()

addConceptInstance

public void addConceptInstance(ConceptInstance concept_instance)
                        throws java.lang.Exception
Adds a concept instance to this semantic network and binds it to a concept instance. Call validate() after all instances have been added to verify that the semantic network was properly built.

Parameters:
concept_instance - - the concept instance
Throws:
java.lang.Exception - - if the concept instance is already present in the semantic network
See Also:
validate()

addRelationshipInstance

public void addRelationshipInstance(RelationshipInstance relationship_instance)
                             throws java.lang.Exception
Adds a relationship instance to this semantic network and binds it to a concept instance. Call validate() after all instances have been added to verify that the semantic network was properly built.

Parameters:
relationship_instance - - the relationship instance
Throws:
java.lang.Exception - - if the relation instance is already present in the concept instance or the concept instance is not present in the semantic network
See Also:
validate()

exportToVisioViewer

public void exportToVisioViewer(java.lang.String filename)
                         throws java.lang.Exception
Exports the semantic network to a file that the Visio viewer can depict. It does not open Visio.

Parameters:
filename - - the fully qualified output filename
Throws:
java.lang.Exception - - if the export fails

getClone

public SemanticNetwork getClone(java.lang.String name,
                                java.lang.String description)
                         throws java.lang.Exception
Returns a mixed deep and shallow clone of this semantic network. See the individual clone methods for specifics.

To ensure a valid clone, validate() is called on this semantic network.

Parameters:
name - - the name of the cloned network
description - - an optional description
Returns:
the clone
Throws:
java.lang.Exception - - if validation fails
See Also:
validate(), AttributeInstance.getClone(), ConceptInstance.getClone(), RelationshipInstance.getClone()

getConceptInstance

public ConceptInstance getConceptInstance(java.lang.String concept_label)
Returns a concept instance in this semantic network.

Returns:
the concept instance, or null if it is not present in the semantic network

getConceptInstances

public java.util.Collection getConceptInstances()
Returns a list of concept instances in this semantic network.

Returns:
the list
See Also:
ConceptInstance

getConceptInstanceNames

public java.util.Set getConceptInstanceNames()
Returns a list of concept instance names in this semantic network.

Returns:
the list
See Also:
ConceptInstance

getDescription

public java.lang.String getDescription()
Returns the description of this semantic network.

Returns:
the description

getName

public java.lang.String getName()
Returns the name of this semantic network.

Returns:
the name

getKnowledgeBase

public KnowledgeBase getKnowledgeBase()
Returns the knowledge base this semantic network is linked to.

Returns:
the knowledge base
See Also:
linkKnowledgeBase(KnowledgeBase.KnowledgeBase)

linkKnowledgeBase

public void linkKnowledgeBase(KnowledgeBase knowledge_base)
Links this semantic network to the knowledge base supporting it.

Parameters:
knowledge_base - - the knowledge base
See Also:
getKnowledgeBase()

serialize

public java.lang.String serialize()
Returns a serialized representation of this semantic network.

Returns:
the serialization

toHTMLString

public java.lang.String toHTMLString()
Returns an indented HTML string representation of this object to be displayed by the Representation Viewer.

Returns:
the String representation
See Also:
RepresentationViewer

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)

validate

public void validate()
              throws java.lang.Exception
Verifies that all concept instances are connected to a concept node in the knowledge base and that all concept instances each relationship instance is directed to are present in this semantic network.

It also builds or updates the links from the nodes in this semantic network to the knowledge base.

Throws:
java.lang.Exception - - if any concept instance does not satisfy the requirements