<commit_before>package algoholic

type Trie struct {
	Char     rune
	Children map[rune]*Trie
	Terminal bool
	Value    interface{}
}

const RootTrie = rune(0)

func NewTrie(chr rune) *Trie {
	return &Trie{chr, make(map[rune]*Trie), false, nil}
}

func NewRootTrie() *Trie {
	return NewTrie(RootTrie)
}

func NewTrieFromMap(strMap map[string]interface{}) *Trie {
	ret := NewRootTrie()

	for str, val := range strMap {
		ret.Insert(str, val)
	}

	return ret
}

func NewTrieFromStrings(strs []string) *Trie {
	strMap := make(map[string]interface{})
	for _, str := range strs {
		strMap[str] = nil
	}

	return NewTrieFromMap(strMap)
}

func (trie *Trie) FindTrie(str string) *Trie {
	if len(str) == 0 {
		return trie
	}

	if next := trie.Children[rune(str[0])]; next != nil {
		return next.FindTrie(str[1:])
	}

	return nil
}
<commit_msg>No need to create a map here.<commit_after>package algoholic

type Trie struct {
	Char     rune
	Children map[rune]*Trie
	Terminal bool
	Value    interface{}
}

const RootTrie = rune(0)

func NewTrie(chr rune) *Trie {
	return &Trie{chr, make(map[rune]*Trie), false, nil}
}

func NewRootTrie() *Trie {
	return NewTrie(RootTrie)
}

func NewTrieFromMap(strMap map[string]interface{}) *Trie {
	ret := NewRootTrie()

	for str, val := range strMap {
		ret.Insert(str, val)
	}

	return ret
}

func NewTrieFromStrings(strs []string) *Trie {
	ret := NewRootTrie()

	for _, str := range strs {
		ret.Insert(str, nil)
	}

	return ret
}

func (trie *Trie) FindTrie(str string) *Trie {
	if len(str) == 0 {
		return trie
	}

	if next := trie.Children[rune(str[0])]; next != nil {
		return next.FindTrie(str[1:])
	}

	return nil
}

{'fraction_non_alphanumeric': 0.13947847180109157, 'fraction_numerical': 0.004851425106124924, 'mean_word_length': 4.076923076923077, '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': '1847527', 'n_tokens_mistral': 691, 'n_tokens_neox': 669, 'n_words': 164}