introduced flag for the existence of TtaskSptr in TargetPhrase

This commit is contained in:
Nicola Bertoldi 2015-06-29 09:30:26 +02:00
parent ea23c921b3
commit 6aa6131b84
4 changed files with 29 additions and 15 deletions

View File

@ -78,7 +78,11 @@ void LanguageModel::EvaluateInIsolation(const Phrase &source
float fullScore, nGramScore;
size_t oovCount;
if (targetPhrase.HasTtaskSPtr()){
CalcScoreWithContext(targetPhrase.GetTtask(), targetPhrase, fullScore, nGramScore, oovCount);
}else{
CalcScore(targetPhrase, fullScore, nGramScore, oovCount);
}
//CalcScore(targetPhrase, fullScore, nGramScore, oovCount);
float estimateScore = fullScore - nGramScore;

View File

@ -1115,7 +1115,9 @@ void StaticData::LoadSparseWeightsFromConfig()
}
std::map<std::string, std::vector<float> > weights = m_parameter->GetAllWeights();
for (auto iter = weights.begin(); iter != weights.end(); ++iter) {
std::map<std::string, std::vector<float> >::iterator iter;
// for (auto iter = weights.begin(); iter != weights.end(); ++iter) {
for (iter = weights.begin(); iter != weights.end(); ++iter) {
// this indicates that it is sparse feature
if (featureNames.find(iter->first) == featureNames.end()) {
UTIL_THROW_IF2(iter->second.size() != 1, "ERROR: only one weight per sparse feature allowed: " << iter->first);

View File

@ -48,10 +48,9 @@ TargetPhrase::TargetPhrase( std::string out_string, const PhraseDictionary *pt)
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_ttask_flag(false)
, m_container(pt)
, m_ttask(NULL)
{
//ACAT
const StaticData &staticData = StaticData::Instance();
// XXX should this really be InputFactorOrder???
@ -68,8 +67,9 @@ TargetPhrase::TargetPhrase(ttasksptr& ttask, std::string out_string, const Phras
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_container(pt)
, m_ttask(ttask)
, m_ttask_flag(true)
, m_container(pt)
{
//ACAT
@ -88,8 +88,9 @@ TargetPhrase::TargetPhrase(ttasksptr& ttask, const PhraseDictionary *pt)
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_container(pt)
, m_ttask(ttask)
, m_ttask_flag(true)
, m_container(pt)
{
}
@ -101,8 +102,9 @@ TargetPhrase::TargetPhrase(ttasksptr& ttask, const Phrase &phrase, const PhraseD
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_container(pt)
, m_ttask(ttask)
, m_ttask_flag(true)
, m_container(pt)
{
}
@ -114,8 +116,8 @@ TargetPhrase::TargetPhrase(const PhraseDictionary *pt)
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_ttask_flag(false)
, m_container(pt)
, m_ttask(NULL)
{
}
@ -127,8 +129,8 @@ TargetPhrase::TargetPhrase(const Phrase &phrase, const PhraseDictionary *pt)
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
, m_ruleSource(NULL)
, m_ttask_flag(false)
, m_container(pt)
, m_ttask(NULL)
{
}
@ -141,8 +143,9 @@ TargetPhrase::TargetPhrase(const TargetPhrase &copy)
, m_alignTerm(copy.m_alignTerm)
, m_alignNonTerm(copy.m_alignNonTerm)
, m_properties(copy.m_properties)
, m_container(copy.m_container)
, m_ttask(copy.m_ttask)
, m_ttask_flag(true)
, m_container(copy.m_container)
{
if (copy.m_lhsTarget) {
m_lhsTarget = new Word(*copy.m_lhsTarget);
@ -174,6 +177,10 @@ void TargetPhrase::WriteToRulePB(hgmert::Rule* pb) const
}
#endif
bool TargetPhrase::HasTtaskSPtr() const {
return m_ttask_flag;
}
const ttasksptr& TargetPhrase::GetTtask() const {
return m_ttask;
}

View File

@ -53,16 +53,16 @@ class PhraseDictionary;
class TargetPhrase: public Phrase
{
public:
typedef std::map<FeatureFunction const*, boost::shared_ptr<Scores> >
ScoreCache_t;
typedef std::map<FeatureFunction const*, boost::shared_ptr<Scores> > ScoreCache_t;
ScoreCache_t const& GetExtraScores() const;
Scores const* GetExtraScores(FeatureFunction const* ff) const;
void SetExtraScores(FeatureFunction const* ff,
boost::shared_ptr<Scores> const& scores);
ttasksptr m_ttask;
void SetExtraScores(FeatureFunction const* ff,boost::shared_ptr<Scores> const& scores);
private:
ScoreCache_t m_cached_scores;
ttasksptr m_ttask;
bool m_ttask_flag;
private:
friend std::ostream& operator<<(std::ostream&, const TargetPhrase&);
@ -93,6 +93,7 @@ public:
TargetPhrase(ttasksptr &ttask, std::string out_string, const PhraseDictionary *pt = NULL);
explicit TargetPhrase(ttasksptr &ttask, const Phrase &targetPhrase, const PhraseDictionary *pt);
const ttasksptr& GetTtask() const;
bool HasTtaskSPtr() const;
~TargetPhrase();