mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
daily automatic beautifier
This commit is contained in:
parent
a950605795
commit
739165c2b0
@ -61,7 +61,7 @@ Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
|
|||||||
// unknown word, add as trans opt
|
// unknown word, add as trans opt
|
||||||
const StaticData &staticData = StaticData::Instance();
|
const StaticData &staticData = StaticData::Instance();
|
||||||
const UnknownWordPenaltyProducer &unknownWordPenaltyProducer
|
const UnknownWordPenaltyProducer &unknownWordPenaltyProducer
|
||||||
= UnknownWordPenaltyProducer::Instance();
|
= UnknownWordPenaltyProducer::Instance();
|
||||||
|
|
||||||
size_t isDigit = 0;
|
size_t isDigit = 0;
|
||||||
if (options()->unk.drop) {
|
if (options()->unk.drop) {
|
||||||
@ -102,7 +102,7 @@ Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
|
|||||||
Word *targetLHS = new Word(true);
|
Word *targetLHS = new Word(true);
|
||||||
|
|
||||||
targetLHS->CreateFromString(Output, options()->output.factor_order,
|
targetLHS->CreateFromString(Output, options()->output.factor_order,
|
||||||
targetLHSStr, true);
|
targetLHSStr, true);
|
||||||
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
|
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
|
||||||
|
|
||||||
// add to dictionary
|
// add to dictionary
|
||||||
@ -143,7 +143,7 @@ Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
|
|||||||
|
|
||||||
Word *targetLHS = new Word(true);
|
Word *targetLHS = new Word(true);
|
||||||
targetLHS->CreateFromString(Output, staticData.options().output.factor_order,
|
targetLHS->CreateFromString(Output, staticData.options().output.factor_order,
|
||||||
targetLHSStr, true);
|
targetLHSStr, true);
|
||||||
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
|
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
|
||||||
|
|
||||||
targetPhrase->GetScoreBreakdown().Assign(&unknownWordPenaltyProducer, unknownScore);
|
targetPhrase->GetScoreBreakdown().Assign(&unknownWordPenaltyProducer, unknownScore);
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
const Column& GetColumn(size_t i) const {
|
const Column& GetColumn(size_t i) const {
|
||||||
UTIL_THROW_IF2(i >= data.size(),
|
UTIL_THROW_IF2(i >= data.size(),
|
||||||
"Out of bounds. Trying to access " << i
|
"Out of bounds. Trying to access " << i
|
||||||
<< " when vector only contains " << data.size());
|
<< " when vector only contains " << data.size());
|
||||||
return data[i];
|
return data[i];
|
||||||
}
|
}
|
||||||
const Column& operator[](size_t i) const {
|
const Column& operator[](size_t i) const {
|
||||||
|
@ -570,7 +570,7 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu
|
|||||||
if ( treeInputLabelsLHS.size() == 0 ) {
|
if ( treeInputLabelsLHS.size() == 0 ) {
|
||||||
scoreBreakdown.PlusEquals(this,
|
scoreBreakdown.PlusEquals(this,
|
||||||
"LHSPAIR_" + targetLHS->GetString().as_string() + "_"
|
"LHSPAIR_" + targetLHS->GetString().as_string() + "_"
|
||||||
+ m_output_default_nonterminal[0]->GetString().as_string(),
|
+ m_output_default_nonterminal[0]->GetString().as_string(),
|
||||||
1);
|
1);
|
||||||
if (!m_targetSourceLHSJointCountFile.empty()) {
|
if (!m_targetSourceLHSJointCountFile.empty()) {
|
||||||
t2sLabelsScore = TransformScore(m_floor);
|
t2sLabelsScore = TransformScore(m_floor);
|
||||||
|
@ -74,12 +74,11 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
|
|||||||
// prune only if stack is twice as big as needed (lazy pruning)
|
// prune only if stack is twice as big as needed (lazy pruning)
|
||||||
size_t toleratedSize = 2*m_maxHypoStackSize-1;
|
size_t toleratedSize = 2*m_maxHypoStackSize-1;
|
||||||
// add in room for stack diversity
|
// add in room for stack diversity
|
||||||
if (m_minHypoStackDiversity)
|
if (m_minHypoStackDiversity) {
|
||||||
{
|
// so what happens if maxdistortion is negative?
|
||||||
// so what happens if maxdistortion is negative?
|
toleratedSize += m_minHypoStackDiversity
|
||||||
toleratedSize += m_minHypoStackDiversity
|
<< m_manager.options()->reordering.max_distortion;
|
||||||
<< m_manager.options()->reordering.max_distortion;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_hypos.size() > toleratedSize) {
|
if (m_hypos.size() > toleratedSize) {
|
||||||
PruneToSize(m_maxHypoStackSize);
|
PruneToSize(m_maxHypoStackSize);
|
||||||
|
@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
namespace Moses
|
namespace Moses
|
||||||
{
|
{
|
||||||
|
|
||||||
InputType::InputType(AllOptions::ptr const& opts, long translationId)
|
InputType::InputType(AllOptions::ptr const& opts, long translationId)
|
||||||
: m_options(opts)
|
: m_options(opts)
|
||||||
, m_translationId(translationId)
|
, m_translationId(translationId)
|
||||||
{
|
{
|
||||||
|
@ -191,9 +191,9 @@ public:
|
|||||||
//! populate this InputType with data from in stream
|
//! populate this InputType with data from in stream
|
||||||
virtual int
|
virtual int
|
||||||
Read(std::istream& in) = 0;
|
Read(std::istream& in) = 0;
|
||||||
// ,
|
// ,
|
||||||
// std::vector<FactorType> const& factorOrder,
|
// std::vector<FactorType> const& factorOrder,
|
||||||
// AllOptions const& opts) =0;
|
// AllOptions const& opts) =0;
|
||||||
|
|
||||||
//! Output debugging info to stream out
|
//! Output debugging info to stream out
|
||||||
virtual void Print(std::ostream&) const =0;
|
virtual void Print(std::ostream&) const =0;
|
||||||
|
@ -65,7 +65,7 @@ MockHypothesisGuard
|
|||||||
m_toptions.push_back(new TranslationOption
|
m_toptions.push_back(new TranslationOption
|
||||||
(range,m_targetPhrases.back()));
|
(range,m_targetPhrases.back()));
|
||||||
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap,
|
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap,
|
||||||
m_manager->GetNextHypoId());
|
m_manager->GetNextHypoId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ aux_interpret_xml(std::string& line, std::vector<size_t> & xmlWalls,
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
if (m_options->input.xml_policy != XmlPassThrough) {
|
if (m_options->input.xml_policy != XmlPassThrough) {
|
||||||
bool OK = ProcessAndStripXMLTags(*m_options, line,
|
bool OK = ProcessAndStripXMLTags(*m_options, line,
|
||||||
m_xmlOptions,
|
m_xmlOptions,
|
||||||
m_reorderingConstraint,
|
m_reorderingConstraint,
|
||||||
xmlWalls, placeholders);
|
xmlWalls, placeholders);
|
||||||
UTIL_THROW_IF2(!OK, "Unable to parse XML in line: " << line);
|
UTIL_THROW_IF2(!OK, "Unable to parse XML in line: " << line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace Moses
|
namespace Moses
|
||||||
{
|
{
|
||||||
class AllOptions;
|
class AllOptions;
|
||||||
namespace Syntax
|
namespace Syntax
|
||||||
{
|
{
|
||||||
namespace F2S
|
namespace F2S
|
||||||
|
@ -331,7 +331,7 @@ AddChartLabel(size_t startPos, size_t endPos, const string &label)
|
|||||||
const std::vector<FactorType>& fOrder = m_options->input.factor_order;
|
const std::vector<FactorType>& fOrder = m_options->input.factor_order;
|
||||||
Word word(true);
|
Word word(true);
|
||||||
const Factor *factor
|
const Factor *factor
|
||||||
= FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true);
|
= FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true);
|
||||||
// TODO - no factors
|
// TODO - no factors
|
||||||
word.SetFactor(0, factor);
|
word.SetFactor(0, factor);
|
||||||
AddChartLabel(startPos, endPos, word);
|
AddChartLabel(startPos, endPos, word);
|
||||||
|
@ -33,7 +33,7 @@ std::vector<std::string> TokenizeXml(const std::string& str, const std::string&
|
|||||||
bool ProcessAndStripXMLTags(AllOptions const& opts,
|
bool ProcessAndStripXMLTags(AllOptions const& opts,
|
||||||
std::string &line, std::vector<XmlOption const*> &res,
|
std::string &line, std::vector<XmlOption const*> &res,
|
||||||
ReorderingConstraint &reorderingConstraint,
|
ReorderingConstraint &reorderingConstraint,
|
||||||
std::vector< size_t > &walls,
|
std::vector< size_t > &walls,
|
||||||
std::vector< std::pair<size_t, std::string> > &placeholders);
|
std::vector< std::pair<size_t, std::string> > &placeholders);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1210,7 +1210,8 @@ void collectWordLabelCounts( SentenceAlignmentWithSyntax &sentence )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeUnknownWordLabel(const string & fileName) {
|
void writeUnknownWordLabel(const string & fileName)
|
||||||
|
{
|
||||||
ofstream outFile;
|
ofstream outFile;
|
||||||
outFile.open(fileName.c_str());
|
outFile.open(fileName.c_str());
|
||||||
typedef map<string,int>::const_iterator I;
|
typedef map<string,int>::const_iterator I;
|
||||||
|
Loading…
Reference in New Issue
Block a user