用于注释掉代码检测的库
commented-out-code的Python项目详细描述
注释掉代码
此库可以检测内联或块注释掉的代码。
它将rpc发送到服务器,服务器使用lstm模型来预测注释掉的代码。 服务器运行在我的学校数据中心上,并将迁移到一台专用计算机上。
现在只支持C/C++。将提供更多的语言支持
如何使用
示例代码
text = '''
void DropoutLayer::updateB(){
int num = this->numUnit;
//cout<<"Error!!!!!!!!!!!!!!!!in DropoutLayer!!!!!!!"<<endl;
if (this->z == NULL){ // embeddings
// gradB += dE_dy, because y = b
iXpY( num , this->dE_dy, gradBiases + bidx );
return;
}
if (fprime != dummy){
// dy_dz = f', evaluated at y
( * this->fprime)(this->y, this->dy_dz, num);
// dE_dz = dE_dy .* dy_dz
pointwise_dot(this->dE_dy, this->dy_dz, this->dE_dz, num);
//cout<<"dropout backward"<<endl;
for( int i = 0; i < num; ++i){
this->dE_dz[i] *= this->indicator[i];
}
}// else if fprime == softmaxprime{
// do nothing, because we assume dE_dz is given by softmax
//}
// ReLUPrime(float * y, float * dy_dz, int n);
}
'''
print(client.search(text, 'cpp')) # return OrderedDict object, key is line_number, value is the commented code itself
# output
# OrderedDict([(4, 'cout<<"Error!!!!!!!!!!!!!!!!in DropoutLayer!!!!!!!"<<endl;'),
# (19, 'cout<<"dropout backward"<<endl;'),
# (26, 'else if fprime == softmaxprime{'),
# (29, '}'),
# (31, 'ReLUPrime(float * y, float * dy_dz, int n);')])