|
MaltParser 1.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.maltparser.ml.libsvm.Libsvm
public class Libsvm
Implements an interface to the LIBSVM learner (currently the LIBSVM 2.84 is used). More information about LIBSVM can be found at LIBSVM -- A Library for Support Vector Machines.
Field Summary | |
---|---|
protected boolean |
excludeNullValues
|
protected Integer |
learnerMode
|
static String |
LIBSVM_VERSION
|
protected String |
name
|
protected int |
numberOfInstances
|
protected InstanceModel |
owner
|
protected String |
pathExternalSVMTrain
|
protected boolean |
saveInstanceFiles
|
Fields inherited from interface org.maltparser.ml.LearningMethod |
---|
CLASSIFY, TRAIN |
Constructor Summary | |
---|---|
Libsvm(InstanceModel owner,
Integer learnerMode)
Constructs a LIBSVM learner. |
Method Summary | |
---|---|
void |
addInstance(ClassTable classCodeTable,
FeatureVector features)
|
protected void |
addInstanceExcludeNull(ClassTable classCodeTable,
FeatureVector features)
|
protected void |
closeInstanceWriter()
|
void |
decreaseNumberOfInstances()
|
void |
finalize()
|
void |
finalizeSentence(Sentence sentence,
DependencyGraph dependencyGraph)
|
Configuration |
getConfiguration()
Returns the current configuration |
protected File |
getFile(String suffix)
|
protected InputStreamReader |
getInstanceInputStreamReader(String suffix)
|
protected OutputStreamWriter |
getInstanceOutputStreamWriter(String suffix)
|
BufferedWriter |
getInstanceWriter()
|
Integer |
getLearnerMode()
|
String |
getLearningMethodName()
|
int |
getNumberOfInstances()
|
InstanceModel |
getOwner()
|
String |
getParamString()
Returns the parameter string for used for configure LIBSVM |
String[] |
getSVMParamStringArray(libsvm.svm_parameter param)
|
void |
increaseNumberOfInstances()
|
protected void |
initParameters(libsvm.svm_parameter param)
Assign a default value to all svm parameters |
protected void |
initSpecialParameters()
|
protected void |
initSvmParam(String paramString)
Initialize the LIBSVM according to the parameter string |
static void |
maltSVMFormat2OriginalSVMFormat(InputStreamReader isr,
OutputStreamWriter osw,
ArrayList<Integer> cardinality)
Converts the instance file (Malt's own SVM format) into the LIBSVM (SVMLight) format. |
void |
moveAllInstances(LearningMethod method,
Feature divideFeature,
ArrayList<Integer> divideFeatureIndexVector)
|
void |
noMoreInstances()
|
void |
parseParameters(String paramstring,
libsvm.svm_parameter param)
Parses the parameter string. |
boolean |
predict(FeatureVector features,
KBestList kBestList)
|
void |
readProblemMaltSVMFormat(InputStreamReader isr,
libsvm.svm_problem prob,
ArrayList<Integer> cardinality,
libsvm.svm_parameter param)
Reads an instance file into a svm_problem object according to the Malt-SVM format, which is column fixed format (tab-separated). |
void |
setLearnerMode(Integer learnerMode)
|
protected void |
setLearningMethodName(String name)
|
protected void |
setNumberOfInstances(int numberOfInstances)
|
protected void |
setOwner(InstanceModel owner)
|
void |
svm_predict_with_kbestlist(libsvm.svm_model model,
libsvm.svm_node[] x,
KBestList kBestList)
|
String |
toString()
|
String |
toStringParameters(libsvm.svm_parameter param)
Returns a string containing all svm-parameters of interest |
void |
train(FeatureVector features)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String LIBSVM_VERSION
protected InstanceModel owner
protected Integer learnerMode
protected String name
protected int numberOfInstances
protected boolean saveInstanceFiles
protected boolean excludeNullValues
protected String pathExternalSVMTrain
Constructor Detail |
---|
public Libsvm(InstanceModel owner, Integer learnerMode) throws MaltChainedException
owner
- the guide model ownerlearnerMode
- the mode of the learner TRAIN or CLASSIFY
MaltChainedException
Method Detail |
---|
public void addInstance(ClassTable classCodeTable, FeatureVector features) throws MaltChainedException
addInstance
in interface LearningMethod
MaltChainedException
protected void addInstanceExcludeNull(ClassTable classCodeTable, FeatureVector features) throws MaltChainedException
MaltChainedException
public void finalizeSentence(Sentence sentence, DependencyGraph dependencyGraph) throws MaltChainedException
finalizeSentence
in interface LearningMethod
MaltChainedException
public void noMoreInstances() throws MaltChainedException
noMoreInstances
in interface LearningMethod
MaltChainedException
public void train(FeatureVector features) throws MaltChainedException
train
in interface LearningMethod
MaltChainedException
public void moveAllInstances(LearningMethod method, Feature divideFeature, ArrayList<Integer> divideFeatureIndexVector) throws MaltChainedException
moveAllInstances
in interface LearningMethod
MaltChainedException
public boolean predict(FeatureVector features, KBestList kBestList) throws MaltChainedException
predict
in interface LearningMethod
MaltChainedException
public void finalize() throws MaltChainedException
finalize
in interface LearningMethod
finalize
in class Object
MaltChainedException
public BufferedWriter getInstanceWriter()
getInstanceWriter
in interface LearningMethod
protected void closeInstanceWriter() throws MaltChainedException
MaltChainedException
protected void initSvmParam(String paramString) throws MaltChainedException
paramString
- the parameter string to configure the LIBSVM learner.
MaltChainedException
public String getParamString()
public InstanceModel getOwner()
protected void setOwner(InstanceModel owner)
public Integer getLearnerMode()
public void setLearnerMode(Integer learnerMode)
public String getLearningMethodName()
public Configuration getConfiguration() throws MaltChainedException
MaltChainedException
public int getNumberOfInstances()
public void increaseNumberOfInstances()
increaseNumberOfInstances
in interface LearningMethod
public void decreaseNumberOfInstances()
decreaseNumberOfInstances
in interface LearningMethod
protected void setNumberOfInstances(int numberOfInstances)
protected void setLearningMethodName(String name)
protected OutputStreamWriter getInstanceOutputStreamWriter(String suffix) throws MaltChainedException
MaltChainedException
protected InputStreamReader getInstanceInputStreamReader(String suffix) throws MaltChainedException
MaltChainedException
protected File getFile(String suffix) throws MaltChainedException
MaltChainedException
public void readProblemMaltSVMFormat(InputStreamReader isr, libsvm.svm_problem prob, ArrayList<Integer> cardinality, libsvm.svm_parameter param) throws LibsvmException
isr
- the instance stream reader for the instance fileprob
- a svm_problem objectcardinality
- a vector containing the number of distinct values for a particular column.param
- a svm_parameter object
LibsvmException
protected void initSpecialParameters() throws MaltChainedException
MaltChainedException
protected void initParameters(libsvm.svm_parameter param) throws LibsvmException
param
- a svm_parameter object
LibsvmException
public String toStringParameters(libsvm.svm_parameter param)
param
- a svm_parameter object
public String[] getSVMParamStringArray(libsvm.svm_parameter param)
public void parseParameters(String paramstring, libsvm.svm_parameter param) throws LibsvmException
paramstring
- the parameter stringparam
- a svm_parameter object
LibsvmException
public void svm_predict_with_kbestlist(libsvm.svm_model model, libsvm.svm_node[] x, KBestList kBestList)
public static void maltSVMFormat2OriginalSVMFormat(InputStreamReader isr, OutputStreamWriter osw, ArrayList<Integer> cardinality) throws LibsvmException
isr
- the input stream reader for the source instance fileosw
- the output stream writer for the destination instance filecardinality
- a vector containing the number of distinct values for a particular column
LibsvmException
public String toString()
toString
in class Object
|
MaltParser 1.0.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |