427 template <bool IS_DEBUG_ON>
428 void MRFModel<IS_DEBUG_ON>::ConvertProtoToArray(
429 const google::protobuf::Message* message, std::vector<float>* feature_array, std::string& ori) {
430 feature_array->clear();
431 ori = "";
432 const google::protobuf::Descriptor* descriptor = message->GetDescriptor();
433 const google::protobuf::Reflection* reflection = message->GetReflection();
434
435 for (int i = 0; i < descriptor->field_count(); ++i) {
436 const google::protobuf::FieldDescriptor* field = descriptor->field(i);
437 //bool has_field = reflection->HasField(message, field);
438 if (i == 0) {
439 ori = reflection->GetString(*message, field);
440 }
441 else
442 feature_array->push_back(reflection->GetFloat(*message, field));
443 }
444
428 void MRFModel<IS_DEBUG_ON>::ConvertProtoToArray(
429 const google::protobuf::Message* message, std::vector<float>* feature_array, std::string& ori) {
430 feature_array->clear();
431 ori = "";
432 const google::protobuf::Descriptor* descriptor = message->GetDescriptor();
433 const google::protobuf::Reflection* reflection = message->GetReflection();
434
435 for (int i = 0; i < descriptor->field_count(); ++i) {
436 const google::protobuf::FieldDescriptor* field = descriptor->field(i);
437 //bool has_field = reflection->HasField(message, field);
438 if (i == 0) {
439 ori = reflection->GetString(*message, field);
440 }
441 else
442 feature_array->push_back(reflection->GetFloat(*message, field));
443 }
444
445 }
auto feature_proto = qinstance.unigram_features[i];
ConvertProtoToArray(&feature_proto, &feature_array, ori);