<commit_before>package dynmap

import (
	"fmt"
	"log"
	"strconv"
	"strings"
	"time"
)

//parse time
func ToTime(value interface{}) (tm time.Time, err error) {
	switch v := value.(type) {
	case string:
		t, err := time.Parse(time.RFC3339, v)
		if err == nil {
			return t, nil
		}
		return time.Now(), err
	}
	return time.Now(), fmt.Errorf("Unable to parse (%s) into a time", value)
}

func ToBool(value interface{}) (bool, error) {
	switch v := value.(type) {
	case bool:
		return v, nil
	case string:
		tmp := strings.ToLower(v)
		if tmp == "true" || tmp == "t" || tmp == "yes" || tmp == "y" || tmp == "on" {
			return true, nil
		}

		if tmp == "false" || tmp == "f" || tmp == "no" || tmp == "n" || tmp == "off" {
			return false, nil
		}
	}
	return false, fmt.Errorf("Unable to convert to bool (%s)", value)
}

func ToInt(value interface{}) (int, error) {
	i, err := ToInt64(value)
	return int(i), err
}

func ToInt64(value interface{}) (i int64, err error) {
	switch v := value.(type) {
	case string:
		i, err := strconv.ParseInt(v, 0, 64)
		return i, err
	case int:
		return int64(v), nil
	case uint:
		return int64(v), nil<commit_msg>strip whitespace when converting to numbers<commit_after>package dynmap

import (
	"fmt"
	"log"
	"strconv"
	"strings"
	"time"
)

//parse time
func ToTime(value interface{}) (tm time.Time, err error) {
	switch v := value.(type) {
	case string:
		t, err := time.Parse(time.RFC3339, v)
		if err == nil {
			return t, nil
		}
		return time.Now(), err
	}
	return time.Now(), fmt.Errorf("Unable to parse (%s) into a time", value)
}

func ToBool(value interface{}) (bool, error) {
	switch v := value.(type) {
	case bool:
		return v, nil
	case string:
		tmp := strings.ToLower(v)
		if tmp == "true" || tmp == "t" || tmp == "yes" || tmp == "y" || tmp == "on" {
			return true, nil
		}

		if tmp == "false" || tmp == "f" || tmp == "no" || tmp == "n" || tmp == "off" {
			return false, nil
		}
	}
	return false, fmt.Errorf("Unable to convert to bool (%s)", value)
}

func ToInt(value interface{}) (int, error) {
	i, err := ToInt64(value)
	return int(i), err
}

func ToInt64(value interface{}) (i int64, err error) {
	switch v := value.(type) {
	case string:
		i, err := strconv.ParseInt(strings.TrimSpace(v), 0, 64)
		return i, err
	case int:
		return int64(v), nil
	case uint:
		return int64(v), nil
{'fraction_non_alphanumeric': 0.18162301416917132, 'fraction_numerical': 0.014598540145985401, 'mean_word_length': 3.3879472693032016, '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': '1502423', 'n_tokens_mistral': 946, 'n_tokens_neox': 881, 'n_words': 284}