sg.edu.nus.comp.nlp.ims.lexelt
Class CStatistic

java.lang.Object
  extended by sg.edu.nus.comp.nlp.ims.lexelt.CStatistic
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, IStatistic

public class CStatistic
extends java.lang.Object
implements IStatistic

statistic of all training instances of a lexelt.

Author:
zhongzhi
See Also:
Serialized Form

Field Summary
protected  java.lang.String m_Default
           
protected  java.lang.String m_Encoding
           
protected  java.util.Hashtable<java.lang.String,java.lang.Integer> m_KeyMap
           
protected  java.util.ArrayList<java.lang.String> m_Keys
           
protected  int m_M2
           
protected  int m_Size
           
protected  java.util.regex.Pattern m_SplitPattern
           
protected  boolean m_Status
           
protected  java.util.ArrayList<java.lang.Integer> m_TagCount
           
protected  java.util.Hashtable<java.lang.String,java.lang.Integer> m_TagMap
           
protected  java.util.ArrayList<java.lang.String> m_Tags
           
protected  java.util.ArrayList<java.lang.Class<? extends IFeature>> m_TypeEnum
           
protected  java.util.ArrayList<java.lang.Integer> m_Types
           
protected  java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> m_ValueCount
           
protected  java.util.ArrayList<java.util.Hashtable<java.lang.String,java.lang.Integer>> m_Values
           
protected  java.util.ArrayList<java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>> m_ValueTagCount
           
protected static java.lang.String SEPARATOR
           
 
Constructor Summary
CStatistic()
          default constructor
CStatistic(java.lang.String p_Encoding)
          constructor with file encoding
 
Method Summary
 boolean addInstance(IInstance p_Instance)
          add one instance into the statistic.
protected  void check()
          check the status
 void clear()
          clear the statistic
 java.lang.Object clone()
           
 boolean contains(int p_KeyIndex, java.lang.String p_Value)
          check whether feature p_Index contains value p_Value
 int getCount(int p_Index, java.lang.String p_Value)
          get the count of value p_Value of feature p_Index
 int getCount(int p_KeyIndex, java.lang.String p_Value, java.lang.String p_Tag)
          get the count of value p_Value of feature p_Key with p_Tag
 int getCount(java.lang.String p_Key, java.lang.String p_Value)
          get the count of value p_Value of feature p_Key
 int getCount(java.lang.String p_Key, java.lang.String p_Value, java.lang.String p_Tag)
          get the count of value p_Value of feature p_Key with p_Tag
 java.lang.String getDefaultValue()
          get the default value of feature
 int getIndex(java.lang.String p_Key)
          get the feature index of feature p_Key
 java.lang.String getKey(int p_Index)
          get the feature name of feature p_Index
 java.util.List<java.lang.String> getKeys()
          get the list of feature names in the statistic
 int getParameter(java.lang.String p_Parameter)
          get the value of p_Parameter
 int getTagCount(java.lang.String p_Tag)
          get count of tag
 java.util.Set<java.lang.String> getTags()
          get the tag list
 java.util.List<java.lang.String> getTagsInOrder()
          get the tags in order
 java.lang.String getType(int p_Index)
          get the feature type of feature p_Index
 java.lang.String getType(java.lang.String p_Key)
          get feature type of feature p_Key
 java.util.List<java.lang.String> getValue(int p_Index)
          get the value list of feature p_Index
 java.util.List<java.lang.String> getValue(java.lang.String p_Key)
          get the value list of feature p_key
 boolean isProcessed()
          check whether the statistic object has been processed like filtering and some others
 boolean loadFromFile(java.lang.String p_FileName)
          load the statistic information from file
protected  void remove(int p_FeatureIndex)
          remove a feature
protected  void remove(int p_FeatureIndex, java.lang.String p_Value)
          remove a value of a feature
 boolean removeInstance(IInstance p_iInstance)
          remove one instance from the statistic
 void select(IFeatureSelector p_Selector)
          select features
 boolean setParameter(java.lang.String p_Parameter, int p_Value)
          set parameter of the statistic information
 int size()
          get the number of instances
 boolean writeToFile(java.lang.String p_FileName)
          write the statistic information into file
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Default

