mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
beautify
This commit is contained in:
parent
49e36cebc2
commit
9f92642e59
@ -379,9 +379,9 @@ void IOWrapper::OutputBestHypo(const Hypothesis *hypo, long /*translationId*/, c
|
||||
Backtrack(hypo);
|
||||
VERBOSE(3,"0" << std::endl);
|
||||
if (!m_surpressSingleBestOutput) {
|
||||
if (StaticData::Instance().GetOutputHypoScore()) {
|
||||
cout << hypo->GetTotalScore() << " ";
|
||||
}
|
||||
if (StaticData::Instance().GetOutputHypoScore()) {
|
||||
cout << hypo->GetTotalScore() << " ";
|
||||
}
|
||||
|
||||
if (StaticData::Instance().IsPathRecoveryEnabled()) {
|
||||
OutputInput(cout, hypo);
|
||||
|
@ -15,8 +15,8 @@ void ChartTranslationOption::Evaluate(const InputType &input, const InputPath &i
|
||||
const std::vector<FeatureFunction*> &ffs = FeatureFunction::GetFeatureFunctions();
|
||||
|
||||
for (size_t i = 0; i < ffs.size(); ++i) {
|
||||
const FeatureFunction &ff = *ffs[i];
|
||||
ff.Evaluate(input, inputPath, m_scoreBreakdown);
|
||||
const FeatureFunction &ff = *ffs[i];
|
||||
ff.Evaluate(input, inputPath, m_scoreBreakdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ void ChartTranslationOptionList::Evaluate(const InputType &input, const InputPat
|
||||
{
|
||||
CollType::iterator iter;
|
||||
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
|
||||
ChartTranslationOptions &transOpts = **iter;
|
||||
transOpts.Evaluate(input, inputPath);
|
||||
ChartTranslationOptions &transOpts = **iter;
|
||||
transOpts.Evaluate(input, inputPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ void ChartTranslationOptions::Evaluate(const InputType &input, const InputPath &
|
||||
{
|
||||
CollType::iterator iter;
|
||||
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
|
||||
ChartTranslationOption &transOpt = **iter;
|
||||
transOpt.Evaluate(input, inputPath);
|
||||
ChartTranslationOption &transOpt = **iter;
|
||||
transOpt.Evaluate(input, inputPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,29 +12,29 @@ namespace Moses
|
||||
InputFeature::InputFeature(const std::string &line)
|
||||
:StatelessFeatureFunction("InputFeature", line)
|
||||
{
|
||||
ReadParameters();
|
||||
ReadParameters();
|
||||
}
|
||||
|
||||
void InputFeature::SetParameter(const std::string& key, const std::string& value)
|
||||
{
|
||||
if (key == "num-input-features") {
|
||||
m_numInputScores = Scan<size_t>(value);
|
||||
} else if (key == "real-word-count") {
|
||||
m_numRealWordCount = Scan<size_t>(value);
|
||||
} else {
|
||||
StatelessFeatureFunction::SetParameter(key, value);
|
||||
}
|
||||
if (key == "num-input-features") {
|
||||
m_numInputScores = Scan<size_t>(value);
|
||||
} else if (key == "real-word-count") {
|
||||
m_numRealWordCount = Scan<size_t>(value);
|
||||
} else {
|
||||
StatelessFeatureFunction::SetParameter(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void InputFeature::Evaluate(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
, const InputPath &inputPath
|
||||
, ScoreComponentCollection &scoreBreakdown) const
|
||||
{
|
||||
const ScoreComponentCollection *scores = inputPath.GetInputScore();
|
||||
if (scores) {
|
||||
const ScoreComponentCollection *scores = inputPath.GetInputScore();
|
||||
if (scores) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -97,9 +97,8 @@ public:
|
||||
return vertex.BestChild();
|
||||
}
|
||||
|
||||
void Evaluate(const InputType &input, const InputPath &inputPath)
|
||||
{
|
||||
// TODO for input lattice
|
||||
void Evaluate(const InputType &input, const InputPath &inputPath) {
|
||||
// TODO for input lattice
|
||||
}
|
||||
private:
|
||||
lm::WordIndex Convert(const Word &word) const;
|
||||
|
@ -250,7 +250,7 @@ bool Sentence::XmlOverlap(size_t startPos, size_t endPos) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list) const
|
||||
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list) const
|
||||
{
|
||||
for (std::vector<XmlOption*>::const_iterator iterXMLOpts = m_xmlOptions.begin();
|
||||
iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) {
|
||||
|
@ -37,9 +37,9 @@ struct CompareTargetPhrase {
|
||||
TargetPhraseCollection::TargetPhraseCollection(const TargetPhraseCollection ©)
|
||||
{
|
||||
for (const_iterator iter = copy.begin(); iter != copy.end(); ++iter) {
|
||||
const TargetPhrase &origTP = **iter;
|
||||
TargetPhrase *newTP = new TargetPhrase(origTP);
|
||||
Add(newTP);
|
||||
const TargetPhrase &origTP = **iter;
|
||||
TargetPhrase *newTP = new TargetPhrase(origTP);
|
||||
Add(newTP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,34 +43,33 @@ const TargetPhraseCollection *PhraseDictionary::GetTargetPhraseCollection(const
|
||||
{
|
||||
const TargetPhraseCollection *ret;
|
||||
if (m_useCache) {
|
||||
size_t hash = hash_value(src);
|
||||
size_t hash = hash_value(src);
|
||||
|
||||
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
|
||||
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
|
||||
|
||||
{ // scope of read lock
|
||||
#ifdef WITH_THREADS
|
||||
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock);
|
||||
#endif
|
||||
iter = m_cache.find(hash);
|
||||
}
|
||||
{
|
||||
// scope of read lock
|
||||
#ifdef WITH_THREADS
|
||||
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock);
|
||||
#endif
|
||||
iter = m_cache.find(hash);
|
||||
}
|
||||
|
||||
if (iter == m_cache.end()) {
|
||||
ret = GetTargetPhraseCollectionNonCache(src);
|
||||
if (ret) {
|
||||
ret = new TargetPhraseCollection(*ret);
|
||||
}
|
||||
if (iter == m_cache.end()) {
|
||||
ret = GetTargetPhraseCollectionNonCache(src);
|
||||
if (ret) {
|
||||
ret = new TargetPhraseCollection(*ret);
|
||||
}
|
||||
|
||||
#ifdef WITH_THREADS
|
||||
boost::unique_lock<boost::shared_mutex> lock(m_accessLock);
|
||||
#endif
|
||||
m_cache[hash] = ret;
|
||||
}
|
||||
else {
|
||||
ret = iter->second;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = GetTargetPhraseCollectionNonCache(src);
|
||||
#ifdef WITH_THREADS
|
||||
boost::unique_lock<boost::shared_mutex> lock(m_accessLock);
|
||||
#endif
|
||||
m_cache[hash] = ret;
|
||||
} else {
|
||||
ret = iter->second;
|
||||
}
|
||||
} else {
|
||||
ret = GetTargetPhraseCollectionNonCache(src);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -34,11 +34,11 @@ PhraseDictionaryTreeAdaptor(const std::string &line)
|
||||
|
||||
PhraseDictionaryTreeAdaptor::~PhraseDictionaryTreeAdaptor()
|
||||
{
|
||||
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
|
||||
for (iter = m_cache.begin(); iter != m_cache.end(); ++iter) {
|
||||
const TargetPhraseCollection *coll = iter->second;
|
||||
delete coll;
|
||||
}
|
||||
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
|
||||
for (iter = m_cache.begin(); iter != m_cache.end(); ++iter) {
|
||||
const TargetPhraseCollection *coll = iter->second;
|
||||
delete coll;
|
||||
}
|
||||
}
|
||||
|
||||
void PhraseDictionaryTreeAdaptor::Load()
|
||||
|
@ -120,8 +120,9 @@ public:
|
||||
}
|
||||
|
||||
//!List of unknowns (OOVs)
|
||||
const std::vector<const Phrase*>& GetUnknownSources() const
|
||||
{ return m_unksrcs; }
|
||||
const std::vector<const Phrase*>& GetUnknownSources() const {
|
||||
return m_unksrcs;
|
||||
}
|
||||
|
||||
//! get length/size of source input
|
||||
size_t GetSize() const {
|
||||
|
@ -129,11 +129,11 @@ void TranslationOptionCollectionConfusionNet::ProcessUnknownWord(size_t sourcePo
|
||||
InputPathList::const_iterator iterInputPath;
|
||||
size_t j=0;
|
||||
for(iterCol = coll.begin(), iterInputPath = inputPathList.begin();
|
||||
iterCol != coll.end();
|
||||
++iterCol , ++iterInputPath) {
|
||||
const InputPath &inputPath = **iterInputPath;
|
||||
size_t length = source.GetColumnIncrement(sourcePos, j++);
|
||||
const Scores &inputScores = iterCol->second;
|
||||
iterCol != coll.end();
|
||||
++iterCol , ++iterInputPath) {
|
||||
const InputPath &inputPath = **iterInputPath;
|
||||
size_t length = source.GetColumnIncrement(sourcePos, j++);
|
||||
const Scores &inputScores = iterCol->second;
|
||||
ProcessOneUnknownWord(inputPath ,sourcePos, length, &inputScores);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ bool TranslationOptionCollectionText::ViolatesXmlOptionsConstraint(size_t startP
|
||||
}
|
||||
if (match) {
|
||||
return false; // no violation if matching xml option found
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user