<commit_before>package gb2260

import "strconv"

type Division struct {
	Code string
	Name string
	Year string
}

var (
	EMPTY_DIVISION Division
)

func (this Division) Province() Division {
	code := this.Code[0:2] + "0000"
	return Get(code)
}

func (this Division) Prefecture() Division {
	if this.IsProvince() {
		return EMPTY_DIVISION
	}

	code := this.Code[:4] + "00"
	return Get(code)
}

func (this Division) Country() Division {
	if this.IsProvince() || this.IsPrefecture() {
		return EMPTY_DIVISION
	}
	return this
}

func (this Division) IsProvince() bool {
	return this.Province() == this
}

func (this Division) IsPrefecture() bool {
	return this.Prefecture() == this
}

func (this Division) IsCountry() bool {
	return this.Country() != EMPTY_DIVISION
}

func (this Division) Stack() []Division {
	stacks := make([]Division, 0)

	province := this.Province()
	stacks = append(stacks, province)

	if this.IsPrefecture() || this.IsCountry() {
		prefecture := this.Prefecture()
		stacks = append(stacks, prefecture)
	}

	if this.IsCountry() {
		stacks = append(stacks, this)
	}

	return stacks
}

func Get(code string) Division {
	key, err := strconv.Atoi(code)
	if err != nil {
		return EMPTY_DIVISION
	}

	div, ok := divisions[key]
	if !ok {
		return EMPTY_DIVISION
	}

	return div
}

// not implemenet
func Search(code string) *Division {
	return nil
}<commit_msg>change code to fit golint<commit_after>package gb2260

import (
	"strconv"
	"strings"
)

// Division 地区
type Division struct {
	Code string // The six-digit number of the specific administrative division.
	Name string // The Chinese name of the specific administrative division.
	Year string // Optional. The revision year, and empty means "latest".
}

var (
	_EmptyDivision Division
)

// Province 省份
func (div Division) Province() Division {
	code := div.Code[0:2] + "0000"
	return Get(code)
}

// Prefecture 地区
func (div Division) Prefecture() Division {
	if div.IsProvince() {
		return _EmptyDivision
	}

	code := div.Code[:4] + "00"
	return Get(code)
}

// Country 县
func (div Division) Country() Division {
	if div.IsProvince() || div.IsPrefecture() {
		return _EmptyDivision
	}
	return div
}

// Description 描述
func (div Division) Description() string {
	stack := div.Stack()
	var names []string
	names = make([]string, 0)

	for _, s := range stack {
		names = append(names, s.Name)
	}

	return strings.Join(names, " ")
}

// IsProvince 是否省份
func (div Division) IsProvince() bool {
	return div.Province() == div
}

// IsPrefecture 是否地区
func (div Division) IsPrefecture() bool {
	return div.Prefecture() == div
}

// IsCountry 是否县
func (div Division) IsCountry() bool {
	return div.Country() != _EmptyDivision
}

// Stack 省，地区，县
func (div Division) Stack() []Division {
	var stacks []Division
	stacks = make([]Division, 0)

	province := div.Province()
	stacks = append(stacks, province)

	if div.IsPrefecture() || div.IsCountry() {
		prefecture := div.Prefecture()
		stacks = append(stacks, prefecture)
	}

	if div.IsCountry() {
		stacks = append(stacks, div)
	}

	return stacks
}

// Get 获取Division
func Get(code string) Division {
	key, err := strconv.Atoi(code)
	if err != nil {
		return _EmptyDivision
	}

	div, ok := divisions[key]
	if !ok {
		return _EmptyDivision
	}

	return div
}

// Search not implemenet
func Search(code string) *Division {
	return nil
}
{'fraction_non_alphanumeric': 0.1291866028708134, 'fraction_numerical': 0.008672248803827751, 'mean_word_length': 3.904692082111437, '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': '6831409', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1198, 'n_words': 341}