diff options
author | nicolabertoldi <nicolabertoldi@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-27 20:50:52 +0400 |
---|---|---|
committer | nicolabertoldi <nicolabertoldi@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-27 20:50:52 +0400 |
commit | 291260abf74ed3fe0c9218465cff6e658d0a1b23 (patch) | |
tree | 474b29cf0ba2b37c5ed41b4c805a85121362a3a7 /mert/Point.cpp | |
parent | 89194be5ebb641072795d9e949312002ac6262e6 (diff) |
- made output more compliant with old version
- added PerSCorer.h and BleuScorer.h
- stored feature names
- fixed bug about output of best Point
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1796 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Point.cpp')
-rw-r--r-- | mert/Point.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mert/Point.cpp b/mert/Point.cpp index af9316679..25a0a3529 100644 --- a/mert/Point.cpp +++ b/mert/Point.cpp @@ -20,17 +20,28 @@ void Point::Randomize(const vector<parameter_t>& min,const vector<parameter_t>& operator[](i)= min[i] + (float)random()/(float)RAND_MAX * (float)(max[i]-min[i]); } -void Point::Normalize(){ +void Point::NormalizeL2(){ parameter_t norm=0.0; for (unsigned int i=0; i<size(); i++) norm+= operator[](i)*operator[](i); - if(norm!=0.0){ + if(norm!=0.0){ norm=sqrt(norm); for (unsigned int i=0; i<size(); i++) operator[](i)/=norm; } } + +void Point::NormalizeL1(){ + parameter_t norm=0.0; + for (unsigned int i=0; i<size(); i++) + norm+= abs(operator[](i)); + if(norm!=0.0){ + for (unsigned int i=0; i<size(); i++) + operator[](i)/=norm; + } +} + //Can initialize from a vector of dim or pdim Point::Point(const vector<parameter_t>& init):vector<parameter_t>(Point::dim){ if(init.size()==dim){ |