org.maltparser.ml.lib
Class Lib
java.lang.Object
org.maltparser.ml.lib.Lib
- All Implemented Interfaces:
- LearningMethod
- Direct Known Subclasses:
- LibLinear, LibSvm
public abstract class Lib
- extends Object
- implements LearningMethod
verbosity
protected Lib.Verbostity verbosity
owner
protected InstanceModel owner
learnerMode
protected int learnerMode
name
protected String name
numberOfInstances
protected int numberOfInstances
saveInstanceFiles
protected boolean saveInstanceFiles
excludeNullValues
protected boolean excludeNullValues
instanceOutput
protected BufferedWriter instanceOutput
featureMap
protected FeatureMap featureMap
paramString
protected String paramString
pathExternalTrain
protected String pathExternalTrain
libOptions
protected LinkedHashMap<String,String> libOptions
allowedLibOptionFlags
protected String allowedLibOptionFlags
configLogger
protected org.apache.log4j.Logger configLogger
model
protected MaltLibModel model
Lib
public Lib(InstanceModel owner,
Integer learnerMode,
String learningMethodName)
throws MaltChainedException
- Constructs a Lib learner.
- Parameters:
owner
- the guide model ownerlearnerMode
- the mode of the learner BATCH 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
moveAllInstances
public void moveAllInstances(LearningMethod method,
FeatureFunction divideFeature,
ArrayList<Integer> divideFeatureIndexVector)
throws MaltChainedException
- Specified by:
moveAllInstances
in interface LearningMethod
- Throws:
MaltChainedException
noMoreInstances
public void noMoreInstances()
throws MaltChainedException
- Specified by:
noMoreInstances
in interface LearningMethod
- Throws:
MaltChainedException
predict
public boolean predict(FeatureVector featureVector,
SingleDecision decision)
throws MaltChainedException
- Specified by:
predict
in interface LearningMethod
- Throws:
MaltChainedException
train
public void train(FeatureVector featureVector)
throws MaltChainedException
- Specified by:
train
in interface LearningMethod
- Throws:
MaltChainedException
trainExternal
protected abstract void trainExternal(FeatureVector featureVector)
throws MaltChainedException
- Throws:
MaltChainedException
trainInternal
protected abstract void trainInternal(FeatureVector featureVector)
throws MaltChainedException
- 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 used for configure the learner
- Returns:
- the parameter string used for configure the learner
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()
throws MaltChainedException
- Throws:
MaltChainedException
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)
getPathExternalTrain
public String getPathExternalTrain()
setPathExternalTrain
public void setPathExternalTrain(String pathExternalTrain)
getInstanceOutputStreamWriter
protected OutputStreamWriter getInstanceOutputStreamWriter(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getInstanceInputStreamReader
protected InputStreamReader getInstanceInputStreamReader(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getInstanceInputStreamReaderFromConfigFile
protected InputStreamReader getInstanceInputStreamReaderFromConfigFile(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getInputStreamFromConfigFileEntry
protected InputStream getInputStreamFromConfigFileEntry(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getFile
protected File getFile(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
getConfigFileEntry
protected JarEntry getConfigFileEntry(String suffix)
throws MaltChainedException
- Throws:
MaltChainedException
initSpecialParameters
protected void initSpecialParameters()
throws MaltChainedException
- Throws:
MaltChainedException
getLibOptions
public String getLibOptions()
getLibParamStringArray
public String[] getLibParamStringArray()
initLibOptions
public abstract void initLibOptions()
initAllowedLibOptionFlags
public abstract void initAllowedLibOptionFlags()
parseParameters
public void parseParameters(String paramstring)
throws MaltChainedException
- Throws:
MaltChainedException
finalize
protected void finalize()
throws Throwable
- Overrides:
finalize
in class Object
- Throws:
Throwable
toString
public String toString()
- Overrides:
toString
in class Object
binariesInstance
protected int binariesInstance(String line,
FeatureList featureList)
throws MaltChainedException
- Throws:
MaltChainedException
binariesInstances2SVMFileFormat
protected void binariesInstances2SVMFileFormat(InputStreamReader isr,
OutputStreamWriter osw)
throws MaltChainedException
- Throws:
MaltChainedException
saveFeatureMap
protected void saveFeatureMap(OutputStream os,
FeatureMap map)
throws MaltChainedException
- Throws:
MaltChainedException
loadFeatureMap
protected FeatureMap loadFeatureMap(InputStream is)
throws MaltChainedException
- Throws:
MaltChainedException
Copyright 2007-2011 Johan Hall, Jens Nilsson and Joakim Nivre.