redo property API

This commit is contained in:
Hieu Hoang 2014-06-13 15:34:24 +01:00
parent ae149b0190
commit dea105f663
5 changed files with 9 additions and 11 deletions

View File

@ -56,6 +56,7 @@
<listOptionValue builtIn="false" value="lm"/>
<listOptionValue builtIn="false" value="util"/>
<listOptionValue builtIn="false" value="boost_iostreams-mt"/>
<listOptionValue builtIn="false" value="boost_serialization"/>
<listOptionValue builtIn="false" value="boost_system-mt"/>
<listOptionValue builtIn="false" value="boost_thread-mt"/>
<listOptionValue builtIn="false" value="boost_filesystem-mt"/>

View File

@ -412,10 +412,9 @@ void IOWrapper::OutputTreeFragmentsTranslationOptions(std::ostream &out, Applica
OutputTranslationOption(out, applicationContext, hypo, sentence, translationId);
const TargetPhrase &currTarPhr = hypo->GetCurrTargetPhrase();
boost::shared_ptr<PhraseProperty> property;
out << " ||| ";
if (currTarPhr.GetProperty("Tree", property)) {
if (const PhraseProperty *property = currTarPhr.GetProperty("Tree")) {
out << " " << property->GetValueString();
} else {
out << " " << "noTreeInfo";
@ -439,10 +438,9 @@ void IOWrapper::OutputTreeFragmentsTranslationOptions(std::ostream &out, Applica
OutputTranslationOption(out, applicationContext, applied, sentence, translationId);
const TargetPhrase &currTarPhr = *static_cast<const TargetPhrase*>(applied->GetNote().vp);
boost::shared_ptr<PhraseProperty> property;
out << " ||| ";
if (currTarPhr.GetProperty("Tree", property)) {
if (const PhraseProperty *property = currTarPhr.GetProperty("Tree")) {
out << " " << property->GetValueString();
} else {
out << " " << "noTreeInfo";

View File

@ -271,8 +271,7 @@ FFState* TreeStructureFeature::EvaluateChart(const ChartHypothesis& cur_hypo
, int featureID /* used to index the state in the previous hypotheses */
, ScoreComponentCollection* accumulator) const
{
boost::shared_ptr<PhraseProperty> property;
if (cur_hypo.GetCurrTargetPhrase().GetProperty("Tree", property)) {
if (const PhraseProperty *property = cur_hypo.GetCurrTargetPhrase().GetProperty("Tree")) {
const std::string &tree = property->GetValueString();
TreePointer mytree (new InternalTree(tree));

View File

@ -248,15 +248,15 @@ void TargetPhrase::SetProperty(const std::string &key, const std::string &value)
m_properties[key] = phrasePropertyFactory.ProduceProperty(key,value);
}
bool TargetPhrase::GetProperty(const std::string &key, boost::shared_ptr<PhraseProperty> &value) const
const PhraseProperty *TargetPhrase::GetProperty(const std::string &key) const
{
std::map<std::string, boost::shared_ptr<PhraseProperty> >::const_iterator iter;
iter = m_properties.find(key);
if (iter != m_properties.end()) {
value = iter->second;
return true;
const boost::shared_ptr<PhraseProperty> &value = iter->second;
return value.get();
}
return false;
return NULL;
}
void TargetPhrase::SetRuleSource(const Phrase &ruleSource) const

View File

@ -137,7 +137,7 @@ public:
void SetProperties(const StringPiece &str);
void SetProperty(const std::string &key, const std::string &value);
bool GetProperty(const std::string &key, boost::shared_ptr<PhraseProperty> &value) const;
const PhraseProperty *GetProperty(const std::string &key) const;
void Merge(const TargetPhrase &copy, const std::vector<FactorType>& factorVec);