<commit_before>#include <iostream>
#include <string>
#include <time.h>

#include <opencv2/opencv.hpp>

void nms(
	const std::vector<cv::Rect>& srcRects,
	std::vector<cv::Rect>& resRects,
	float thresh
	)
{
	resRects.clear();

	const size_t size = srcRects.size();

    // If there are no boxes, return an empty list
	if (!size)
	{
		return;
	}

	// Grab the coordinates of the bounding boxes
	std::vector<int> x1(size);
	std::vector<int> y1(size);
	std::vector<int> x2(size);
	std::vector<int> y2(size);
	std::vector<float> area(size);
	std::multimap<int, size_t> idxs; // Sort the bounding boxes by the bottom - right y - coordinate of the bounding box

	for (size_t i = 0; i < size; ++i)
	{
		const cv::Rect& r = srcRects[i];

		x1[i] = r.x;
		y1[i] = r.y;
		x2[i] = r.x + r.width;
		y2[i] = r.y + r.height;
		area[i] = static_cast<float>(r.width * r.height);
		idxs.insert(std::pair<int, size_t>(y2[i], i));
	}
	
	// keep looping while some indexes still remain in the indexes list
	while (idxs.size() > 0)
	{
		// grab the last index in the indexes list, add the index value to the list of picked indexes, then initialize the suppression list(i.e.indexes that will be deleted) using the last index
		auto lastElem = --std::end(idxs);
		const size_t i = lastElem->second;

		resRects.push_back(srcRects[i]);

		idxs.erase(lastElem);

		// loop over all indexes in the indexes list
		for (auto pos = std::begin(idxs); pos != std::end(idxs); )
		{
			// grab the current index
			const size_t j = pos->second;
			
			// find the largest(x, y) coordinates for the start of the bounding box and the smallest(x, y) coordinates for the end of the bounding box
			int xx1 = std::max(x1[i], x1[j]);
			int yy1 = std::max(y1[i], y1[j]);
			int xx2 = std::min(x2[i], x2[j]);
			int yy2 = std::min(y2[i], y2[j]);
			
			// compute the width and height of the bounding box
			int w = std::max(0, xx2 - xx1 + 1);
			int h = std::max(0, yy2 - yy1 + 1);

			// compute the ratio of overlap between the computed bounding box and the bounding box in the area list
			float overlap = (w * h) / area[j];

			// if there is sufficient overlap, suppress the current bounding box
			if (overlap > thresh)
			{
				pos = idxs.erase(pos);
			}<commit_msg>Remove cache arrays<commit_after>#include <iostream>
#include <string>
#include <time.h>

#include <opencv2/opencv.hpp>

void nms(
	const std::vector<cv::Rect>& srcRects,
	std::vector<cv::Rect>& resRects,
	float thresh
	)
{
	resRects.clear();

	const size_t size = srcRects.size();

	// If there are no boxes, return an empty list
	if (!size)
	{
		return;
	}

	// Sort the bounding boxes by the bottom - right y - coordinate of the bounding box
	std::multimap<int, size_t> idxs;
	for (size_t i = 0; i < size; ++i)
	{
		idxs.insert(std::pair<int, size_t>(srcRects[i].br().y, i));
	}

	// keep looping while some indexes still remain in the indexes list
	while (idxs.size() > 0)
	{
		// grab the last index in the indexes list, add the index value to the list of picked indexes, then initialize the suppression list(i.e.indexes that will be deleted) using the last index
		auto lastElem = --std::end(idxs);
		const cv::Rect& rect1 = srcRects[lastElem->second];

		resRects.push_back(rect1);

		idxs.erase(lastElem);

		// loop over all indexes in the indexes list
		for (auto pos = std::begin(idxs); pos != std::end(idxs); )
		{
			// grab the current index
			const cv::Rect& rect2 = srcRects[pos->second];

			// find the largest(x, y) coordinates for the start of the bounding box and the smallest(x, y) coordinates for the end of the bounding box
			int xx1 = std::max(rect1.x, rect2.x);
			int yy1 = std::max(rect1.y, rect2.y);
			int xx2 = std::min(rect1.br().x, rect2.br().x);
			int yy2 = std::min(rect1.br().y, rect2.br().y);

			// compute the width and height of the bounding box
			int w = std::max(0, xx2 - xx1 + 1);
			int h = std::max(0, yy2 - yy1 + 1);

			// compute the ratio of overlap between the computed bounding box and the bounding box in the area list
			float overlap = (w * h) / static_cast<float>(rect2.area());

			// if there is sufficient overlap, suppress the current bounding box
			if (overlap > thresh)
			{
				pos = idxs.erase(pos);
			}
{'fraction_non_alphanumeric': 0.14122681883024252, 'fraction_numerical': 0.014027579648121732, 'mean_word_length': 3.414480587618048, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 34, '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': '3642255', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1508, 'n_words': 508}