<commit_before>package qb

import (
	"fmt"
	"github.com/fatih/structs"
	"github.com/serenize/snaker"
	"strings"
)

const tagPrefix = "qb"

// NewMapper instantiates a new mapper object and returns it as a mapper pointer
func NewMapper(driver string) *Mapper {
	return &Mapper{
		driver: driver,
	}
}

// Mapper is the generic struct for struct to table mapping
type Mapper struct {
	driver string
}

func (m *Mapper) extractValue(value string) string {

	hasParams := strings.Contains(value, "(") && strings.Contains(value, ")")

	if hasParams {
		startIndex := strings.Index(value, "(")
		endIndex := strings.Index(value, ")")
		return value[startIndex+1 : endIndex]
	}

	return ""
}

// ConvertStructToMap converts a model struct to a map
func (m *Mapper) ConvertStructToMap(model interface{}) map[string]interface{} {

	fields := structs.Fields(model)
	kv := map[string]interface{}{}
	for _, f := range fields {
		if f.IsZero() {
			continue
		}

		kv[f.Name()] = f.Value()
	}
	return kv
}
<commit_msg>add convention mapping to ConvertStructToMap in mapper<commit_after>package qb

import (
	"fmt"
	"github.com/fatih/structs"
	"github.com/serenize/snaker"
	"strings"
)

const tagPrefix = "qb"

// NewMapper instantiates a new mapper object and returns it as a mapper pointer
func NewMapper(driver string) *Mapper {
	return &Mapper{
		driver: driver,
	}
}

// Mapper is the generic struct for struct to table mapping
type Mapper struct {
	driver string
}

func (m *Mapper) extractValue(value string) string {

	hasParams := strings.Contains(value, "(") && strings.Contains(value, ")")

	if hasParams {
		startIndex := strings.Index(value, "(")
		endIndex := strings.Index(value, ")")
		return value[startIndex+1 : endIndex]
	}

	return ""
}

// ConvertStructToMap converts a model struct to a map
func (m *Mapper) ConvertStructToMap(model interface{}) map[string]interface{} {

	fields := structs.Fields(model)
	kv := map[string]interface{}{}
	for _, f := range fields {
		if f.IsZero() {
			continue
		}

		kv[m.ColName(f.Name())] = f.Value()
	}
	return kv
}

{'fraction_non_alphanumeric': 0.13336566440349176, 'fraction_numerical': 0.0009699321047526673, 'mean_word_length': 4.209595959595959, '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': '160403', 'n_tokens_mistral': 725, 'n_tokens_neox': 691, 'n_words': 194}