Skip to main content

Module: util/allocateHats/HatMetrics

Type aliases

HatMetric

Ƭ HatMetric: (hat: HatCandidate) => number

Type declaration

▸ (hat): number

A function that takes a hat candidate and returns a number representing its quality; greater is always better

Parameters
NameType
hatHatCandidate
Returns

number

Defined in

util/allocateHats/HatMetrics.ts:10

Functions

hatOldTokenRank

hatOldTokenRank(hatOldTokenRanks): HatMetric

Parameters

NameTypeDescription
hatOldTokenRanksCompositeKeyMap<{ grapheme: string ; hatStyle: string }, number>A map from a hat candidate (grapheme+style combination) to the score of the token that used the given hat in the previous hat allocation.

Returns

HatMetric

A metric that returns Infinity if the hat candidate is not in use in the old allocation, otherwise the rank of the token from the old allocation that we'd steal the hat from

Defined in

util/allocateHats/HatMetrics.ts:25


isOldTokenHat

isOldTokenHat(oldTokenHat): HatMetric

Parameters

NameTypeDescription
oldTokenHatundefined | TokenHatThe old hat for the token to which we're assigning a hat

Returns

HatMetric

A metric which returns 1 if the hat candidate is the one the token currently has, 0 otherwise

Defined in

util/allocateHats/HatMetrics.ts:63


minimumTokenRankContainingGrapheme

minimumTokenRankContainingGrapheme(tokenRank, graphemeTokenRanks): HatMetric

Parameters

NameTypeDescription
tokenRanknumberThe rank of the current token, so that we don't consider higher ranked tokens (which already have been assigned hats)
graphemeTokenRanksObjectA map from graphemes to an ordered list of the ranks of tokens containing the grapheme

Returns

HatMetric

A metric which returns the minimum token rank among lower ranked tokens that contain the hat's grapheme (or Infinity if the grapheme doesn't appear in any lower ranked tokens)

Defined in

util/allocateHats/HatMetrics.ts:50


negativePenalty

Const negativePenalty(hat): number

Parameters

NameType
hatHatCandidate

Returns

number

A metric that just returns the negative penalty of the given hat candidate

Defined in

util/allocateHats/HatMetrics.ts:16


penaltyEquivalenceClass

penaltyEquivalenceClass(hatStability): HatMetric

Given a HatStability, returns its equivalence class function.

Parameters

NameType
hatStabilityHatStability

Returns

HatMetric

A hat metric that will collapse hats that are not different enough to justify keeping / stealing

Defined in

util/allocateHats/HatMetrics.ts:79