iitb.con.net
Class FileConceptNet

java.lang.Object
  extended by iitb.con.net.ConceptNet
      extended by iitb.con.net.FileConceptNet

public class FileConceptNet
extends ConceptNet

FileConceptNet extends and provides the implementation for the ConceptNet class. It manages the Type and Instance in the concept-nets.
It provides methods to add, update, and remove the types and instances in the concept-nets.
It also provides a high level retrieval support through Query object.

See Also:
Type, Instance, Entity, Relation

Field Summary
static java.lang.String BAK
           
 
Constructor Summary
FileConceptNet(java.lang.String name, java.lang.String mode)
          Initializes the Concept-Net.
 
Method Summary
 int add(Instance instance)
          Adds the instance to the concept-net.
The instance can be EntityInstance or RelationInstance
 void addInstance(InstanceMetaItem item)
           
 int addInstance(Instance instance, short clusterId)
           
 boolean close()
          Closes the concept-net.
 Result commit()
          Commits the changes to the concept-net.
<K extends java.lang.Comparable<K>>
Result
createIndex(java.lang.String typeName, java.lang.String attributeName, K dataType)
          Creates Index of the specified type's attribute.
 Result dropIndex(Type type, java.lang.String attributeName)
          Drops the index for the specified type attribute.
 Type getType(java.lang.String name)
          Returns the Type of specified name.
 boolean hasType(java.lang.String name)
          Returns true if type exists in the concept-net
 Result induct(Type type)
          Inducts Type into the concept-net
 Query query()
          Returns the Query object.
 void reInitializeNetFiles(java.lang.String backupName)
          Reinitializes the instances related files for clustering, defragementation purposes.
 Result remove(Instance instance)
          Removes the instance from the concept-net.
 Result remove(int instanceId)
          Removes the existing Instance from the concept-nets.
 void showStaistics()
          Display the statistical information about the concept-net.
 Result update(Instance instance)
          Updates the instance in the concept-net.
 
Methods inherited from class iitb.con.net.ConceptNet
getConceptNetDir, getConceptNetName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BAK

public static final java.lang.String BAK
See Also:
Constant Field Values
Constructor Detail

FileConceptNet

public FileConceptNet(java.lang.String name,
                      java.lang.String mode)
               throws java.io.FileNotFoundException,
                      java.io.IOException
Initializes the Concept-Net.

The Type Table and Instance Table are loaded into the memory and other necessary files are opened in the specified mode.

Parameters:
name - concept-net name
mode - opening mode; can read (r) or read-write (rw)
Throws:
java.io.FileNotFoundException - if concept-net does not exists then throws exception
java.io.IOException - if any file operations fail
Method Detail

add

public int add(Instance instance)
Adds the instance to the concept-net.
The instance can be EntityInstance or RelationInstance

Specified by:
add in class ConceptNet
Parameters:
instance - Instance
Returns:
the added instance's id

addInstance

public void addInstance(InstanceMetaItem item)

addInstance

public int addInstance(Instance instance,
                       short clusterId)

close

public boolean close()
Closes the concept-net.

Specified by:
close in class ConceptNet
Returns:
true on success

commit

public Result commit()
Commits the changes to the concept-net.

The operations like induct, add, update, remove, etc., does not affect the concept-net unless it is committed.

Specified by:
commit in class ConceptNet
Returns:
Result

createIndex

public <K extends java.lang.Comparable<K>> Result createIndex(java.lang.String typeName,
                                                              java.lang.String attributeName,
                                                              K dataType)
Creates Index of the specified type's attribute.

Specified by:
createIndex in class ConceptNet
Type Parameters:
K - data type object
Parameters:
typeName - type name
attributeName - attribute name
dataType - data type
Returns:
Result

dropIndex

public Result dropIndex(Type type,
                        java.lang.String attributeName)
Drops the index for the specified type attribute.

Specified by:
dropIndex in class ConceptNet
Parameters:
type - Type object
attributeName - attribute name
Returns:
Result

getType

public Type getType(java.lang.String name)
Returns the Type of specified name. Returns NULL if type does not exists.

Specified by:
getType in class ConceptNet
Parameters:
name - type name
Returns:
Type

hasType

public boolean hasType(java.lang.String name)
Returns true if type exists in the concept-net

Specified by:
hasType in class ConceptNet
Parameters:
name - type name
Returns:
true if type exists in the concept-net

induct

public Result induct(Type type)
Inducts Type into the concept-net

Specified by:
induct in class ConceptNet
Parameters:
type - Type
Returns:
Type

query

public Query query()
Returns the Query object. User can query the concept-net using the methods of the Query object.

Specified by:
query in class ConceptNet
Returns:
Query

reInitializeNetFiles

public void reInitializeNetFiles(java.lang.String backupName)
Reinitializes the instances related files for clustering, defragementation purposes. Also backup the old data before re-initializing

Parameters:
backupName - name of the backup

remove

public Result remove(Instance instance)
Removes the instance from the concept-net.

Specified by:
remove in class ConceptNet
Parameters:
instance - Instance
Returns:
Result

remove

public Result remove(int instanceId)
Removes the existing Instance from the concept-nets.

Specified by:
remove in class ConceptNet
Parameters:
instanceId - instance's id
Returns:
Result

showStaistics

public void showStaistics()
Display the statistical information about the concept-net.

Specified by:
showStaistics in class ConceptNet

update

public Result update(Instance instance)
Updates the instance in the concept-net.

Specified by:
update in class ConceptNet
Parameters:
instance - Instance
Returns:
Result