<commit_before>package graph

import (
	"database/sql/driver"
	"fmt"
)

type SymbolStat struct {
	SymbolKey
	Type StatType
	N    int
}

type Stats map[StatType]int

type StatType string

const (
	StatXRefs            = "xrefs"
	StatRRefs            = "rrefs"
	StatURefs            = "urefs"
	StatXRefsRecursive   = "xrefs-recursive"
	StatRRefsRecursive   = "rrefs-recursive"
	StatURefsRecursive   = "urefs-recursive"
	StatAuthors          = "authors"
	StatClients          = "clients"
	StatDependents       = "dependents"
	StatExportedElements = "exported-elements"
)

func (x StatType) Value() (driver.Value, error) {
	return string(x), nil
}

func (x *StatType) Scan(v interface{}) error {
	if data, ok := v.([]byte); ok {
		*x = StatType(data)
		return nil
	}
	return fmt.Errorf("%T.Scan failed: %v", x, v)
}

// UniqueRefSymbols groups refs by the RefSymbolKey field and returns a map of
// how often each RefSymbolKey appears. If m is non-nil, counts are incremented
// and a new map is not created.
func UniqueRefSymbols(refs []*Ref, m map[RefSymbolKey]int) map[RefSymbolKey]int {
	if m == nil {
		m = make(map[RefSymbolKey]int)
	}
	for _, ref := range refs {
		m[ref.RefSymbolKey()]++
	}
	return m
}
<commit_msg>move SymbolStat to svc pkg<commit_after>package graph

import (
	"database/sql/driver"
	"fmt"
)

type Stats map[StatType]int

type StatType string

const (
	StatXRefs            = "xrefs"
	StatRRefs            = "rrefs"
	StatURefs            = "urefs"
	StatXRefsRecursive   = "xrefs-recursive"
	StatRRefsRecursive   = "rrefs-recursive"
	StatURefsRecursive   = "urefs-recursive"
	StatAuthors          = "authors"
	StatClients          = "clients"
	StatDependents       = "dependents"
	StatExportedElements = "exported-elements"
)

func (x StatType) Value() (driver.Value, error) {
	return string(x), nil
}

func (x *StatType) Scan(v interface{}) error {
	if data, ok := v.([]byte); ok {
		*x = StatType(data)
		return nil
	}
	return fmt.Errorf("%T.Scan failed: %v", x, v)
}

// UniqueRefSymbols groups refs by the RefSymbolKey field and returns a map of
// how often each RefSymbolKey appears. If m is non-nil, counts are incremented
// and a new map is not created.
func UniqueRefSymbols(refs []*Ref, m map[RefSymbolKey]int) map[RefSymbolKey]int {
	if m == nil {
		m = make(map[RefSymbolKey]int)
	}
	for _, ref := range refs {
		m[ref.RefSymbolKey()]++
	}
	return m
}

{'fraction_non_alphanumeric': 0.11813992459153749, 'fraction_numerical': 0.0, 'mean_word_length': 3.3260869565217392, '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': '5166023', 'n_tokens_mistral': 903, 'n_tokens_neox': 863, 'n_words': 234}