absurdist
Class ConceptSystem

java.lang.Object
  extended byabsurdist.ConceptSystem
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ConceptGraph

public class ConceptSystem
extends java.lang.Object
implements java.io.Serializable

Class ConceptSystem is the data model for a concept system specifying the semantic network between the concepts. It contains all concept categoies and relation models used in the system, as well as all its concepts and relations.

See Also:
Serialized Form

Field Summary
 java.util.Vector anchors
          This is a vector that is either null (if no anchors are in use), or is of the same length as "concepts".
 java.util.Vector categories
          All concept categories involved in the system.
 java.util.Vector concepts
          All concepts in the system.
static int DIRECTED
          Direction mode for directed relation models.
static int MIXED
          Direction mode for a mixture of directed and undirected relation models.
 java.util.Vector models
          All relation models used in the system.
 java.lang.String name
          Identifier of the system.
 java.util.Hashtable relations
          All relation instances in the system.
static int UNDIRECTED
          Direction mode for undirected relation models.
 
Constructor Summary
ConceptSystem()
          Creates an empty concept system.
ConceptSystem(ConceptSystem system)
          Creates a copy of a concept system.
ConceptSystem(ConceptSystem system, double noiseCC, double noiseCI, double noiseRC, double noiseRI)
          Creates another concept system by adding some noise to an existing system.
ConceptSystem(Graph graph)
          Creates a concept system from a graph instance.
ConceptSystem(int n, double fullness)
          Creates a concept system represented as a random simple graph, with default concepts and default relations.
ConceptSystem(int n, int nCat, boolean ranked, boolean valued, double fullness, int nLabel, int directMode, boolean weighted)
          Creates a concept system represented as a random graph, categorized/randked/valued, directed/weighted/labeled as indicated, with concepts of random categories and ranks, and randomly weighted/labeled relations.
ConceptSystem(java.lang.String name, java.util.Vector categories, java.util.Vector models, java.util.Vector concepts, java.util.Hashtable relations)
          Creates a concept systems with specified contents.
 
Method Summary
 void addAnchor(int innerIdx, java.lang.String leafName)
          Adds another "anchor" (information about formerly attached leaf) to the inner node.
 void addCategory(java.lang.String category)
          Adds a concept category.
 void addConcept(Concept concept)
          Adds a concept.
 void addModel(RelationModel model)
          Adds a relation model.
 void addNoise(double noiseCC, double noiseCI, double noiseRC, double noiseRI)
          Adds some noise to this system.
 int allAnchorCnt()
          How many anchors are in this system?
 int anchorOverlap(ConceptSystem other, int iHere, int iOther)
          How many achors do Concept i of this system and Concept iother of the other system have in common? This can be used in external similarity computations
 java.lang.String getCategory(int i)
          Gets the ith concept category.
 int getCategoryIndex(java.lang.String category)
          Gets the index of a concept category in the system.
 int getCategoryNum()
          Gets the total number of concept categories in the system.
 Concept getConcept(int i)
          Gets the ith concept.
 Concept getConcept(java.lang.String name)
          Gets the concept with the specified name
 int getConceptIndex(Concept concept)
          Gets the index of a concept in the system.
 int getConceptIndex(java.lang.String name)
          Gets the index of a concept with the specified name.
 int getConceptNum()
          Gets the total number of concepts in the system.
static java.lang.String getKey(int i, int j)
          Gets the key for the relations between concept i and j.
 RelationModel getModel(int i)
          Gets the ith relation model.
 RelationModel getModel(java.lang.String label)
          Gets the relation model with the specified label.
 int getModelIndex(RelationModel model)
          Gets the index of a relation model in the system.
 int getModelIndex(java.lang.String label)
          Gets the index of a relation model with the specified label.
 int getModelNum()
          Gets the total number of relation models in the system.
 Relation getRelation(int i, int j, java.lang.String label)
          Gets the relation of the specified label between concept i and concept j.
static Relation getRelation(java.util.Vector rellist, java.lang.String label)
          Gets the relation of the specified label in a relation list.
 java.util.Vector getRelations(int i, int j)
          Gets the relation list between concept i and concept j.
 int getRelListNum()
          Gets the total number of relation lists in the system.
 boolean isCategorized()
          Checks whether this concept system is categorized, i.e.
 boolean isDirected()
          Checks whether this concept system contains any directed relation models.
 boolean isLabeled()
          Checks whether this concept system is labeled, i.e.
 boolean isRanked()
          Checks whether any of the concept in this concept system is ranked.
 boolean isSimple()
          Checks whether this is a simple system, i.e.
 boolean isValued()
          Checks whether any of the concept in this concept system is valued.
 boolean isWeighted()
          Checks whether any of the relation in this concept system is weighted.
 void putRelation(int i, int j, Relation relation)
          Adds the specified relation to the relation list between concept i and concept j.
static void putRelation(java.util.Vector rellist, Relation relation)
          Adds the specified relation to a relation list.
 void putRelations(int i, int j, java.util.Vector rellist)
          Puts the relation list between concept i and concept j.
