mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 21:42:19 +03:00
port SRILM to new weights format
This commit is contained in:
parent
542cd72c63
commit
41da563645
@ -68,13 +68,11 @@
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.656913512.1104983390" name="PhraseLengthFeatureTest.cpp" rcbsApplicability="disable" resourcePath="PhraseLengthFeatureTest.cpp" toolsToInvoke="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1774992327.160279120">
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1774992327.160279120" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1774992327"/>
|
||||
</fileInfo>
|
||||
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.656913512.1283955357" name="BackwardLMState.h" rcbsApplicability="disable" resourcePath="LM/BackwardLMState.h" toolsToInvoke=""/>
|
||||
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.656913512.1495793082" name="SRI.h" rcbsApplicability="disable" resourcePath="LM/SRI.h" toolsToInvoke=""/>
|
||||
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.656913512.1830045369" name="Backward.h" rcbsApplicability="disable" resourcePath="LM/Backward.h" toolsToInvoke=""/>
|
||||
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.656913512.1283955357" name="BackwardLMState.h" rcbsApplicability="disable" resourcePath="LM/BackwardLMState.h" toolsToInvoke=""/>
|
||||
<sourceEntries>
|
||||
<entry excluding="PhraseLengthFeatureTest.cpp|LM/BackwardTest.cpp|LM/BackwardLMState.h|LM/BackwardLMState.cpp|LM/Backward.h|LM/Backward.cpp|FeatureVectorTest.cpp|LM/ParallelBackoff.h|LM/ParallelBackoff.cpp|LM/SRI.h|LM/SRI.cpp|src/SyntacticLanguageModelState.h|src/SyntacticLanguageModelFiles.h|src/SyntacticLanguageModel.h|src/SyntacticLanguageModel.cpp|src/LM/SRI.h|src/LM/SRI.cpp|src/LM/Rand.h|src/LM/Rand.cpp|src/LM/LDHT.h|src/LM/LDHT.cpp|SyntacticLanguageModelState.h|SyntacticLanguageModelFiles.h|SyntacticLanguageModel.h|SyntacticLanguageModel.cpp|LM/Rand.h|LM/Rand.cpp|LM/LDHT.h|LM/LDHT.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="PhraseLengthFeatureTest.cpp|LM/BackwardTest.cpp|LM/BackwardLMState.h|LM/BackwardLMState.cpp|LM/Backward.h|LM/Backward.cpp|FeatureVectorTest.cpp|LM/ParallelBackoff.h|LM/ParallelBackoff.cpp|src/SyntacticLanguageModelState.h|src/SyntacticLanguageModelFiles.h|src/SyntacticLanguageModel.h|src/SyntacticLanguageModel.cpp|src/LM/SRI.h|src/LM/SRI.cpp|src/LM/Rand.h|src/LM/Rand.cpp|src/LM/LDHT.h|src/LM/LDHT.cpp|SyntacticLanguageModelState.h|SyntacticLanguageModelFiles.h|SyntacticLanguageModel.h|SyntacticLanguageModel.cpp|LM/Rand.h|LM/Rand.cpp|LM/LDHT.h|LM/LDHT.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -43,6 +43,28 @@ LanguageModelSRI::LanguageModelSRI(const std::string &line)
|
||||
,m_srilmVocab(0)
|
||||
,m_srilmModel(0)
|
||||
{
|
||||
FactorType factorType;
|
||||
size_t nGramOrder;
|
||||
string filePath;
|
||||
|
||||
for (size_t i = 0; i < m_args.size(); ++i) {
|
||||
const vector<string> &args = m_args[i];
|
||||
|
||||
if (args[0] == "factor") {
|
||||
factorType = Scan<FactorType>(args[1]);
|
||||
}
|
||||
else if (args[0] == "order") {
|
||||
nGramOrder = Scan<size_t>(args[1]);
|
||||
}
|
||||
else if (args[0] == "path") {
|
||||
filePath = args[1];
|
||||
}
|
||||
else {
|
||||
throw "Unknown argument " + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
Load(filePath, factorType, nGramOrder);
|
||||
}
|
||||
|
||||
LanguageModelSRI::~LanguageModelSRI()
|
||||
|
@ -60,6 +60,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "LM/IRST.h"
|
||||
#endif
|
||||
|
||||
#ifdef LM_SRI
|
||||
#include "LM/SRI.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYNLM
|
||||
#include "SyntacticLanguageModel.h"
|
||||
#endif
|
||||
@ -637,6 +641,13 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
vector<float> weights = m_parameter->GetWeights(model->GetScoreProducerDescription());
|
||||
SetWeights(model, weights);
|
||||
}
|
||||
#endif
|
||||
#ifdef LM_SRI
|
||||
else if (feature == "SRILM") {
|
||||
LanguageModelSRI *model = new LanguageModelSRI(line);
|
||||
vector<float> weights = m_parameter->GetWeights(model->GetScoreProducerDescription());
|
||||
SetWeights(model, weights);
|
||||
}
|
||||
#endif
|
||||
else if (feature == "Generation") {
|
||||
GenerationDictionary *model = new GenerationDictionary(line);
|
||||
|
Loading…
Reference in New Issue
Block a user