mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-11-10 10:59:21 +03:00
Merge branch 'hieu_opt_input' of github.com:hieuhoang/mosesdecoder into hieu_opt_input
This commit is contained in:
commit
e33f8506f8
@ -295,21 +295,33 @@ GetLexicalWeight(const PhrasePair& pp) const
|
||||
if (s < pp.m_startSource || t < pp.m_startTarget) continue;
|
||||
if ((sx = s - pp.m_startSource) >= src_size) continue;
|
||||
if ((tx = t - pp.m_startTarget) >= trg_size) continue;
|
||||
sp[sx] += m_wrd_cooc.pbwd(sw[s],tw[t]);
|
||||
tp[tx] += m_wrd_cooc.pfwd(sw[s],tw[t]);
|
||||
|
||||
sp[sx] += m_wrd_cooc.pfwd(sw[s],tw[t]);
|
||||
tp[tx] += m_wrd_cooc.pbwd(sw[s],tw[t]);
|
||||
++sc[sx];
|
||||
++tc[tx];
|
||||
#if 0
|
||||
cout << m_srcVocab->GetWord(sw[s]) << " -> "
|
||||
<< m_trgVocab->GetWord(tw[t]) << " "
|
||||
<< m_wrd_cooc.pfwd(sw[s],tw[t]) << " "
|
||||
<< m_wrd_cooc.pbwd(sw[s],tw[t]) << " "
|
||||
<< sp[sx] << " (" << sc[sx] << ") "
|
||||
<< tp[tx] << " (" << tc[tx] << ") "
|
||||
<< endl;
|
||||
#endif
|
||||
}
|
||||
pair<float,float> ret(1,1);
|
||||
wordID_t null_trg = m_trgVocab->GetkOOVWordID();
|
||||
wordID_t null_src = m_srcVocab->GetkOOVWordID();
|
||||
for (size_t i = 0, k = pp.m_startSource; i < sp.size(); ++i, ++k) {
|
||||
size_t soff = pp.m_startSource;
|
||||
for (size_t i = 0; i < sp.size(); ++i) {
|
||||
if (sc[i]) ret.first *= sp[i]/sc[i];
|
||||
else ret.first *= m_wrd_cooc.pbwd(sw[k], null_trg);
|
||||
else ret.first *= m_wrd_cooc.pfwd(sw[soff+i], null_trg);
|
||||
}
|
||||
for (size_t i = 0, k = pp.m_startTarget; i < tp.size(); ++i, ++k) {
|
||||
size_t toff = pp.m_startTarget;
|
||||
for (size_t i = 0; i < tp.size(); ++i) {
|
||||
if (tc[i]) ret.second *= tp[i]/tc[i];
|
||||
else ret.second *= m_wrd_cooc.pfwd(null_src,tw[k]);
|
||||
else ret.second *= m_wrd_cooc.pbwd(null_src,tw[toff+i]);
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
@ -56,6 +56,7 @@ GetTargetPhraseCollection(const Phrase& src) const
|
||||
BOOST_FOREACH(pstat_entry & e, pstats) {
|
||||
TargetPhrase* tp = m_biSA->GetMosesFactorIDs(e.first, src);
|
||||
tp->GetScoreBreakdown().Assign(this,e.second);
|
||||
tp->Evaluate(src);
|
||||
ret->Add(tp);
|
||||
}
|
||||
// return ret;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "moses/TypeDef.h"
|
||||
#include "moses/TranslationModel/PhraseDictionary.h"
|
||||
#include "moses/TranslationModel/BilingualDynSuffixArray.h"
|
||||
|
||||
|
@ -20,6 +20,7 @@ License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
***********************************************************************/
|
||||
|
||||
#include <typeinfo>
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
#include "TranslationOptionCollection.h"
|
||||
|
Loading…
Reference in New Issue
Block a user