static ConceptSystem readBin(java.lang.String fileName)
          Creates and reads a concept system from a binary file.
static ConceptSystem readTxt(java.lang.String filename)
          Creates and reads a concept system from a text file.
 void removeRelation(int i, int j, Relation relation)
          Removes the specified relation from the relation list between concept i and concept j; if this causes the list to be empty, remove the list from the system.
 void removeRelations(int i, int j)
          Removes the relation list between concept i and concept j.
 boolean simpleConcepts()
          Checks whether this concept system contains only simple, i.e.
 boolean simpleRelations()
          Checks whether this concept system contains only simple, i.e.
 java.lang.String toString()
          Returns a string representation of this concept system.
 void writeBin(java.lang.String fileName)
          Writes out the concept systems object into a binary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDIRECTED

public static final int UNDIRECTED
Direction mode for undirected relation models.

See Also:
Constant Field Values

DIRECTED

public static final int DIRECTED
Direction mode for directed relation models.

See Also:
Constant Field Values

MIXED

public static final int MIXED
Direction mode for a mixture of directed and undirected relation models.

See Also:
Constant Field Values

name

public java.lang.String name
Identifier of the system.


categories

public java.util.Vector categories
All concept categories involved in the system.


models

public java.util.Vector models
All relation models used in the system.


concepts

public java.util.Vector concepts
All concepts in the system.


relations

public java.util.Hashtable relations
All relation instances in the system. Each hashtable slot cooresponds to a concept pair and is keyed by the combaination of their indices. Each slot stores a list that contains various labeled relations existing between the concept pair. Keys of the table are obtained by getKey(). Note: An undirected relation is stored in both slots that correspond to its concept pair in each direction correspondingly.


anchors

public java.util.Vector anchors
This is a vector that is either null (if no anchors are in use), or is of the same length as "concepts". The i-th element is either a null, or a Vector of Strings; each component of that is the name of a leaf node that had been attached to the i-th internal node (concept) prior to the graph transformation done by splitAnchors.pl. This information comes from the "Anchors" section of the input text file, and is non-empty only in the case of "tree mapping" (July 29, 2003)

Constructor Detail

ConceptSystem

public ConceptSystem()
Creates an empty concept system.


ConceptSystem

public ConceptSystem(java.lang.String name,
                     java.util.Vector categories,
                     java.util.Vector models,
                     java.util.Vector concepts,
                     java.util.Hashtable relations)
Creates a concept systems with specified contents.


ConceptSystem

public ConceptSystem(Graph graph)
Creates a concept system from a graph instance.


ConceptSystem

public ConceptSystem(int n,
                     double fullness)
              throws java.lang.Exception
Creates a concept system represented as a random simple graph, with default concepts and default relations.

Parameters:
n - Number of concepts in the system.
fullness - Percentage of relations among the total possible relation links in the system. The value of fullness ranges between [0,1].

ConceptSystem

public ConceptSystem(int n,
                     int nCat,
                     boolean ranked,
                     boolean valued,
                     double fullness,
                     int nLabel,
                     int directMode,
                     boolean weighted)
              throws java.lang.Exception
Creates a concept system represented as a random graph, categorized/randked/valued, directed/weighted/labeled as indicated, with concepts of random categories and ranks, and randomly weighted/labeled relations.

Parameters:
n - Number of concepts in the system.
nCat - Number of concept categories in the system.
ranked - Whether the concepts are rankded.
valued - Whether the concepts have feature values.
fullness - Percentage of relations among the total possible relation links in the system.
nLabel - Number of different relation labels in the system.
directMode - Whether the system has directed, undirected, or both types of relations.
weighted - Whether the relations are weighted.

ConceptSystem

public ConceptSystem(ConceptSystem system)
Creates a copy of a concept system.


ConceptSystem

public ConceptSystem(ConceptSystem system,
                     double noiseCC,
                     double noiseCI,
                     double noiseRC,
                     double noiseRI)
Creates another concept system by adding some noise to an existing system. All noise values are in the range of [0, 1]). This is how it works:

Parameters:
noiseCC - Concept noise coverage, i.e. percentage of concepts that are affected
noiseCI - Concept noise intensity, i.e. amount of changes to concept quantitative values (d1 & d2)
noiseRC - Relation noise coverage, i.e. percentage of relations that are changed and even inverted
noiseRI - Relation noise intensity, i.e. amount of change to relation weight
Method Detail

addNoise

public void addNoise(double noiseCC,
                     double noiseCI,
                     double noiseRC,
                     double noiseRI)
Adds some noise to this system. All noise are in the range of [0, 1])

Parameters:
noiseCC - Concept noise coverage, i.e. percentage of concepts that are affected
noiseCI - Concept noise intensity, i.e. amount of changes to concept quantitative values (d1 & d2)
noiseRC - Relation noise coverage, i.e. percentage of relations that are changed and even inverted
noiseRI - Relation noise intensity, i.e. amount of change to relation weight

