示例#1
0
//ADEED_BY_TS
bool operator==(const FeatureStats& f1, const FeatureStats& f2) {
  size_t size = f1.size();

  if (size != f2.size())
    return false;

  for (size_t k=0; k < size; k++) {
    if (f1.get(k) != f2.get(k))
      return false;
  }

  return true;
}
示例#2
0
文件: Point.cpp 项目: zhengzi12/moses
double Point::operator*(const FeatureStats& F)const{
  ncall++;//to track performance
  double prod=0.0;
  if(OptimizeAll())
    for (unsigned i=0; i<size(); i++)
      prod+= operator[](i)*F.get(i);
  else{
    for (unsigned i=0; i<size(); i++)
      prod+= operator[](i)*F.get(optindices[i]);
    for(map<unsigned,float >::iterator it=fixedweights.begin();it!=fixedweights.end();it++)
      prod+=it->second*F.get(it->first);
  }
  return prod;
}
示例#3
0
void Data::outputSample( ostream &out, const FeatureStats &f1, const FeatureStats &f2 ) 
{
  // difference in score in regular features
	for(unsigned int j=0; j<f1.size(); j++)
		if (abs(f1.get(j)-f2.get(j)) > 0.00001)
			out << " F" << j << " " << (f1.get(j)-f2.get(j));

  if (!hasSparseFeatures())
    return;

  out << " ";

  // sparse features
  const SparseVector &s1 = f1.getSparse();
  const SparseVector &s2 = f2.getSparse();
  SparseVector diff = s1 - s2;
  diff.write(out);
}