<commit_before>package xkcd

import (
	"encoding/json"
	"net/http"
	"strconv"
	"time"
)

type comicResponse struct {
	Alt        string `json:"alt"`
	Day        string `json:"day"`
	ImageURL   string `json:"img"`
	URL        string `json:"link"`
	Month      string `json:"month"`
	Number     int    `json:"num"`
	SafeTitle  string `json:"safe_title"`
	Title      string `json:"title"`
	Transcript string `json:"transcript"`
	Year       string `json:"year"`
}

type Comic struct {
	Alt         string
	PublishDate time.Time
	ImageURL    string
	URL         string
	Number      int
	SafeTitle   string
	Title       string
	Transcript  string
}

func (comic *Comic) UnmarshalJSON(data []byte) error {
	var aux comicResponse
	if err := json.Unmarshal(data, &aux); err != nil {
		return err
	}

	date, err := time.Parse("2006/1/2", aux.Year+"/"+aux.Month+"/"+aux.Day)
	if err != nil {
		return err
	}

	comic.Alt = aux.Alt
	comic.PublishDate = date
	comic.ImageURL = aux.ImageURL
	comic.URL = aux.URL
	comic.Number = aux.Number
	comic.SafeTitle = aux.SafeTitle
	comic.Title = aux.Title
	comic.Transcript = aux.Transcript

	return nil
}

func (c *Client) doComicRequest(path string) (Comic, error) {
	var comic Comic

	req, err := http.NewRequest("GET", c.baseURL()+path, nil)
	if err != nil {
		return comic, err
	}

	body, err := c.do(req)
	if err != nil {
		return comic, err
	}
	defer body.Close()

	if err := json.NewDecoder(body).Decode(&comic); err != nil {
		return comic, err
	}
	return comic, nil
}<commit_msg>Add News field to Comic<commit_after>package xkcd

import (
	"encoding/json"
	"net/http"
	"strconv"
	"time"
)

type comicResponse struct {
	Alt        string `json:"alt"`
	Day        string `json:"day"`
	ImageURL   string `json:"img"`
	URL        string `json:"link"`
	Month      string `json:"month"`
	News       string `json:"news"`
	Number     int    `json:"num"`
	SafeTitle  string `json:"safe_title"`
	Title      string `json:"title"`
	Transcript string `json:"transcript"`
	Year       string `json:"year"`
}

type Comic struct {
	Alt         string
	PublishDate time.Time
	ImageURL    string
	URL         string
	News        string
	Number      int
	SafeTitle   string
	Title       string
	Transcript  string
}

func (comic *Comic) UnmarshalJSON(data []byte) error {
	var aux comicResponse
	if err := json.Unmarshal(data, &aux); err != nil {
		return err
	}

	date, err := time.Parse("2006/1/2", aux.Year+"/"+aux.Month+"/"+aux.Day)
	if err != nil {
		return err
	}

	comic.Alt = aux.Alt
	comic.PublishDate = date
	comic.ImageURL = aux.ImageURL
	comic.URL = aux.URL
	comic.Number = aux.Number
	comic.News = aux.News
	comic.SafeTitle = aux.SafeTitle
	comic.Title = aux.Title
	comic.Transcript = aux.Transcript

	return nil
}

func (c *Client) doComicRequest(path string) (Comic, error) {
	var comic Comic

	req, err := http.NewRequest("GET", c.baseURL()+path, nil)
	if err != nil {
		return comic, err
	}

	body, err := c.do(req)
	if err != nil {
		return comic, err
	}
	defer body.Close()

	if err := json.NewDecoder(body).Decode(&comic); err != nil {
		return comic, err
	}
	return comic, nil
}
{'fraction_non_alphanumeric': 0.13166345536287732, 'fraction_numerical': 0.0038535645472061657, 'mean_word_length': 3.0932982917214193, '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': '1288267', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1108, 'n_words': 303}