<commit_before>#include <ostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include "sevensegment.h"

namespace sevensegment {

	const static std::vector< std::vector<std::string> > digits {
		{ " - ", "| |", "   ", "| |", " - " }, // 0
		{ "   ", "  |", "   ", "  |", "   " }, // 1
		{ " - ", "  |", " - ", "|  ", " - " }, // 2
		{ " - ", "  |", " - ", "  |", " - " }, // 3
		{ "   ", "| |", " - ", "  |", "   " }, // 4
		{ " - ", "|  ", " - ", "  |", " - " }, // 5
		{ " - ", "|  ", " - ", "| |", " - " }, // 6
		{ " - ", "  |", "   ", "  |", "   " }, // 7
		{ " - ", "| |", " - ", "| |", " - " }, // 8
		{ " - ", "| |", " - ", "  |", " - " }  // 9
	};
	const static std::vector<std::string> minus_sign
		{ "   ", "   ", " - ", "   ", "   " }; // -

	const static std::vector< std::vector<std::string> > error {
		{ " - ", "|  ", " - ", "|  ", " - " }, // E
		{ "   ", "   ", " - ", "|  ", "   " }, // r
		{ "   ", "   ", " - ", "|  ", "   " }, // r
		{ "   ", "   ", " - ", "| |", " - " }, // o
		{ "   ", "   ", " - ", "|  ", "   " }, // r
	};

	std::string stretchLine(const std::string &line, unsigned n) {
		std::string stretched_line(n+2, line[1]);
		stretched_line.front() = line[0];
		stretched_line.back() = line[2];
		return stretched_line;
	}

	std::vector< std::vector<std::string> > split_digits(int i, std::vector< std::vector<std::string> > &vector) {
	    if(i >= 10)
	       split_digits(i / 10, vector);

	    vector.push_back(digits.at(i % 10));
	    return vector;
	}

	std::vector< std::vector<std::string> > split_digits(int i) {
		std::vector< std::vector<std::string> > vector {};
		if (i<0) {
			vector.push_back(minus_sign);
			i = -i;
		}

		return split_digits(i, vector);
	}

	std::string lineOfLargeDigits(const std::vector< std::vector<std::string> > &digits_vector, unsigned line_nr, unsigned n){
		std::string line {};
		for_each(digits_vector.begin(), digits_vector.end(), [&](std::vector<std::string> digit){
			line.append(stretchLine(digit[line_nr], n));
			line.append(n/2, ' '); // letter spacing for readability
		});
		return line;
	}


	void printDigitSequence(std::vector< std::vector<std::string> > digits_vector, std::ostream &out, unsigned n){
		if (n<1) throw std::invalid_argument { "invalid scale" };
		unsigned line_nr {0};
		std::ostream_iterator<std::string> out_it(out, "\n");

		// iterate through lines, not digits
		// OPTIMIZE: transpose vector first
		for_each(digits_vector.front().begin(), digits_vector.front().end(), [&](std::string){
			if (line_nr == 1 || line_nr == 3) {
				auto line = lineOfLargeDigits(digits_vector, line_nr, n);
				std::generate_n(out_it, n, [&](){return line;});
			} else {
				out << lineOfLargeDigits(digits_vector, line_nr, n) << '\n';
			}
			line_nr++;
		});
	}

	void printLargeDigit(unsigned i, std::ostream &out, unsigned n) {
		auto digit = digits.at(i);<commit_msg>only add letter spacing between letters<commit_after>#include <ostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include "sevensegment.h"

namespace sevensegment {

	const static std::vector< std::vector<std::string> > digits {
		{ " - ", "| |", "   ", "| |", " - " }, // 0
		{ "   ", "  |", "   ", "  |", "   " }, // 1
		{ " - ", "  |", " - ", "|  ", " - " }, // 2
		{ " - ", "  |", " - ", "  |", " - " }, // 3
		{ "   ", "| |", " - ", "  |", "   " }, // 4
		{ " - ", "|  ", " - ", "  |", " - " }, // 5
		{ " - ", "|  ", " - ", "| |", " - " }, // 6
		{ " - ", "  |", "   ", "  |", "   " }, // 7
		{ " - ", "| |", " - ", "| |", " - " }, // 8
		{ " - ", "| |", " - ", "  |", " - " }  // 9
	};
	const static std::vector<std::string> minus_sign
		{ "   ", "   ", " - ", "   ", "   " }; // -

	const static std::vector< std::vector<std::string> > error {
		{ " - ", "|  ", " - ", "|  ", " - " }, // E
		{ "   ", "   ", " - ", "|  ", "   " }, // r
		{ "   ", "   ", " - ", "|  ", "   " }, // r
		{ "   ", "   ", " - ", "| |", " - " }, // o
		{ "   ", "   ", " - ", "|  ", "   " }, // r
	};

	std::string stretchLine(const std::string &line, unsigned n) {
		std::string stretched_line(n+2, line[1]);
		stretched_line.front() = line[0];
		stretched_line.back() = line[2];
		return stretched_line;
	}

	std::vector< std::vector<std::string> > split_digits(int i, std::vector< std::vector<std::string> > &vector) {
	    if(i >= 10)
	       split_digits(i / 10, vector);

	    vector.push_back(digits.at(i % 10));
	    return vector;
	}

	std::vector< std::vector<std::string> > split_digits(int i) {
		std::vector< std::vector<std::string> > vector {};
		if (i<0) {
			vector.push_back(minus_sign);
			i = -i;
		}

		return split_digits(i, vector);
	}

	std::string lineOfLargeDigits(const std::vector< std::vector<std::string> > &digits_vector, unsigned line_nr, unsigned n){
		std::string line {};
		unsigned digit_nr { 0 };
		for_each(digits_vector.begin(), digits_vector.end(), [&](std::vector<std::string> digit){
			line.append(stretchLine(digit[line_nr], n));

			// between digits (not at the end)
			if (++digit_nr != digits_vector.size())
				line.append(n/2, ' '); // letter spacing for readability
		});
		return line;
	}

	void printDigitSequence(std::vector< std::vector<std::string> > digits_vector, std::ostream &out, unsigned n){
		if (n<1) throw std::invalid_argument { "invalid scale" };
		unsigned line_nr {0};
		std::ostream_iterator<std::string> out_it(out, "\n");

		// iterate through lines, not digits
		// OPTIMIZE: transpose vector first
		for_each(digits_vector.front().begin(), digits_vector.front().end(), [&](std::string){
			if (line_nr == 1 || line_nr == 3) {
				auto line = lineOfLargeDigits(digits_vector, line_nr, n);
				std::generate_n(out_it, n, [&](){return line;});
			} else {
				out << lineOfLargeDigits(digits_vector, line_nr, n) << '\n';
			}
			line_nr++;
		});
	}

	void printLargeDigit(unsigned i, std::ostream &out, unsigned n) {
		auto digit = digits.at(i);
{'fraction_non_alphanumeric': 0.2555985856204748, 'fraction_numerical': 0.008924061289779425, 'mean_word_length': 2.7171464330413015, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 53, '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': '2994428', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2284, 'n_words': 368}