<commit_before>package twweather

type StationMap map[string]StationStatus

func (weather *Weather) GetStationBy(predictor func(StationStatus) bool) StationMap {
	candidate := make(StationMap, 2)
	for _, location := range weather.stationList.Locations {
		if predictor(location) {
			// return a copy
			cp := location
			candidate[location.StationName] = cp
		}
	}
	return candidate
}

// GetStationByCityName returns StationMap that contains stations matched by town name.
func (weather *Weather) GetStationByTownName(townName string) StationMap {
	return weather.GetStationBy(func(station StationStatus) bool {
		return station.TownName == townName
	})
}

// GetStationByCityName returns StationMap that contains stations matched by city name.
func (weather *Weather) GetStationsByCityName(cityName string) StationMap {
	return weather.GetStationBy(func(station StationStatus) bool {
		return station.CityName == cityName
	})
}<commit_msg>Added StationFilter type.<commit_after>package twweather

type StationMap map[string]StationStatus

type StationFilter func(StationStatus) bool

func (weather *Weather) GetStationBy(filter StationFilter) StationMap {
	candidate := make(StationMap, 2)
	for _, location := range weather.stationList.Locations {
		if filter(location) {
			// return a copy
			cp := location
			candidate[location.StationName] = cp
		}
	}
	return candidate
}

// GetStationByCityName returns StationMap that contains stations matched by town name.
func (weather *Weather) GetStationByTownName(townName string) StationMap {
	return weather.GetStationBy(func(station StationStatus) bool {
		return station.TownName == townName
	})
}

// GetStationByCityName returns StationMap that contains stations matched by city name.
func (weather *Weather) GetStationsByCityName(cityName string) StationMap {
	return weather.GetStationBy(func(station StationStatus) bool {
		return station.CityName == cityName
	})
}
{'fraction_non_alphanumeric': 0.0816008316008316, 'fraction_numerical': 0.0010395010395010396, 'mean_word_length': 5.5476190476190474, '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': '2570895', 'n_tokens_mistral': 569, 'n_tokens_neox': 532, 'n_words': 157}