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

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

public class CGISLexeltWriter
extends java.lang.Object
implements ILexeltWriter

convert instances in a lexelt to maxent format.

Author:
zhongzhi

Constructor Summary
CGISLexeltWriter()
           
 
Method Summary
 java.lang.Object getInstances(ILexelt p_Lexelt)
          extract instances from p_iLexelt
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)
protected  java.lang.String toString(IInstance p_Instance, IStatistic p_Stat, int[][] p_Indice)
          get the vector of 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
 

Constructor Detail

CGISLexeltWriter

public CGISLexeltWriter()
Method Detail

getInstances

public java.lang.Object getInstances(ILexelt p_Lexelt)
                              throws java.lang.Exception
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.Exception - exception while converting p_Lexelt

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

toString

protected java.lang.String toString(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

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

toString

public java.lang.String toString(ILexelt p_Lexelt)
                          throws java.lang.Exception
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.Exception - exception while converting p_Lexelt

write

public void write(java.lang.String p_Filename,
                  ILexelt p_Lexelt)
           throws java.lang.Exception
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.lang.Exception - exception while converting p_Lexelt