org.maltparser.ml.liblinear
Class Liblinear
java.lang.Object
org.maltparser.ml.liblinear.Liblinear
- All Implemented Interfaces:
- LearningMethod
public class Liblinear
- extends Object
- implements LearningMethod
Method Summary |
void |
addInstance(SingleDecision decision,
FeatureVector featureVector)
|
protected void |
closeInstanceWriter()
|
void |
decreaseNumberOfInstances()
|
protected void |
finalize()
|
void |
finalizeSentence(DependencyStructure dependencyGraph)
|
double |
getBias()
|
DependencyParserConfig |
getConfiguration()
Returns the current configuration |
protected File |
getFile(String suffix)
|
protected InputStreamReader |
getInstanceInputStreamReader(String suffix)
|
protected OutputStreamWriter |
getInstanceOutputStreamWriter(String suffix)
|
BufferedWriter |
getInstanceWriter()
|
int |
getLearnerMode()
|
String |
getLearningMethodName()
|
String |
getLibLinearOptions()
|
liblinear.Parameter |
getLiblinearParameters()
|
String[] |
getLibLinearParamStringArray()
|
int |
getNumberOfInstances()
|
InstanceModel |
getOwner()
|
String |
getParamString()
Returns the parameter string for used for configure Liblinear |
void |
increaseNumberOfInstances()
|
void |
initLiblinearOptions()
|
protected void |
initSpecialParameters()
|
void |
liblinear_predict_with_kbestlist(liblinear.Model model,
liblinear.FeatureNode[] x,
KBestList kBestList)
|
static void |
maltSVMFormat2OriginalSVMFormat(InputStreamReader isr,
OutputStreamWriter osw,
int[] cardinalities)
Converts the instance file (Malt's own SVM format) into the Liblinear (SVMLight) format. |
void |
moveAllInstances(LearningMethod method,
FeatureFunction divideFeature,
ArrayList<Integer> divideFeatureIndexVector)
|
void |
noMoreInstances()
|
void |
parseParameters(String paramstring)
|
boolean |
predict(FeatureVector featureVector,
SingleDecision decision)
|
liblinear.Problem |
readLibLinearProblem(InputStreamReader isr,
int[] cardinalities)
Reads an instance file into a svm_problem object according to the Malt-SVM format, which is column fixed format (tab-separated). |
void |
setLearnerMode(int learnerMode)
|
protected void |
setLearningMethodName(String name)
|
protected void |
setNumberOfInstances(int numberOfInstances)
|
protected void |
setOwner(InstanceModel owner)
|
void |
terminate()
|
String |
toString()
|
void |
train(FeatureVector featureVector)
|
LIBLINEAR_VERSION
public static final String LIBLINEAR_VERSION
- See Also:
- Constant Field Values
owner
protected InstanceModel owner
learnerMode
protected int learnerMode
name
protected String name
numberOfInstances
protected int numberOfInstances
saveInstanceFiles
protected boolean saveInstanceFiles
excludeNullValues
protected boolean excludeNullValues
pathExternalLiblinearTrain
protected String pathExternalLiblinearTrain
Liblinear
public Liblinear(InstanceModel owner,
Integer learnerMode)
throws MaltChainedException
- Constructs a Liblinear learner.
- Parameters:
owner
- the guide model ownerlearnerMode
- the mode of the learner TRAIN or CLASSIFY
- Throws:
MaltChainedException
addInstance
public void addInstance(SingleDecision decision,
FeatureVector featureVector)
throws MaltChainedException
- Specified by:
addInstance
in interface LearningMethod
- Throws:
MaltChainedException
finalizeSentence
public void finalizeSentence(DependencyStructure dependencyGraph)
throws MaltChainedException
- Specified by:
finalizeSentence
in interface LearningMethod
- Throws:
MaltChainedException
noMoreInstances
public void noMoreInstances()
throws MaltChainedException
- Specified by:
noMoreInstances
in interface LearningMethod
- Throws:
MaltChainedException
train
public void train(FeatureVector featureVector)
throws MaltChainedException
- Specified by:
train
in interface LearningMethod
- Throws:
MaltChainedException
moveAllInstances
public void moveAllInstances(LearningMethod method,
FeatureFunction divideFeature,
ArrayList<Integer> divideFeatureIndexVector)
throws MaltChainedException
- Specified by:
moveAllInstances
in interface LearningMethod
- Throws:
MaltChainedException
predict
public boolean predict(FeatureVector featureVector,
SingleDecision decision)
throws MaltChainedException
- Specified by:
predict
in interface LearningMethod
- Throws:
MaltChainedException
terminate
public void terminate()
throws MaltChainedException
- Specified by:
terminate
in interface LearningMethod
- Throws:
MaltChainedException
getInstanceWriter
public BufferedWriter getInstanceWriter()
- Specified by:
getInstanceWriter
in interface LearningMethod
closeInstanceWriter
protected void closeInstanceWriter()
throws MaltChainedException
- Throws:
MaltChainedException
getParamString
public String getParamString()
- Returns the parameter string for used for configure Liblinear
- Returns:
- the parameter string for used for configure Liblinear
getOwner
public InstanceModel getOwner()
setOwner
protected void setOwner(InstanceModel owner)
getLearnerMode
public int getLearnerMode()
setLearnerMode
public void setLearnerMode(int learnerMode)
throws MaltChainedException
- Throws:
MaltChainedException
getLearningMethodName
public String getLearningMethodName()
getConfiguration
public DependencyParserConfig getConfiguration()
throws MaltChainedException
- Returns the current configuration
- Returns:
- the current configuration
- Throws:
MaltChainedException
getNumberOfInstances
public int getNumberOfInstances()
increaseNumberOfInstances
public void increaseNumberOfInstances()
- Specified by:
increaseNumberOfInstances
in interface LearningMethod
decreaseNumberOfInstances
public void decreaseNumberOfInstances()
- Specified by:
decreaseNumberOfInstances
in interface LearningMethod
setNumberOfInstances
protected void setNumberOfInstances(int numberOfInstances)
setLearningMethodName
protected void setLearningMethodName(String name)
getInstanceOutputStreamWriter
protected OutputStreamWriter getInstanceOutputStreamWriter(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getInstanceInputStreamReader
protected InputStreamReader getInstanceInputStreamReader(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getFile
protected File getFile(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
readLibLinearProblem
public liblinear.Problem readLibLinearProblem(InputStreamReader isr,
int[] cardinalities)
throws MaltChainedException
- Reads an instance file into a svm_problem object according to the Malt-SVM format, which is column fixed format (tab-separated).
- Parameters:
isr
- the instance stream reader for the instance filecardinalities
- a array containing the number of distinct values for a particular column.
- Throws:
LiblinearException
MaltChainedException
initSpecialParameters
protected void initSpecialParameters()
throws MaltChainedException
- Throws:
MaltChainedException
getLibLinearOptions
public String getLibLinearOptions()
parseParameters
public void parseParameters(String paramstring)
throws MaltChainedException
- Throws:
MaltChainedException
getBias
public double getBias()
throws MaltChainedException
- Throws:
MaltChainedException
getLiblinearParameters
public liblinear.Parameter getLiblinearParameters()
throws MaltChainedException
- Throws:
MaltChainedException
initLiblinearOptions
public void initLiblinearOptions()
getLibLinearParamStringArray
public String[] getLibLinearParamStringArray()
liblinear_predict_with_kbestlist
public void liblinear_predict_with_kbestlist(liblinear.Model model,
liblinear.FeatureNode[] x,
KBestList kBestList)
throws MaltChainedException
- Throws:
MaltChainedException
maltSVMFormat2OriginalSVMFormat
public static void maltSVMFormat2OriginalSVMFormat(InputStreamReader isr,
OutputStreamWriter osw,
int[] cardinalities)
throws MaltChainedException
- Converts the instance file (Malt's own SVM format) into the Liblinear (SVMLight) format. The input instance file is removed (replaced)
by the instance file in the Liblinear (SVMLight) format. If a column contains -1, the value will be removed in destination file.
- Parameters:
isr
- the input stream reader for the source instance fileosw
- the output stream writer for the destination instance filecardinalities
- a vector containing the number of distinct values for a particular column
- Throws:
LiblinearException
MaltChainedException
finalize
protected void finalize()
throws Throwable
- Overrides:
finalize
in class Object
- Throws:
Throwable
toString
public String toString()
- Overrides:
toString
in class Object
Copyright 2007-2009 Johan Hall, Jens Nilsson and Joakim Nivre.