<commit_before>package db

import (
	"fmt"
)

type Pointer struct {
	Season  uint
	Episode uint
}

func (p Pointer) String() string {
	return fmt.Sprintf("S%02dE%02d", p.Season, p.Episode)
}<commit_msg>Implement parsing pointer from string<commit_after>package db

import (
	"errors"
	"fmt"
	"regexp"
	"strconv"
)

type Pointer struct {
	Season  uint
	Episode uint
}

func (p Pointer) String() string {
	return fmt.Sprintf("S%02dE%02d", p.Season, p.Episode)
}

func PointerFromString(s string) (Pointer, error) {
	re := regexp.MustCompile(`^S(\d+)E(\d+)$`)
	match := re.FindStringSubmatch(s)
	if match == nil {
		return Pointer{}, errors.New("Invalid pointer")
	}

	season, _ := strconv.Atoi(match[1])
	episode, _ := strconv.Atoi(match[2])

	return Pointer{
		Season:  uint(season),
		Episode: uint(episode),
	}, nil
}
{'fraction_non_alphanumeric': 0.15403422982885084, 'fraction_numerical': 0.012224938875305624, 'mean_word_length': 4.571428571428571, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4387926', 'n_tokens_mistral': 332, 'n_tokens_neox': 311, 'n_words': 74}