<commit_before>package rational

// Rational stores a rational value.
type Rational struct {
	numerator   int64
	denominator int64
}

// New returns new rational number representation.
func New(n, d int64) (ev Rational) {
	return Rational{
		numerator:   n,
		denominator: d,
	}
}<commit_msg>creating new rational from float<commit_after>package rational

import (
	"math"
	"strconv"
	"strings"
)

// Rational stores a rational value.
type Rational struct {
	numerator   int64
	denominator int64
}

// New returns new rational number representation.
func New(n, d int64) (ev Rational) {
	return Rational{
		numerator:   n,
		denominator: d,
	}
}

// NewFromFloat returns new rational number representation retrieved from float64.
func NewFromFloat(f float64) (ev Rational, err error) {
	d, _ := math.Modf(f)

	fStr := strings.Split(strconv.FormatFloat(f, 'f', -1, 64), ".")[1]

	var numerator int64
	numerator, err = strconv.ParseInt(fStr, 10, 64)
	if err != nil {
		return
	}
	denominator := int64(math.Pow(10, float64(len(fStr))))

	ev = New(denominator*int64(d)+numerator, denominator)
	ev.Simplify()

	return
}
{'fraction_non_alphanumeric': 0.11310592459605028, 'fraction_numerical': 0.03052064631956912, 'mean_word_length': 4.186046511627907, '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': '5681160', 'n_tokens_mistral': 423, 'n_tokens_neox': 387, 'n_words': 116}