|
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.malt04.LibsvmMalt04
public class LibsvmMalt04
Implements an interface to the LIBSVM learner (LIBSVM 2.80 is used). More information about LIBSVM can be found at LIBSVM -- A Library for Support Vector Machines. This class tries to reproduce the same behavior as MaltParser 0.4. Unfortunately we have to introduce some strange behaviors and bugs to able to reproduce the results:
--graph-root_label
option and the --guide-classitem_separator
option (bug in MaltParser 0.4).
--graph-root_label
option and the --guide-classitem_separator
option (bug in MaltParser 0.4).
--libsvm-libsvm_exclude_null
and --libsvm-libsvm_exclude_columns
options in the new MaltParser)
feature != "OutputColumn(DEPREL, Stack[0])"
and it points at a node which has the root as head it will not extract the dependency type of informative root label,
instead it will extract the root label specified by the --graph-root_label
option (bug in MaltParser 0.4).
feature = "Split(InputColumn(FEATS, X), \|")
, where X
is arbitrary node. The set of syntactic and/or morphological features will not be ordered correctly
according to the LIBSVM format (bug in MaltParser 0.4).
feature = "Split(InputColumn(FEATS, X), \|")
, where X
is arbitrary node. It will not regard the set of syntactic and/or morphological features as set. In some cases, there are treebanks that does not follow the
CoNLL data format and have individual syntactic and/or morphological features twice in the FEATS column (bug in MaltParser 0.4).
Field Summary | |
---|---|
protected Integer |
learnerMode
The learner/classifier mode |
static String |
LIBSVM_VERSION
|
protected String |
name
The name of the learner |
protected int |
numberOfInstances
Number of processed instances |
protected InstanceModel |
owner
The parent instance model |
protected String |
pathExternalSVMTrain
|
Fields inherited from interface org.maltparser.ml.LearningMethod |
---|
CLASSIFY, TRAIN |
Constructor Summary | |
---|---|
LibsvmMalt04(InstanceModel owner,
Integer learnerMode)
Constructs a LIBSVM learner. |
Method Summary | |
---|---|
void |
addInstance(ClassTable classCodeTable,
FeatureVector features)
|
static double |
atof(String s)
Returns the double (floating-point) value of the string s |
static int |
atoi(String s)
Returns the integer value of the string s |
protected void |
closeInstanceWriter()
Close the instance writer |
void |
decreaseNumberOfInstances()
|
void |
finalize()
|
void |
finalizeSentence(Sentence sentence,
DependencyGraph dependencyGraph)
|
Configuration |
getConfiguration()
Returns the current configuration |
protected File |
getFile(String suffix)
Returns a file object. |
protected InputStreamReader |
getInstanceInputStreamReader(String suffix)
Returns the instance input reader. |
protected OutputStreamWriter |
getInstanceOutputStreamWriter(String suffix)
Returns the instance output writer. |
BufferedWriter |
getInstanceWriter()
|
Integer |
getLearnerMode()
Returns the learner mode |
String |
getLearningMethodName()
Returns the name of the learning method |
int |
getNumberOfInstances()
Returns the number of processed instances |
InstanceModel |
getOwner()
Returns the parent instance model |
String |
getParamString()
Returns the parameter string for used for configure LIBSVM |
String[] |
getSVMParamStringArray(libsvm28.svm_parameter param)
|
void |
increaseNumberOfInstances()
|
void |
initParameters(libsvm28.svm_parameter param)
Assign a default value to all svm parameters |
protected void |
initSpecialParameters()
Initialize the LIBSVM with a coding and a behavior strategy. |
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,
libsvm28.svm_parameter param)
Parses the parameter string. |
boolean |
predict(FeatureVector features,
KBestList kBestList)
|
void |
readProblemMaltSVMFormat(InputStreamReader isr,
libsvm28.svm_problem prob,
ArrayList<Integer> cardinality,
libsvm28.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). |
static void |
readProblemOriginalSVMFormat(InputStreamReader isr,
libsvm28.svm_problem prob,
libsvm28.svm_parameter param)
Reads an instance file into a svm_problem object according to the LIBSVM (SVMLight) format. |
void |
setLearnerMode(Integer learnerMode)
Sets the learner mode |
protected void |
setLearningMethodName(String name)
Sets the learning method name |
protected void |
setNumberOfInstances(int numberOfInstances)
Sets the number of instance |
protected void |
setOwner(InstanceModel owner)
Sets the parent instance model |
String |
toString()
|
String |
toStringParameters(libsvm28.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 String pathExternalSVMTrain
Constructor Detail |
---|
public LibsvmMalt04(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
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
protected void initSpecialParameters() throws MaltChainedException
MaltChainedException
public String getParamString()
public InstanceModel getOwner()
protected void setOwner(InstanceModel owner)
owner
- a instance modelpublic Integer getLearnerMode()
public void setLearnerMode(Integer learnerMode)
learnerMode
- the learner modepublic 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)
numberOfInstances
- the number of instanceprotected void setLearningMethodName(String name)
name
- the learning method nameprotected OutputStreamWriter getInstanceOutputStreamWriter(String suffix) throws MaltChainedException
suffix
- the file suffix of the file name
MaltChainedException
protected InputStreamReader getInstanceInputStreamReader(String suffix) throws MaltChainedException
suffix
- the file suffix of the file name
MaltChainedException
protected File getFile(String suffix) throws MaltChainedException
suffix
- the file suffix of the file name
MaltChainedException
public void readProblemMaltSVMFormat(InputStreamReader isr, libsvm28.svm_problem prob, ArrayList<Integer> cardinality, libsvm28.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
public void initParameters(libsvm28.svm_parameter param) throws LibsvmException
param
- a svm_parameter object
LibsvmException
public String toStringParameters(libsvm28.svm_parameter param)
param
- a svm_parameter object
public String[] getSVMParamStringArray(libsvm28.svm_parameter param)
public void parseParameters(String paramstring, libsvm28.svm_parameter param) throws LibsvmException
paramstring
- the parameter stringparam
- a svm_parameter object
LibsvmException
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 static double atof(String s) throws LibsvmException
s
- string value that should be converted into a double.
LibsvmException
public static int atoi(String s) throws LibsvmException
s
- string value that should be converted into an integer
LibsvmException
public static void readProblemOriginalSVMFormat(InputStreamReader isr, libsvm28.svm_problem prob, libsvm28.svm_parameter param) throws LibsvmException
isr
- the input stream reader for the source instance fileprob
- a svm_problem objectparam
- a svm_parameter object
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 |