mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
inverse file
This commit is contained in:
parent
2984573f28
commit
a8bebb7659
@ -39,6 +39,7 @@ int main(int argc, char** argv)
|
||||
Moses::InputFileStream strmSource(pathSource);
|
||||
Moses::InputFileStream strmAlignment(pathAlignment);
|
||||
Moses::OutputFileStream m_extractFile(pathExtract);
|
||||
Moses::OutputFileStream m_extractInvFile(pathExtract + ".inv");
|
||||
|
||||
|
||||
// MAIN LOOP
|
||||
@ -69,7 +70,8 @@ int main(int argc, char** argv)
|
||||
rules.Consolidate(params);
|
||||
//cerr << rules.Debug();
|
||||
|
||||
rules.Output(m_extractFile);
|
||||
rules.Output(m_extractFile, true);
|
||||
rules.Output(m_extractInvFile, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,25 +121,30 @@ std::string Rule::Debug() const
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Rule::Output(std::ostream &out) const
|
||||
void Rule::Output(std::ostream &out, bool forward) const
|
||||
{
|
||||
// source
|
||||
for (size_t i = 0; i < m_source.GetSize(); ++i) {
|
||||
const RuleSymbol &symbol = *m_source[i];
|
||||
symbol.Output(out);
|
||||
out << " ";
|
||||
}
|
||||
m_lhs.Output(out, Moses::Input);
|
||||
if (forward) {
|
||||
// source
|
||||
m_source.Output(out);
|
||||
m_lhs.Output(out, Moses::Input);
|
||||
|
||||
out << " ||| ";
|
||||
out << " ||| ";
|
||||
|
||||
// target
|
||||
for (size_t i = 0; i < m_target.GetSize(); ++i) {
|
||||
const RuleSymbol &symbol = *m_target[i];
|
||||
symbol.Output(out);
|
||||
out << " ";
|
||||
// target
|
||||
m_target.Output(out);
|
||||
m_lhs.Output(out, Moses::Output);
|
||||
}
|
||||
else {
|
||||
// target
|
||||
m_target.Output(out);
|
||||
m_lhs.Output(out, Moses::Output);
|
||||
|
||||
out << " ||| ";
|
||||
|
||||
// source
|
||||
m_source.Output(out);
|
||||
m_lhs.Output(out, Moses::Input);
|
||||
}
|
||||
m_lhs.Output(out, Moses::Output);
|
||||
|
||||
out << " ||| ";
|
||||
|
||||
@ -147,7 +152,13 @@ void Rule::Output(std::ostream &out) const
|
||||
Alignments::const_iterator iterAlign;
|
||||
for (iterAlign = m_alignments.begin(); iterAlign != m_alignments.end(); ++iterAlign) {
|
||||
const std::pair<int,int> &alignPair = *iterAlign;
|
||||
out << alignPair.first << "-" << alignPair.second << " ";
|
||||
|
||||
if (forward) {
|
||||
out << alignPair.first << "-" << alignPair.second << " ";
|
||||
}
|
||||
else {
|
||||
out << alignPair.second << "-" << alignPair.first << " ";
|
||||
}
|
||||
}
|
||||
|
||||
out << "||| ";
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
{ return m_alignments; }
|
||||
|
||||
std::string Debug() const;
|
||||
void Output(std::ostream &out) const;
|
||||
void Output(std::ostream &out, bool forward) const;
|
||||
|
||||
void Prevalidate(const Parameter ¶ms);
|
||||
void CreateTarget(const Parameter ¶ms);
|
||||
|
@ -30,3 +30,12 @@ int RulePhrase::Compare(const RulePhrase &other) const
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RulePhrase::Output(std::ostream &out) const
|
||||
{
|
||||
for (size_t i = 0; i < m_coll.size(); ++i) {
|
||||
const RuleSymbol &symbol = *m_coll[i];
|
||||
symbol.Output(out);
|
||||
out << " ";
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
class RuleSymbol;
|
||||
|
||||
@ -33,6 +34,7 @@ public:
|
||||
|
||||
int Compare(const RulePhrase &other) const;
|
||||
|
||||
void Output(std::ostream &out) const;
|
||||
};
|
||||
|
||||
#endif /* RULEPHRASE_H_ */
|
||||
|
@ -138,12 +138,12 @@ std::string Rules::Debug() const
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Rules::Output(std::ostream &out) const
|
||||
void Rules::Output(std::ostream &out, bool forward) const
|
||||
{
|
||||
std::set<Rule*, CompareRules>::const_iterator iter;
|
||||
for (iter = m_mergeRules.begin(); iter != m_mergeRules.end(); ++iter) {
|
||||
const Rule &rule = **iter;
|
||||
rule.Output(out);
|
||||
rule.Output(out, forward);
|
||||
out << endl;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
void Consolidate(const Parameter ¶ms);
|
||||
|
||||
std::string Debug() const;
|
||||
void Output(std::ostream &out) const;
|
||||
void Output(std::ostream &out, bool forward) const;
|
||||
|
||||
protected:
|
||||
const AlignedSentence &m_alignedSentence;
|
||||
|
Loading…
Reference in New Issue
Block a user