mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
delete arg -use-alignment-info
This commit is contained in:
parent
a9c6bf8150
commit
78b3c8763b
@ -79,7 +79,7 @@ public:
|
||||
PhraseTableImplementation implementation,
|
||||
PhraseDictionaryFeature* feature,
|
||||
bool inMemory = StaticData::Instance().UseMinphrInMemory(),
|
||||
bool useAlignmentInfo = StaticData::Instance().UseAlignmentInfo())
|
||||
bool useAlignmentInfo = StaticData::Instance().NeedAlignmentInfo())
|
||||
: PhraseDictionary(numScoreComponent, feature),
|
||||
m_implementation(implementation),
|
||||
m_inMemory(inMemory),
|
||||
|
@ -204,7 +204,7 @@ protected:
|
||||
m_languageModels=&languageModels;
|
||||
|
||||
const StaticData &staticData = StaticData::Instance();
|
||||
m_dict->UseWordAlignment(staticData.UseAlignmentInfo());
|
||||
m_dict->UseWordAlignment(staticData.NeedAlignmentInfo());
|
||||
|
||||
std::string binFname=filePath+".binphr.idx";
|
||||
if(!FileExists(binFname.c_str())) {
|
||||
|
@ -179,7 +179,6 @@ Parameter::Parameter()
|
||||
AddParam("minphr-memory", "Load phrase table in minphr format into memory");
|
||||
|
||||
AddParam("include-segmentation-in-n-best", "include phrasal segmentation in the n-best list. default is false");
|
||||
AddParam("use-alignment-info", "Use word-to-word alignment: actually it is only used to output the word-to-word alignment. Word-to-word alignments are taken from the phrase table if any. Default is false.");
|
||||
AddParam("print-alignment-info-in-n-best", "Include word-to-word alignment in the n-best list. Word-to-word alignments are takne from the phrase table if any. Default is false");
|
||||
AddParam("alignment-output-file", "print output word alignments into given file");
|
||||
AddParam("sort-word-alignment", "Sort word alignments for more consistent display. 0=no sort (default), 1=target order");
|
||||
|
@ -102,7 +102,7 @@ StaticData::StaticData()
|
||||
,m_factorDelimiter("|") // default delimiter between factors
|
||||
,m_lmEnableOOVFeature(false)
|
||||
,m_isAlwaysCreateDirectTranslationOption(false)
|
||||
|
||||
,m_needAlignmentInfo(false)
|
||||
{
|
||||
m_maxFactorIdx[0] = 0; // source side
|
||||
m_maxFactorIdx[1] = 0; // target side
|
||||
@ -172,20 +172,17 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
}
|
||||
|
||||
SetBooleanParameter( &m_continuePartialTranslation, "continue-partial-translation", false );
|
||||
|
||||
//word-to-word alignment
|
||||
SetBooleanParameter( &m_UseAlignmentInfo, "use-alignment-info", false );
|
||||
SetBooleanParameter( &m_PrintAlignmentInfoNbest, "print-alignment-info-in-n-best", false );
|
||||
|
||||
SetBooleanParameter( &m_outputHypoScore, "output-hypo-score", false );
|
||||
|
||||
if (!m_UseAlignmentInfo && m_PrintAlignmentInfoNbest) {
|
||||
TRACE_ERR("--print-alignment-info-in-n-best should only be used together with \"--use-alignment-info true\". Continue forcing to false.\n");
|
||||
m_PrintAlignmentInfoNbest=false;
|
||||
//word-to-word alignment
|
||||
SetBooleanParameter( &m_PrintAlignmentInfoNbest, "print-alignment-info-in-n-best", false );
|
||||
if (m_PrintAlignmentInfoNbest) {
|
||||
m_needAlignmentInfo = true;
|
||||
}
|
||||
|
||||
if (m_parameter->GetParam("alignment-output-file").size() > 0) {
|
||||
m_alignmentOutputFile = Scan<std::string>(m_parameter->GetParam("alignment-output-file")[0]);
|
||||
m_needAlignmentInfo = true;
|
||||
}
|
||||
|
||||
// n-best
|
||||
@ -1793,10 +1790,7 @@ bool StaticData::LoadTargetWordInsertionFeature()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_UseAlignmentInfo && GetSearchAlgorithm() != ChartDecoding) {
|
||||
UserMessage::Add("Target word insertion feature needs word alignments in phrase table.");
|
||||
return false;
|
||||
}
|
||||
m_needAlignmentInfo = true;
|
||||
|
||||
// set factor
|
||||
FactorType factorId = Scan<size_t>(tokens[0]);
|
||||
@ -1832,10 +1826,7 @@ bool StaticData::LoadSourceWordDeletionFeature()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_UseAlignmentInfo && GetSearchAlgorithm() != ChartDecoding) {
|
||||
UserMessage::Add("Source word deletion feature needs word alignments in phrase table.");
|
||||
return false;
|
||||
}
|
||||
m_needAlignmentInfo = true;
|
||||
|
||||
// set factor
|
||||
FactorType factorId = Scan<size_t>(tokens[0]);
|
||||
@ -1856,15 +1847,17 @@ bool StaticData::LoadSourceWordDeletionFeature()
|
||||
|
||||
bool StaticData::LoadWordTranslationFeature()
|
||||
{
|
||||
const vector<string> ¶meters = m_parameter->GetParam("word-translation-feature");
|
||||
if (parameters.empty())
|
||||
return true;
|
||||
|
||||
const vector<float> &weight = Scan<float>(m_parameter->GetParam("weight-wt"));
|
||||
if (weight.size() > 1) {
|
||||
if (weight.size() != 1) {
|
||||
std::cerr << "Only one sparse producer weight allowed for the word translation feature" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const vector<string> ¶meters = m_parameter->GetParam("word-translation-feature");
|
||||
if (parameters.empty())
|
||||
return true;
|
||||
m_needAlignmentInfo = true;
|
||||
|
||||
for (size_t i=0; i<parameters.size(); ++i) {
|
||||
vector<string> tokens = Tokenize(parameters[i]);
|
||||
@ -1874,11 +1867,6 @@ bool StaticData::LoadWordTranslationFeature()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_UseAlignmentInfo && GetSearchAlgorithm() != ChartDecoding) {
|
||||
UserMessage::Add("Word translation feature needs word alignments in phrase table.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// set factor
|
||||
vector <string> factors = Tokenize(tokens[0],"-");
|
||||
FactorType factorIdSource = Scan<size_t>(factors[0]);
|
||||
|
@ -171,7 +171,7 @@ protected:
|
||||
bool m_reportAllFactorsNBest;
|
||||
std::string m_detailedTranslationReportingFilePath;
|
||||
bool m_onlyDistinctNBest;
|
||||
bool m_UseAlignmentInfo;
|
||||
bool m_needAlignmentInfo;
|
||||
bool m_PrintAlignmentInfoNbest;
|
||||
|
||||
std::string m_alignmentOutputFile;
|
||||
@ -431,17 +431,9 @@ public:
|
||||
const std::string &GetDetailedTranslationReportingFilePath() const {
|
||||
return m_detailedTranslationReportingFilePath;
|
||||
}
|
||||
|
||||
const std::string &GetAlignmentOutputFile() const {
|
||||
return m_alignmentOutputFile;
|
||||
}
|
||||
|
||||
bool IsLabeledNBestList() const {
|
||||
return m_labeledNBestList;
|
||||
}
|
||||
bool NBestIncludesSegmentation() const {
|
||||
return m_nBestIncludesSegmentation;
|
||||
}
|
||||
|
||||
bool UseMinphrInMemory() const {
|
||||
return m_minphrMemory;
|
||||
@ -553,16 +545,6 @@ public:
|
||||
//Weights for feature with fixed number of values
|
||||
void SetWeights(const ScoreProducer* sp, const std::vector<float>& weights);
|
||||
|
||||
|
||||
bool UseAlignmentInfo() const {
|
||||
return m_UseAlignmentInfo;
|
||||
}
|
||||
void UseAlignmentInfo(bool a) {
|
||||
m_UseAlignmentInfo=a;
|
||||
};
|
||||
bool PrintAlignmentInfoInNbest() const {
|
||||
return m_PrintAlignmentInfoNbest;
|
||||
}
|
||||
bool GetDistinctNBest() const {
|
||||
return m_onlyDistinctNBest;
|
||||
}
|
||||
@ -725,10 +707,6 @@ public:
|
||||
return m_parameter;
|
||||
}
|
||||
|
||||
WordAlignmentSort GetWordAlignmentSort() const {
|
||||
return m_wordAlignmentSort;
|
||||
}
|
||||
|
||||
int ThreadCount() const {
|
||||
return m_threadCount;
|
||||
}
|
||||
@ -738,6 +716,23 @@ public:
|
||||
|
||||
void SetExecPath(const std::string &path);
|
||||
const std::string &GetBinDirectory() const;
|
||||
|
||||
bool NeedAlignmentInfo() const {
|
||||
return m_needAlignmentInfo; }
|
||||
const std::string &GetAlignmentOutputFile() const {
|
||||
return m_alignmentOutputFile;
|
||||
}
|
||||
bool PrintAlignmentInfoInNbest() const {
|
||||
return m_PrintAlignmentInfoNbest;
|
||||
}
|
||||
WordAlignmentSort GetWordAlignmentSort() const {
|
||||
return m_wordAlignmentSort;
|
||||
}
|
||||
|
||||
bool NBestIncludesSegmentation() const {
|
||||
return m_nBestIncludesSegmentation;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user