<commit_before>#include "symtab.h"
#include "util.h"
#include <map>

using namespace std;

map<string,string> symtab;
map<string,string> revsymtab;
int label_count = 0;

bool add_to_symtab(std::string symbol, std::string value) {
	if ( symtab.count(symbol) )
		return false;
	symtab[symbol] = value;
	revsymtab[value] = symbol;
	return true;
}

bool read_from_symtab(std::string symbol, std::string &value) {
	if ( !symtab.count(symbol) )
		return false;
	value = symtab[symbol];
	return true;
}

bool find_from_symtab(std::string &symbol, std::string value) {
	if ( !revsymtab.count(value) )
		return false;
	symbol = revsymtab[value];
	return true;
}

bool give_label(std::string &label, std::string location) {
	if ( find_from_symtab(label,location) )
		return true;
	label = "label" + int2str(label_count++);
	add_to_symtab(label,location);
	return false;
}

bool give_label(std::string location) {
	string temp;
	return give_label(temp,location);
}

void initialize_symtab() {
	symtab.clear();
	revsymtab.clear();
	label_count = 0;
}

bool are_same_in_symtab(std::string symbol, std::string value) {
	string temp;
	if ( !read_from_symtab(symbol,temp) ) {
		return false;
	}
	return (value==temp);
}<commit_msg>Clean up symtab.cpp<commit_after>#include "symtab.h"
#include "util.h"
#include <map>

using namespace std;

map<string,string> symtab;
map<string,string> revsymtab;
int label_count = 0;

bool add_to_symtab(std::string symbol, std::string value) {
	if ( symtab.count(symbol) )
		return false;
	symtab[symbol] = value;
	revsymtab[value] = symbol;
	return true;
}

bool find_from_symtab(std::string &symbol, std::string value) {
	if ( !revsymtab.count(value) )
		return false;
	symbol = revsymtab[value];
	return true;
}

bool give_label(std::string location) {
	string label;
	if ( find_from_symtab(label,location) )
		return true;
	label = "label" + int2str(label_count++);
	add_to_symtab(label,location);
	return false;
}

void initialize_symtab() {
	symtab.clear();
	revsymtab.clear();
	label_count = 0;
}
{'fraction_non_alphanumeric': 0.14094955489614244, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 5.698675496688741, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '556124', 'n_tokens_mistral': 770, 'n_tokens_neox': 768, 'n_words': 165}