<commit_before>#include <ros/ros.h>
#include <qbot/SpcCmd.h>
#include <qbot/SpcNLP.h>
#include <qbot/NLPRes.h>

#include <iostream>  //declaring variables
#include <string>
#include <fstream>
#include <vector>

const int bufferSize = 1000;
uint8_t sys_state = 0;
std::string question = "";

class NLP_Node{
private:
	ros::Publisher nlpPub_; // NLP to CNC - NLPRes.msg
	ros::Subscriber cncSub_; // CNC to SPC - SpcCmd.msg
	ros::Subscriber spcSub_; // SPC to NLP - SpcNLP.msg
	
public:
	NLP_Node(ros::NodeHandle& n){
		nlpPub_ = n.advertise<qbot::NLPRes>("/NLP_2_CNC", bufferSize);
		cncSub_ = n.subscribe("/CNC_2_SPC", bufferSize, &NLP_Node::cncCallback, this);
		spcSub_ = n.subscribe("/SPC_2_NLP", bufferSize, &NLP_Node::spcCallback, this);
	}
	
	std::string getAnswer(std::string response){
		return "6";
	}
	
	// CNC messaged SPC
	void cncCallback(const qbot::SpcCmd& spccmd){
		// Capture system state and current question
		sys_state = spccmd.sys_state;
		question = spccmd.question;
		ROS_INFO("NLP received from CNC:\n state: %d \n qustion: %s\n", sys_state, question.c_str());
	}
	
	// SPC messaged NLP
	void spcCallback(const qbot::SpcNLP& spcnlp){
		qbot::NLPRes nlpres; // Init response to CNC
		
		ROS_INFO("NLP received response from SPC: %s\n", spcnlp.response.c_str());
		// If response is empty, return an error
		if(spcnlp.response.empty())
		{
			nlpres.res_type = 1;
		}
		else
		{
			// Try to match response to a request for a break
			if(spcnlp.response.find("break") != std::string::npos)
			{
				nlpres.res_type = 3;
			}
			// Try to match response to a request for a nurse
			else if(spcnlp.response.find("nurse") != std::string::npos)
			{
				nlpres.res_type = 4;
			}
			// If expecting a response
			else if(sys_state == 21)
			{
				// Get formatted answer
				nlpres.response = getAnswer(spcnlp.response);
				
				// If couldn't get an answer, request to ask again
				if(nlpres.response.empty())
				{
					nlpres.res_type = 1;
				}
				else
				{
					nlpres.res_type = 0;
				}
			}
		}
		<commit_msg>NLP: Invoke error code 2.<commit_after>#include <ros/ros.h>
#include <qbot/SpcCmd.h>
#include <qbot/SpcNLP.h>
#include <qbot/NLPRes.h>

#include <iostream>  //declaring variables
#include <string>
#include <fstream>
#include <vector>

const int bufferSize = 1000;
uint8_t sys_state = 0;
std::string question = "";

class NLP_Node{
private:
	ros::Publisher nlpPub_; // NLP to CNC - NLPRes.msg
	ros::Subscriber cncSub_; // CNC to SPC - SpcCmd.msg
	ros::Subscriber spcSub_; // SPC to NLP - SpcNLP.msg
	
public:
	NLP_Node(ros::NodeHandle& n){
		nlpPub_ = n.advertise<qbot::NLPRes>("/NLP_2_CNC", bufferSize);
		cncSub_ = n.subscribe("/CNC_2_SPC", bufferSize, &NLP_Node::cncCallback, this);
		spcSub_ = n.subscribe("/SPC_2_NLP", bufferSize, &NLP_Node::spcCallback, this);
	}
	
	std::string getAnswer(std::string response){
		return "6";
	}
	
	// CNC messaged SPC
	void cncCallback(const qbot::SpcCmd& spccmd){
		// Capture system state and current question
		sys_state = spccmd.sys_state;
		question = spccmd.question;
		ROS_INFO("NLP received from CNC:\n state: %d \n qustion: %s\n", sys_state, question.c_str());
	}
	
	// SPC messaged NLP
	void spcCallback(const qbot::SpcNLP& spcnlp){
		qbot::NLPRes nlpres; // Init response to CNC
		
		ROS_INFO("NLP received response from SPC: %s\n", spcnlp.response.c_str());
		// If response is empty, return an error
		if(spcnlp.response.empty() && sys_state != 21)
		{
			nlpres.res_type = 2;
		}
		else
		{
			// Try to match response to a request for a break
			if(spcnlp.response.find("break") != std::string::npos)
			{
				nlpres.res_type = 3;
			}
			// Try to match response to a request for a nurse
			else if(spcnlp.response.find("nurse") != std::string::npos)
			{
				nlpres.res_type = 4;
			}
			// If expecting a response
			else if(sys_state == 21)
			{
				// Get formatted answer
				nlpres.response = getAnswer(spcnlp.response);
				
				// If couldn't get an answer, request to ask again
				if(nlpres.response.empty())
				{
					nlpres.res_type = 1;
				}
				else
				{
					nlpres.res_type = 0;
				}
			}
		}
		
{'fraction_non_alphanumeric': 0.14018009247992214, 'fraction_numerical': 0.009004623996106109, 'mean_word_length': 3.3446088794926006, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2819215', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1589, 'n_words': 374}