<commit_before>package subscription

import (
	"strings"

	"github.com/liam-lai/ptt-alertor/myutil"
)

type Subscription struct {
	Board    string             `json:"board"`
	Keywords myutil.StringSlice `json:"keywords"`
	Authors  myutil.StringSlice `json:"authors"`
}

func (s Subscription) String() string {
	if len(s.Keywords) == 0 {
		return ""
	}
	return s.Board + ": " + strings.Join(s.Keywords, ", ")
}

func (s Subscription) StringAuthor() string {
	if len(s.Authors) == 0 {
		return ""
	}
	return s.Board + ": " + strings.Join(s.Authors, ", ")
}

func (s *Subscription) CleanUp() {
	s.Keywords.Clean()
	s.Keywords.RemoveStringsSpace()
	s.Authors.Clean()
	s.Authors.RemoveStringsSpace()
}<commit_msg>sort keywords and authors before print<commit_after>package subscription

import (
	"sort"
	"strings"

	"github.com/liam-lai/ptt-alertor/myutil"
)

type Subscription struct {
	Board    string             `json:"board"`
	Keywords myutil.StringSlice `json:"keywords"`
	Authors  myutil.StringSlice `json:"authors"`
}

func (s Subscription) String() string {
	if len(s.Keywords) == 0 {
		return ""
	}
	sort.Strings(s.Keywords)
	return s.Board + ": " + strings.Join(s.Keywords, ", ")
}

func (s Subscription) StringAuthor() string {
	if len(s.Authors) == 0 {
		return ""
	}
	sort.Strings(s.Authors)
	return s.Board + ": " + strings.Join(s.Authors, ", ")
}

func (s *Subscription) CleanUp() {
	s.Keywords.Clean()
	s.Keywords.RemoveStringsSpace()
	s.Authors.Clean()
	s.Authors.RemoveStringsSpace()
}
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.0026666666666666666, 'mean_word_length': 3.9701986754966887, 'pattern_counts': {'":': 4, '<': 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': '500199', 'n_tokens_mistral': 561, 'n_tokens_neox': 536, 'n_words': 106}