diff options
author | Nicola Bertoldi <bertoldi@fbk.eu> | 2014-05-19 17:35:08 +0400 |
---|---|---|
committer | Nicola Bertoldi <bertoldi@fbk.eu> | 2014-05-19 17:35:08 +0400 |
commit | 20b3e8929e93c40e0f1ec61b9268330fe59607f9 (patch) | |
tree | ae6102023df2adfd6bfb287cbc6d89caad5afeac /phrase-extract/InternalStructFeature.cpp | |
parent | 2f3cd5e2fe54f0352eee4657ea91e0039073a95a (diff) |
beautify
Diffstat (limited to 'phrase-extract/InternalStructFeature.cpp')
-rw-r--r-- | phrase-extract/InternalStructFeature.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/phrase-extract/InternalStructFeature.cpp b/phrase-extract/InternalStructFeature.cpp index 3757b0e43..a2369a80c 100644 --- a/phrase-extract/InternalStructFeature.cpp +++ b/phrase-extract/InternalStructFeature.cpp @@ -8,7 +8,8 @@ namespace MosesTraining void InternalStructFeature::add(const ScoreFeatureContext& context, std::vector<float>& denseValues, - std::map<std::string,float>& sparseValues) const { + std::map<std::string,float>& sparseValues) const +{ const std::map<std::string,float> *allTrees = context.phrasePair.GetProperty("Tree"); // our would we rather want to take the most frequent one only? for ( std::map<std::string,float>::const_iterator iter=allTrees->begin(); iter!=allTrees->end(); ++iter ) { @@ -19,24 +20,26 @@ void InternalStructFeature::add(const ScoreFeatureContext& context, void InternalStructFeatureDense::add(const std::string *treeFragment, float count, std::vector<float>& denseValues, - std::map<std::string,float>& sparseValues) const { - //cout<<"Dense: "<<*internalStruct<<endl; - size_t start=0; - int countNP=0; - while((start = treeFragment->find("NP", start)) != string::npos) { - countNP += count; - start+=2; //length of "NP" - } - //should add e^countNP so in the decoder I get log(e^countNP)=countNP -> but is log or ln? - //should use this but don't know what it does? -> maybeLog( (bitmap == i) ? 2.718 : 1 ) - denseValues.push_back(exp(countNP)); + std::map<std::string,float>& sparseValues) const +{ + //cout<<"Dense: "<<*internalStruct<<endl; + size_t start=0; + int countNP=0; + while((start = treeFragment->find("NP", start)) != string::npos) { + countNP += count; + start+=2; //length of "NP" + } + //should add e^countNP so in the decoder I get log(e^countNP)=countNP -> but is log or ln? + //should use this but don't know what it does? -> maybeLog( (bitmap == i) ? 2.718 : 1 ) + denseValues.push_back(exp(countNP)); } void InternalStructFeatureSparse::add(const std::string *treeFragment, float count, std::vector<float>& denseValues, - std::map<std::string,float>& sparseValues) const { + std::map<std::string,float>& sparseValues) const +{ //cout<<"Sparse: "<<*internalStruct<<endl; if(treeFragment->find("VBZ")!=std::string::npos) sparseValues["NTVBZ"] += count; |