protected final java.lang.String m_Default
See Also:
Constant Field Values

m_Status

protected boolean m_Status

m_Size

protected int m_Size

m_Keys

protected java.util.ArrayList<java.lang.String> m_Keys

m_KeyMap

protected java.util.Hashtable<java.lang.String,java.lang.Integer> m_KeyMap

m_TypeEnum

protected java.util.ArrayList<java.lang.Class<? extends IFeature>> m_TypeEnum

m_Types

protected java.util.ArrayList<java.lang.Integer> m_Types

m_Values

protected java.util.ArrayList<java.util.Hashtable<java.lang.String,java.lang.Integer>> m_Values

m_ValueCount

protected java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> m_ValueCount

m_ValueTagCount

protected java.util.ArrayList<java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>> m_ValueTagCount

m_TagMap

protected java.util.Hashtable<java.lang.String,java.lang.Integer> m_TagMap

m_Tags

protected java.util.ArrayList<java.lang.String> m_Tags

m_TagCount

protected java.util.ArrayList<java.lang.Integer> m_TagCount

m_M2

protected int m_M2

SEPARATOR

protected static final java.lang.String SEPARATOR
See Also:
Constant Field Values

m_SplitPattern

protected java.util.regex.Pattern m_SplitPattern

m_Encoding

protected java.lang.String m_Encoding
Constructor Detail

CStatistic

public CStatistic()
default constructor


CStatistic

public CStatistic(java.lang.String p_Encoding)
constructor with file encoding

Parameters:
p_Encoding - file encoding
Method Detail

addInstance

public boolean addInstance(IInstance p_Instance)
Description copied from interface: IStatistic
add one instance into the statistic.

Specified by:
addInstance in interface IStatistic
Parameters:
p_Instance - instance
Returns:
add success or not

removeInstance

public boolean removeInstance(IInstance p_iInstance)
Description copied from interface: IStatistic
remove one instance from the statistic

Specified by:
removeInstance in interface IStatistic
Parameters:
p_iInstance - instance
Returns:
success or not

getKeys

public java.util.List<java.lang.String> getKeys()
Description copied from interface: IStatistic
get the list of feature names in the statistic

Specified by:
getKeys in interface IStatistic
Returns:
list of keys

getParameter

public int getParameter(java.lang.String p_Parameter)
Description copied from interface: IStatistic
get the value of p_Parameter

Specified by:
getParameter in interface IStatistic
Parameters:
p_Parameter - parameter name
Returns:
value

loadFromFile

public boolean loadFromFile(java.lang.String p_FileName)
Description copied from interface: IStatistic
load the statistic information from file

Specified by:
loadFromFile in interface IStatistic
Parameters:
p_FileName - statistic file
Returns:
success or not

setParameter

public boolean setParameter(java.lang.String p_Parameter,
                            int p_Value)
Description copied from interface: IStatistic
set parameter of the statistic information

Specified by:
setParameter in interface IStatistic
Parameters:
p_Parameter - parameter name
p_Value - parameter value
Returns:
success or not

writeToFile

public boolean writeToFile(java.lang.String p_FileName)
Description copied from interface: IStatistic
write the statistic information into file

Specified by:
writeToFile in interface IStatistic
Parameters:
p_FileName - file to be written
Returns:
success or not

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

contains

public boolean contains(int p_KeyIndex,
                        java.lang.String p_Value)
Description copied from interface: IStatistic
check whether feature p_Index contains value p_Value

Specified by:
contains in interface IStatistic
Parameters:
p_KeyIndex - feature index
p_Value - feature value
Returns:
contains or not

getCount

public int getCount(java.lang.String p_Key,
                    java.lang.String p_Value)
Description copied from interface: IStatistic
get the count of value p_Value of feature p_Key

Specified by:
getCount in interface IStatistic
Parameters:
p_Key - feature name
p_Value - feature value
Returns:
count

getCount

public int getCount(int p_Index,
                    java.lang.String p_Value)
Description copied from interface: IStatistic
get the count of value p_Value of feature p_Index

