<commit_before>package template

import (
	"fmt"
	"regexp"
	"strings"
	"time"

	"github.com/grokify/gotilla/reflect/reflectutil"
	"github.com/grokify/gotilla/strings/stringsutil"
	"github.com/grokify/gotilla/time/timeutil"
)

// Execute takes a template string and an interface{}
// struct, substituting struct values for the variables.
// Field names can be nested.
func Execute(pattern string, item interface{}) string {
	r := regexp.MustCompile(`{{(.*?)}}`)
	m := r.FindAllStringSubmatch(pattern, -1)

	if len(m) == 0 {
		return pattern
	}

	fields := []FieldInfo{}
	for _, mi := range m {
		fieldsi := ParseFieldInfoString(mi[1])
		fields = append(fields, fieldsi...)<commit_msg>refactor template<commit_after>package template

import (
	"fmt"
	"regexp"
	"strings"
	"time"

	"github.com/grokify/gotilla/reflect/reflectutil"
	"github.com/grokify/gotilla/strings/stringsutil"
	"github.com/grokify/gotilla/time/timeutil"
)

// Execute takes a template string and an interface{}
// struct, substituting struct values for the variables.
// Field names can be nested.
func Execute(pattern string, item interface{}) string {
	r := regexp.MustCompile(`{{(.*?)}}`)
	m := r.FindAllStringSubmatch(pattern, -1)

	if len(m) == 0 {
		return pattern
	}

	fields := []FieldInfo{}
	for _, mi := range m {
		fields = append(fields, ParseFieldInfoString(mi[1])...)
{'fraction_non_alphanumeric': 0.15122312824314307, 'fraction_numerical': 0.004447739065974796, 'mean_word_length': 4.378486055776892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7117668', 'n_tokens_mistral': 477, 'n_tokens_neox': 458, 'n_words': 112}