getCategoryNum

public int getCategoryNum()
Gets the total number of concept categories in the system.


getModelNum

public int getModelNum()
Gets the total number of relation models in the system.


getConceptNum

public int getConceptNum()
Gets the total number of concepts in the system.


getRelListNum

public int getRelListNum()
Gets the total number of relation lists in the system.


getCategoryIndex

public int getCategoryIndex(java.lang.String category)
Gets the index of a concept category in the system.


getModelIndex

public int getModelIndex(RelationModel model)
Gets the index of a relation model in the system.


getModelIndex

public int getModelIndex(java.lang.String label)
Gets the index of a relation model with the specified label.

Returns:
-1 if not found.

getConceptIndex

public int getConceptIndex(Concept concept)
Gets the index of a concept in the system.


getConceptIndex

public int getConceptIndex(java.lang.String name)
Gets the index of a concept with the specified name.

Returns:
-1 if not found.

getCategory

public java.lang.String getCategory(int i)
Gets the ith concept category.


getModel

public RelationModel getModel(int i)
Gets the ith relation model.


getModel

public RelationModel getModel(java.lang.String label)
Gets the relation model with the specified label.

Returns:
Null if not found.

getConcept

public Concept getConcept(int i)
Gets the ith concept.


getConcept

public Concept getConcept(java.lang.String name)
Gets the concept with the specified name

Returns:
Null if not found.

getKey

public static java.lang.String getKey(int i,
                                      int j)
Gets the key for the relations between concept i and j.


getRelations

public java.util.Vector getRelations(int i,
                                     int j)
Gets the relation list between concept i and concept j.


getRelation

public Relation getRelation(int i,
                            int j,
                            java.lang.String label)
Gets the relation of the specified label between concept i and concept j.


getRelation

public static Relation getRelation(java.util.Vector rellist,
                                   java.lang.String label)
Gets the relation of the specified label in a relation list.


putRelations

public void putRelations(int i,
                         int j,
                         java.util.Vector rellist)
Puts the relation list between concept i and concept j.


putRelation

public void putRelation(int i,
                        int j,
                        Relation relation)
Adds the specified relation to the relation list between concept i and concept j.


addCategory

public void addCategory(java.lang.String category)
Adds a concept category.


addModel

public void addModel(RelationModel model)
Adds a relation model.


addConcept

public void addConcept(Concept concept)
Adds a concept.


putRelation

public static void putRelation(java.util.Vector rellist,
                               Relation relation)
Adds the specified relation to a relation list.


removeRelations

public void removeRelations(int i,
                            int j)
Removes the relation list between concept i and concept j.


removeRelation

public void removeRelation(int i,
                           int j,
                           Relation relation)
Removes the specified relation from the relation list between concept i and concept j; if this causes the list to be empty, remove the list from the system.


isCategorized

public boolean isCategorized()
Checks whether this concept system is categorized, i.e. contains multiple concept categories.


isRanked

public boolean isRanked()
Checks whether any of the concept in this concept system is ranked.


isValued

public boolean isValued()
Checks whether any of the concept in this concept system is valued.


simpleConcepts

public boolean simpleConcepts()
Checks whether this concept system contains only simple, i.e. uncategorized(mono-categorized)/unranked/unvalued, concepts.


isLabeled

public boolean isLabeled()
Checks whether this concept system is labeled, i.e. contains multiple relation labels/models.


isDirected

public boolean isDirected()
Checks whether this concept system contains any directed relation models.


isWeighted

public boolean isWeighted()
Checks whether any of the relation in this concept system is weighted.


simpleRelations

public boolean simpleRelations()
Checks whether this concept system contains only simple, i.e. unlabeled(monolabled)/undirected/unweighted relations.


isSimple

public boolean isSimple()
Checks whether this is a simple system, i.e. contains only simple concepts and relations.


addAnchor

public void addAnchor(int innerIdx,
                      java.lang.String leafName)
Adds another "anchor" (information about formerly attached leaf) to the inner node. This method should only be used after all concepts have been initialized


allAnchorCnt

public int allAnchorCnt()
How many anchors are in this system?


anchorOverlap

public int anchorOverlap(ConceptSystem other,
                         int iHere,
                         int iOther)
How many achors do Concept i of this system and Concept iother of the other system have in common? This can be used in external similarity computations


readTxt

public static ConceptSystem readTxt(java.lang.String filename)
                             throws java.lang.Exception
Creates and reads a concept system from a text file.

Returns:
The created concept system.
Throws:
java.lang.Exception

readBin

public static ConceptSystem readBin(java.lang.String fileName)
                             throws java.lang.Exception
Creates and reads a concept system from a binary file.

Returns:
The created concept system.
Throws:
java.lang.Exception

writeBin

public void writeBin(java.lang.String fileName)
              throws java.lang.Exception
Writes out the concept systems object into a binary file.

Throws:
java.lang.Exception

toString

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