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

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

public class CLibSVMLexeltWriter
extends java.lang.Object
implements ILexeltWriter

convert instances in a lexelt to libsvm format.

Author:
zhongzhi

Constructor Summary
CLibSVMLexeltWriter()
          default constructor
 
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)
 java.lang.String toString(ILexelt p_iLexelt)
          write lexelt to a string
 void write(java.lang.String p_Filename, ILexelt p_iLexelt)
          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

CLibSVMLexeltWriter

public CLibSVMLexeltWriter()
default constructor

Method Detail

write

public void write(java.lang.String p_Filename,
                  ILexelt p_iLexelt)
           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_iLexelt - lexelt
Throws:
java.io.IOException
java.lang.ClassNotFoundException

toString

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

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

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 - cannot find the defined type

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

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