<commit_before>package eval

import (
	"fmt"
	"reflect"
	"strconv"
)

// Inspect prints a reflect.Value the way you would enter it.
// Some like this should really be part of the reflect package.
func Inspect(val reflect.Value) string {
	if val.Interface() == nil {
		return "nil"
	}
	switch val.Kind() {
	case reflect.String:
		return strconv.QuoteToASCII(val.String())
	case reflect.Bool, reflect.Int,	reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:
		fmt.Sprintf("%v", val.Interface())
	case reflect.Slice, reflect.Array:
		sep := "{"
		str := ""
		for i:=0; i < val.Len(); i++ {
			str += sep
			sep = ", "
			str += Inspect(val.Index(i))
		}
		str += "}"
		return str

	case reflect.Struct:
		str := "{"
		n  := val.NumField()
		for i := 0; i < n; i++ {
			if i > 0 { str += " " }
			name  := val.Type().Field(i).Name
			field := val.Field(i)
			str += fmt.Sprintf("%s: %s,", name, Inspect(field))
		}
		str += "}"
		return str
	}


	// FIXME: add more Kinds as folks are annoyed with the output of
	// the below:
	return fmt.Sprintf("%v", val.Interface())
}<commit_msg>inspect.go: Do better on showing Pointer values. Don't use fmt.Sprintf("%v"<commit_after>package eval

import (
	"fmt"
	"reflect"
	"strconv"
)

// Inspect prints a reflect.Value the way you would enter it.
// Some like this should really be part of the reflect package.
func Inspect(val reflect.Value) string {
	if val.Interface() == nil {
		return "nil"
	}
	switch val.Kind() {
	case reflect.String:
		return strconv.QuoteToASCII(val.String())
	case reflect.Bool, reflect.Int,	reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:
		fmt.Sprintf("%v", val.Interface())
	case reflect.Slice, reflect.Array:
		sep := "{"
		str := ""
		for i:=0; i < val.Len(); i++ {
			str += sep
			sep = ", "
			str += Inspect(val.Index(i))
		}
		str += "}"
		return str

	case reflect.Struct:
		str := "{"
		n  := val.NumField()
		for i := 0; i < n; i++ {
			if i > 0 { str += " " }
			name  := val.Type().Field(i).Name
			field := val.Field(i)
			str += fmt.Sprintf("%s: %s,", name, Inspect(field))
		}
		str += "}"
		return str

	case reflect.Ptr:
		return "&" + Inspect(val.Elem())
	}


	// FIXME: add more Kinds as folks are annoyed with the output of
	// the below:
	return fmt.Sprintf("%v", val.Interface())
}
{'fraction_non_alphanumeric': 0.16622188333968738, 'fraction_numerical': 0.019824628288219594, 'mean_word_length': 3.380634390651085, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6379864', 'n_tokens_mistral': 1021, 'n_tokens_neox': 922, 'n_words': 259}