<commit_before>#include "tag-database.h"
#include <QFile>


TagDatabase::TagDatabase(QString typeFile, QString tagFile)
	: m_typeFile(typeFile), m_tagFile(tagFile)
{}

bool TagDatabase::load()
{
	QMap<int, TagType> types = loadTypes(m_typeFile);

	QFile file(m_tagFile);
	if (!file.open(QFile::ReadOnly | QFile::Text))
		return false;

	QTextStream in(&file);
	while (!in.atEnd()) {
		QString line = in.readLine();

		QStringList data = line.split(',');
		if (data.count() != 2)
			continue;

		int tId = data[1].toInt();
		if (!types.contains(tId))
			continue;

		m_database.insert(data[0], types[tId]);
	}
	file.close();

	return true;<commit_msg>Don't reload already lodaded TagDatabases<commit_after>#include "tag-database.h"
#include <QFile>


TagDatabase::TagDatabase(QString typeFile, QString tagFile)
	: m_typeFile(typeFile), m_tagFile(tagFile)
{}

bool TagDatabase::load()
{
	// Don't reload databases
	if (!m_database.isEmpty())
		return true;

	QMap<int, TagType> types = loadTypes(m_typeFile);

	QFile file(m_tagFile);
	if (!file.open(QFile::ReadOnly | QFile::Text))
		return false;

	QTextStream in(&file);
	while (!in.atEnd()) {
		QString line = in.readLine();

		QStringList data = line.split(',');
		if (data.count() != 2)
			continue;

		int tId = data[1].toInt();
		if (!types.contains(tId))
			continue;

		m_database.insert(data[0], types[tId]);
	}
	file.close();

	return true;
{'fraction_non_alphanumeric': 0.1679771265189421, 'fraction_numerical': 0.004288777698355968, 'mean_word_length': 4.957446808510638, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6175052', 'n_tokens_mistral': 562, 'n_tokens_neox': 517, 'n_words': 106}