<commit_before>package util

import (
	"bytes"
	"fmt"
	"strings"
)

// PosError is an error associated with a position range.
type PosError struct {
	Begin int
	End   int
	Err   error
}

func (pe *PosError) Error() string {
	return fmt.Sprintf("%d-%d: %s", pe.Begin, pe.End, pe.msg())
}

// Pprint pretty-prints a PosError with a header indicating the source and type
// of the error, the error text and the affected line with an additional line
// that points an arrow at the affected column.
func (pe *PosError) Pprint(srcname, errtype, src string) string {
	lineno, colno, line := FindContext(src, pe.Begin)

	buf := new(bytes.Buffer)
	// Source and type of the error
	fmt.Fprintf(buf, "\033[1m%s:%d:%d: \033[31m%s:", srcname, lineno+1, colno+1, errtype)
	// Message
	fmt.Fprintf(buf, "\033[m\033[1m%s\033[m\n", pe.msg())
	// Affected line
	// TODO Handle long lines
	fmt.Fprintf(buf, "%s\n", line)
	// Column indicator
	// TODO Handle multi-width characters
	fmt.Fprintf(buf, "%s\033[32;1m^\033[m\n", strings.Repeat(" ", colno))
	return buf.String()
}

func (pe *PosError) msg() string {
	if pe.Err != nil {
		return pe.Err.Error()
	} else {
		return "<nil>"
	}
}
<commit_msg>Add a missing space to the pprint of PosError.<commit_after>package util

import (
	"bytes"
	"fmt"
	"strings"
)

// PosError is an error associated with a position range.
type PosError struct {
	Begin int
	End   int
	Err   error
}

func (pe *PosError) Error() string {
	return fmt.Sprintf("%d-%d: %s", pe.Begin, pe.End, pe.msg())
}

// Pprint pretty-prints a PosError with a header indicating the source and type
// of the error, the error text and the affected line with an additional line
// that points an arrow at the affected column.
func (pe *PosError) Pprint(srcname, errtype, src string) string {
	lineno, colno, line := FindContext(src, pe.Begin)

	buf := new(bytes.Buffer)
	// Source and type of the error
	fmt.Fprintf(buf, "\033[1m%s:%d:%d: \033[31m%s: ", srcname, lineno+1, colno+1, errtype)
	// Message
	fmt.Fprintf(buf, "\033[m\033[1m%s\033[m\n", pe.msg())
	// Affected line
	// TODO Handle long lines
	fmt.Fprintf(buf, "%s\n", line)
	// Column indicator
	// TODO Handle multi-width characters
	fmt.Fprintf(buf, "%s\033[32;1m^\033[m\n", strings.Repeat(" ", colno))
	return buf.String()
}

func (pe *PosError) msg() string {
	if pe.Err != nil {
		return pe.Err.Error()
	} else {
		return "<nil>"
	}
}

{'fraction_non_alphanumeric': 0.15246449456975772, 'fraction_numerical': 0.02506265664160401, 'mean_word_length': 3.668615984405458, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6769190', 'n_tokens_mistral': 912, 'n_tokens_neox': 869, 'n_words': 278}