<commit_before>package types

import (
	"fmt"
	"golang.org/x/text/currency"
	"time"
)

// A JourneyQualification qualifies a Journey, see const declaration.
type JourneyQualification string

// JourneySomething qualify journeys
const (
	JourneyBest          JourneyQualification = "best"
	JourneyRapid                              = "rapid"
	JourneyComfort                            = "comfort"
	JourneyCar                                = "car"
	JourneyLessWalk                           = "less_fallback_walk"
	JourneyLessBike                           = "less_fallback_bike"
	JourneyLessBikeShare                      = "less_fallback_bss"
	JourneyFastest                            = "fastest"
	JourneyNoPTWalk                           = "non_pt_walk"
	JourneyNoPTBike                           = "non_pt_bike"
	JourneyNoPTBikeShare                      = "non_pt_bss"
)

// JourneyQualifications is a user-friendly map of all journey qualification
var JourneyQualifications = map[string]JourneyQualification{
	"Best":                                   JourneyBest,
	"Rapid":                                  JourneyRapid,
	"Comfort":                                JourneyComfort,
	"Car":                                    JourneyCar,
	"Less walking":                           JourneyLessWalk,
	"Less biking":                            JourneyLessBike,
	"Less bike sharing":                      JourneyLessBikeShare,
	"Fastest":                                JourneyFastest,
	"No public transit, prefer walking":      JourneyNoPTWalk,
	"No public transit, prefer biking":       JourneyNoPTBike,
	"No public transit, prefer bike-sharing": JourneyNoPTBikeShare,
}

// A Journey holds information about a possible journey
type Journey struct {
	Duration  time.Duration
	Transfers uint

	Departure time.Time
	Requested time.Time
	Arrival   time.Time

	CO2Emissions CO2Emissions

	Sections []Section

	From Place
	To   Place

	Type JourneyQualification

	Fare Fare

	//Status from the whole journey taking into acount the most disturbing information retrieved on every object used
	Status JourneyStatus
}

// String pretty-prints the journey
// Warning: it is possible for a journey to have From and/or To nil, in those cases it will be replaced by "unknown"
// WIP, later let's add more of the data
func (j Journey) String() string {
	// However, it is possible for a journey not to have From and/or To information !
	// As such, in those cases it will be marked as "unknown"
	var format string = "%s (%s) --(%s)--> %s (%s)" // in the form "Paris Gare de Lyon (02/01 @ 15:04) --(45m)--> Paris Saint Lazare (02/01 @ 15:49)"
	timeFormat := "02/01 @ 15:04"

	var (
		from string = "unknown"
		to   string = "unknown"
	)
	if j.From != nil {
		from = j.From.PlaceName()
	}
	if j.To != nil {
		to = j.To.PlaceName()
	}

	message := fmt.Sprintf(format, from, j.Departure.Format(timeFormat), j.Duration.String(), to, j.Arrival.Format(timeFormat))
	for i, section := range j.Sections {
		message += fmt.Sprintf("\n\t%d: %s",i,section.String())
	}
	return message
}

// CO2Emissions countains the
type CO2Emissions struct {
	Unit  string<commit_msg>go fmt on types/journeys.go<commit_after>package types

import (
	"fmt"
	"golang.org/x/text/currency"
	"time"
)

// A JourneyQualification qualifies a Journey, see const declaration.
type JourneyQualification string

// JourneySomething qualify journeys
const (
	JourneyBest          JourneyQualification = "best"
	JourneyRapid                              = "rapid"
	JourneyComfort                            = "comfort"
	JourneyCar                                = "car"
	JourneyLessWalk                           = "less_fallback_walk"
	JourneyLessBike                           = "less_fallback_bike"
	JourneyLessBikeShare                      = "less_fallback_bss"
	JourneyFastest                            = "fastest"
	JourneyNoPTWalk                           = "non_pt_walk"
	JourneyNoPTBike                           = "non_pt_bike"
	JourneyNoPTBikeShare                      = "non_pt_bss"
)

// JourneyQualifications is a user-friendly map of all journey qualification
var JourneyQualifications = map[string]JourneyQualification{
	"Best":                                   JourneyBest,
	"Rapid":                                  JourneyRapid,
	"Comfort":                                JourneyComfort,
	"Car":                                    JourneyCar,
	"Less walking":                           JourneyLessWalk,
	"Less biking":                            JourneyLessBike,
	"Less bike sharing":                      JourneyLessBikeShare,
	"Fastest":                                JourneyFastest,
	"No public transit, prefer walking":      JourneyNoPTWalk,
	"No public transit, prefer biking":       JourneyNoPTBike,
	"No public transit, prefer bike-sharing": JourneyNoPTBikeShare,
}

// A Journey holds information about a possible journey
type Journey struct {
	Duration  time.Duration
	Transfers uint

	Departure time.Time
	Requested time.Time
	Arrival   time.Time

	CO2Emissions CO2Emissions

	Sections []Section

	From Place
	To   Place

	Type JourneyQualification

	Fare Fare

	//Status from the whole journey taking into acount the most disturbing information retrieved on every object used
	Status JourneyStatus
}

// String pretty-prints the journey
// Warning: it is possible for a journey to have From and/or To nil, in those cases it will be replaced by "unknown"
// WIP, later let's add more of the data
func (j Journey) String() string {
	// However, it is possible for a journey not to have From and/or To information !
	// As such, in those cases it will be marked as "unknown"
	var format string = "%s (%s) --(%s)--> %s (%s)" // in the form "<NAME> (02/01 @ 15:04) --(45m)--> Paris S<NAME> (02/01 @ 15:49)"
	timeFormat := "02/01 @ 15:04"

	var (
		from string = "unknown"
		to   string = "unknown"
	)
	if j.From != nil {
		from = j.From.PlaceName()
	}
	if j.To != nil {
		to = j.To.PlaceName()
	}

	message := fmt.Sprintf(format, from, j.Departure.Format(timeFormat), j.Duration.String(), to, j.Arrival.Format(timeFormat))
	for i, section := range j.Sections {
		message += fmt.Sprintf("\n\t%d: %s", i, section.String())
	}
	return message
}

// CO2Emissions countains the
type CO2Emissions struct {
	Unit  string
{'fraction_non_alphanumeric': 0.08898776418242492, 'fraction_numerical': 0.009534403305259813, 'mean_word_length': 2.125124131082423, 'pattern_counts': {'":': 22, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2050166', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1865, 'n_words': 556}