<commit_before>package enum

//TreeEnum is a special type of Enum where the list of values also have a tree
//structure that can be interrogated. TreeEnums always have 0 map to "" as the
//root value.
type TreeEnum interface {
	Enum

	//IsLeaf returns true if the given value in the enum represents a leaf (as
	//opposed to branch)
	IsLeaf(val int) bool

	//Children returns all of the val beneath this branch that are direct
	//descendents, either including or excluding non-leaf nodes.
	Children(node int, includeBranches bool) []int

	//Descendants returns all enumvals beneath this point, recursively.
	Descendants(node int, includeBranches bool) []int

	NewImmutableTreeVal(val int) (ImmutableTreeVal, error)
	NewTreeVal() TreeVal

	MustNewImmutableTreeVal(val int) ImmutableTreeVal
	MustNewTreeVal(val int) TreeVal
}

//ImmutableTreeVal is a value from a TreeEnum.
type ImmutableTreeVal interface {
	ImmutableVal

	//IsLeaf is a convenience for
	//!val.TreeEnum().IsLeaf(val.Value())
	IsLeaf() bool

	//NodeString returns the name of this specific node, whereas String
	//returns the fully qualified name. So whereas String() might return
	//"Normal - Default - Save Item", NodeString() will return "Default".
	NodeString() string
}

//TreeVal is a value from a tree enum.
type TreeVal interface {
	Val

	//IsLeaf is a convenience for
	//!val.TreeEnum().IsLeaf(val.Value())
	IsLeaf() bool

	//NodeString returns the name of this specific node, whereas String
	//returns the fully qualified name. So whereas String() might return
	//"Normal - Default - Save Item", NodeString() will return "Default".
	NodeString() string
}

func (e *enum) IsLeaf(val int) bool {
	if e.tree == nil {
		return false
	}
<commit_msg>Factored TreeVal's getter methods into a separate interface for clarity. Part of #628.<commit_after>package enum

//TreeEnum is a special type of Enum where the list of values also have a tree
//structure that can be interrogated. TreeEnums always have 0 map to "" as the
//root value.
type TreeEnum interface {
	Enum

	//IsLeaf returns true if the given value in the enum represents a leaf (as
	//opposed to branch)
	IsLeaf(val int) bool

	//Children returns all of the val beneath this branch that are direct
	//descendents, either including or excluding non-leaf nodes.
	Children(node int, includeBranches bool) []int

	//Descendants returns all enumvals beneath this point, recursively.
	Descendants(node int, includeBranches bool) []int

	NewImmutableTreeVal(val int) (ImmutableTreeVal, error)
	NewTreeVal() TreeVal

	MustNewImmutableTreeVal(val int) ImmutableTreeVal
	MustNewTreeVal(val int) TreeVal
}

//TreeValGetters is the collection of methods that TreeVals have beyodn normal
//Vals. It is factored out into a separate interface to clarify how
//ImmutableTreeVal and TreeVal differ from their non-treeval types.
type TreeValGetters interface {
	//IsLeaf is a convenience for
	//!val.TreeEnum().IsLeaf(val.Value())
	IsLeaf() bool

	//NodeString returns the name of this specific node, whereas String
	//returns the fully qualified name. So whereas String() might return
	//"Normal - Default - Save Item", NodeString() will return "Default".
	NodeString() string
}

//ImmutableTreeVal is a value from a TreeEnum.
type ImmutableTreeVal interface {
	ImmutableVal
	TreeValGetters
}

//TreeVal is a value from a tree enum.
type TreeVal interface {
	Val
	TreeValGetters
}

func (e *enum) IsLeaf(val int) bool {
	if e.tree == nil {
		return false
	}

{'fraction_non_alphanumeric': 0.08093317972350231, 'fraction_numerical': 0.0014400921658986176, 'mean_word_length': 4.137573964497041, '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': '48052', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1007, 'n_words': 442}