Specified by:
getCount in interface IStatistic
Parameters:
p_Index - feature index
p_Value - feature value
Returns:
count

getIndex

public int getIndex(java.lang.String p_Key)
Description copied from interface: IStatistic
get the feature index of feature p_Key

Specified by:
getIndex in interface IStatistic
Parameters:
p_Key - feature name
Returns:
feature index

getKey

public java.lang.String getKey(int p_Index)
Description copied from interface: IStatistic
get the feature name of feature p_Index

Specified by:
getKey in interface IStatistic
Parameters:
p_Index - feature index
Returns:
feature name

size

public int size()
Description copied from interface: IStatistic
get the number of instances

Specified by:
size in interface IStatistic
Returns:
size

getType

public java.lang.String getType(int p_Index)
Description copied from interface: IStatistic
get the feature type of feature p_Index

Specified by:
getType in interface IStatistic
Parameters:
p_Index - feature index
Returns:
feature type

getType

public java.lang.String getType(java.lang.String p_Key)
Description copied from interface: IStatistic
get feature type of feature p_Key

Specified by:
getType in interface IStatistic
Parameters:
p_Key - feature name
Returns:
feature type

getValue

public java.util.List<java.lang.String> getValue(int p_Index)
Description copied from interface: IStatistic
get the value list of feature p_Index

Specified by:
getValue in interface IStatistic
Parameters:
p_Index - feature index
Returns:
value list

getValue

public java.util.List<java.lang.String> getValue(java.lang.String p_Key)
Description copied from interface: IStatistic
get the value list of feature p_key

Specified by:
getValue in interface IStatistic
Parameters:
p_Key - feature name
Returns:
value list

clear

public void clear()
Description copied from interface: IStatistic
clear the statistic

Specified by:
clear in interface IStatistic

getTags

public java.util.Set<java.lang.String> getTags()
Description copied from interface: IStatistic
get the tag list

Specified by:
getTags in interface IStatistic
Returns:
tag list

getTagsInOrder

public java.util.List<java.lang.String> getTagsInOrder()
Description copied from interface: IStatistic
get the tags in order

Specified by:
getTagsInOrder in interface IStatistic
Returns:
tag list

getTagCount

public int getTagCount(java.lang.String p_Tag)
Description copied from interface: IStatistic
get count of tag

Specified by:
getTagCount in interface IStatistic
Parameters:
p_Tag - tag name
Returns:
tag count

getDefaultValue

public java.lang.String getDefaultValue()
Description copied from interface: IStatistic
get the default value of feature

Specified by:
getDefaultValue in interface IStatistic
Returns:
default value

getCount

public int getCount(java.lang.String p_Key,
                    java.lang.String p_Value,
                    java.lang.String p_Tag)
Description copied from interface: IStatistic
get the count of value p_Value of feature p_Key with p_Tag

Specified by:
getCount in interface IStatistic
Parameters:
p_Key - feature name
p_Value - feature value
p_Tag - tag
Returns:
count

getCount

public int getCount(int p_KeyIndex,
                    java.lang.String p_Value,
                    java.lang.String p_Tag)
Description copied from interface: IStatistic
get the count of value p_Value of feature p_Key with p_Tag

Specified by:
getCount in interface IStatistic
Parameters:
p_KeyIndex - feature index
p_Value - feature value
p_Tag - tag
Returns:
count

isProcessed

public boolean isProcessed()
Description copied from interface: IStatistic
check whether the statistic object has been processed like filtering and some others

Specified by:
isProcessed in interface IStatistic
Returns:
status

select

public void select(IFeatureSelector p_Selector)
Description copied from interface: IStatistic
select features

Specified by:
select in interface IStatistic
Parameters:
p_Selector - feature selector

check

protected void check()
check the status


remove

protected void remove(int p_FeatureIndex)
remove a feature

Parameters:
p_FeatureIndex - feature index

remove

protected void remove(int p_FeatureIndex,
                      java.lang.String p_Value)
remove a value of a feature

Parameters:
p_FeatureIndex - feature index
p_Value - feature value