<commit_before>package xmmsclient

type XmmsValue interface {
	isXmmsValue()
}
type XmmsInt int64
type XmmsError string
type XmmsString string
type XmmsDict map[string]XmmsValue
type XmmsList struct {
	Entries  []XmmsValue
	Restrict uint32
}

func (i XmmsInt) isXmmsValue() {}

func (s XmmsError) isXmmsValue() {}

func (s XmmsString) isXmmsValue() {}

func (d XmmsDict) isXmmsValue() {}

func (l XmmsList) isXmmsValue() {}

func NewXmmsList(entries ...XmmsValue) XmmsList {
	return XmmsList{Entries: entries, Restrict: TypeNone}
}<commit_msg>Add value type conversion helpers.<commit_after>package xmmsclient

import (
	"errors"
)

type XmmsValue interface {
	isXmmsValue()
}
type XmmsInt int64
type XmmsError string
type XmmsString string
type XmmsDict map[string]XmmsValue
type XmmsList struct {
	Entries  []XmmsValue
	Restrict uint32
}

func (i XmmsInt) isXmmsValue() {}

func (s XmmsError) isXmmsValue() {}

func (s XmmsString) isXmmsValue() {}

func (d XmmsDict) isXmmsValue() {}

func (l XmmsList) isXmmsValue() {}

func NewXmmsList(entries ...XmmsValue) XmmsList {
	return XmmsList{Entries: entries, Restrict: TypeNone}
}

func valueAsInt(raw XmmsValue) (XmmsInt, error) {
	if value, ok := raw.(XmmsInt); ok {
		return value, nil
	}
	return 0, errors.New("Bad type")
}

func valueAsString(raw XmmsValue) (XmmsString, error) {
	if value, ok := raw.(XmmsString); ok {
		return value, nil
	}
	return "", errors.New("Bad type")
}

func valueAsList(raw XmmsValue) (XmmsList, error) {
	if value, ok := raw.(XmmsList); ok {
		return value, nil
	}
	return XmmsList{}, errors.New("Bad type")
}

func valueAsDict(raw XmmsValue) (XmmsDict, error) {
	if value, ok := raw.(XmmsDict); ok {
		return value, nil
	}
	return XmmsDict{}, errors.New("Bad type")
}
{'fraction_non_alphanumeric': 0.12164477441462021, 'fraction_numerical': 0.005139920045688178, 'mean_word_length': 5.041379310344827, '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': '767418', 'n_tokens_mistral': 713, 'n_tokens_neox': 702, 'n_words': 181}