<commit_before>package kumo

import (
	"encoding/xml"
	"io"
	"io/ioutil"
)

type NZB struct {
	Files []File `xml:"file"`
}

type File struct {
	Poster   string    `xml:"poster,attr"`
	Subject  string    `xml:"subject,attr"`
	Date     int       `xml:"date,attr"`
	Groups   []string  `xml:"groups>group"`
	Segments []Segment `xml:"segments>segment"`
}

type Segment struct {
	Bytes   int    `xml:"bytes,attr"`
	Number  int    `xml:"number,attr"`
	Segment string `xml:",chardata"`
	Group   string
}

func (n *NZB) Size() int {
	size := 0
	for i := 0; i < len(n.Files); i++ {
		files := n.Files[i]

		for j := 0; j < len(files.Segments); j++ {
			size += files.Segments[j].Bytes
		}
	}

	return size
}

func Parse(f io.Reader) (*NZB, error) {
	data, err := ioutil.ReadAll(f)
	if err != nil {
		return nil, err
	}

	nzb := new(NZB)
	err = xml.Unmarshal(data, &nzb)
	if err != nil {
		return nil, err
	}

	return nzb, nil
}
<commit_msg>Switched to use range for loops.<commit_after>package kumo

import (
	"encoding/xml"
	"io"
	"io/ioutil"
)

type NZB struct {
	Files []File `xml:"file"`
}

type File struct {
	Poster   string    `xml:"poster,attr"`
	Subject  string    `xml:"subject,attr"`
	Date     int       `xml:"date,attr"`
	Groups   []string  `xml:"groups>group"`
	Segments []Segment `xml:"segments>segment"`
}

type Segment struct {
	Bytes   int    `xml:"bytes,attr"`
	Number  int    `xml:"number,attr"`
	Segment string `xml:",chardata"`
	Group   string
}

func (n *NZB) Size() int {
	size := 0
	for _, file := range n.Files {
		for _, segment := range file.Segments {
			size += segment.Bytes
		}
	}

	return size
}

func Parse(f io.Reader) (*NZB, error) {
	data, err := ioutil.ReadAll(f)
	if err != nil {
		return nil, err
	}

	nzb := new(NZB)
	err = xml.Unmarshal(data, &nzb)
	if err != nil {
		return nil, err
	}

	return nzb, nil
}

{'fraction_non_alphanumeric': 0.16158868335146898, 'fraction_numerical': 0.002176278563656148, 'mean_word_length': 3.2275862068965515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 22}, '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': '7434844', 'n_tokens_mistral': 758, 'n_tokens_neox': 727, 'n_words': 193}