sg.edu.nus.comp.nlp.ims.io
Class CLibLinearLexeltWriter

java.lang.Object
  extended by sg.edu.nus.comp.nlp.ims.io.CLibLinearLexeltWriter
All Implemented Interfaces:
ILexeltWriter

public class CLibLinearLexeltWriter
extends java.lang.Object
implements ILexeltWriter

convert instances in a lexelt to liblinear format

Author:
zhongzhi

Field Summary
protected  double m_Bias
           
protected  int m_MaxIndex
           
 
Constructor Summary
CLibLinearLexeltWriter()
          constructor
CLibLinearLexeltWriter(double bias)
          constructor
 
Method Summary
 double getBias()
          get bias
 java.lang.Object getInstances(ILexelt p_Lexelt)
          extract instances from p_iLexelt
protected  liblinear.FeatureNode[] getVector(IInstance p_Instance, IStatistic p_Stat, int[][] p_Indice)
          get the vector of one instance
protected  int[][] loadStatistic(ILexelt p_iLexelt)
          load the statistic of p_iLexelt for each feature type in statistic if feature is binary keep it else if feature is list and the number of values is less than 2 one new feature else set each value as a new feature
protected  java.util.HashSet<java.lang.Integer> processTags(IStatistic p_Stat, java.util.ArrayList<java.lang.String> p_Tags)
          change tags to integer (start from 1)
 void setBias(double p_Bias)
          set bias
protected  java.lang.String toString(IInstance p_Instance, IStatistic p_Stat, int[][] p_Indice)
          generate feature vector for one instance
 java.lang.String toString(ILexelt p_Lexelt)
          write lexelt to a string
 void write(java.lang.String p_Filename, ILexelt p_Lexelt)
          write information of p_iLexelt to p_FileName in some format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Bias

protected double m_Bias

m_MaxIndex

protected int m_MaxIndex
Constructor Detail

CLibLinearLexeltWriter

public CLibLinearLexeltWriter()
constructor


CLibLinearLexeltWriter

public CLibLinearLexeltWriter(double bias)
constructor

Parameters:
bias - bias
Method Detail

setBias

public void setBias(double p_Bias)
set bias

Parameters:
p_Bias - bias

getBias

public double getBias()
get bias

Returns:
bias

loadStatistic

protected int[][] loadStatistic(ILexelt p_iLexelt)
                         throws java.lang.ClassNotFoundException
load the statistic of p_iLexelt for each feature type in statistic if feature is binary keep it else if feature is list and the number of values is less than 2 one new feature else set each value as a new feature

Parameters:
p_iLexelt - lexelt
Returns:
indices
Throws:
java.lang.ClassNotFoundException

getVector

protected liblinear.FeatureNode[] getVector(IInstance p_Instance,
                                            IStatistic p_Stat,
                                            int[][] p_Indice)
get the vector of one instance

Parameters:
p_Instance - input instance
p_Stat - statistic
Returns:
feature vector

toString

protected java.lang.String toString(IInstance p_Instance,
                                    IStatistic p_Stat,
                                    int[][] p_Indice)
generate feature vector for one instance

Parameters:
p_Instance - input instance
p_Stat - statisitc of training data set
p_Indice - feature indice
Returns:
feature vector

processTags

protected java.util.HashSet<java.lang.Integer> processTags(IStatistic p_Stat,
                                                           java.util.ArrayList<java.lang.String> p_Tags)
change tags to integer (start from 1)

Parameters:
p_Stat - statistic
p_Tags - real tags
Returns:
new tags

getInstances

public java.lang.Object getInstances(ILexelt p_Lexelt)
                              throws java.lang.ClassNotFoundException
Description copied from interface: ILexeltWriter
extract instances from p_iLexelt

Specified by:
getInstances in interface ILexeltWriter
Parameters:
p_Lexelt - lexelt
Returns:
instances
Throws:
java.lang.ClassNotFoundException

toString

public java.lang.String toString(ILexelt p_Lexelt)
                          throws java.lang.ClassNotFoundException
Description copied from interface: ILexeltWriter
write lexelt to a string

Specified by:
toString in interface ILexeltWriter
Parameters:
p_Lexelt - lexelt
Returns:
feature vector string
Throws:
java.lang.ClassNotFoundException

write

public void write(java.lang.String p_Filename,
                  ILexelt p_Lexelt)
           throws java.io.IOException,
                  java.lang.ClassNotFoundException
Description copied from interface: ILexeltWriter
write information of p_iLexelt to p_FileName in some format

Specified by:
write in interface ILexeltWriter
Parameters:
p_Filename - file name
p_Lexelt - lexelt
Throws:
java.io.IOException
java.lang.ClassNotFoundException