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
Name | Type |
---|---|
hat | HatCandidate |
Returns
number
Defined in
util/allocateHats/HatMetrics.ts:10
Functions
hatOldTokenRank
▸ hatOldTokenRank(hatOldTokenRanks
): HatMetric
Parameters
Name | Type | Description |
---|---|---|
hatOldTokenRanks | CompositeKeyMap <{ 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
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
Name | Type | Description |
---|---|---|
oldTokenHat | undefined | TokenHat | The old hat for the token to which we're assigning a hat |
Returns
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
Name | Type | Description |
---|---|---|
tokenRank | number | The rank of the current token, so that we don't consider higher ranked tokens (which already have been assigned hats) |
graphemeTokenRanks | Object | A map from graphemes to an ordered list of the ranks of tokens containing the grapheme |
Returns
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
Name | Type |
---|---|
hat | HatCandidate |
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
Name | Type |
---|---|
hatStability | HatStability |
Returns
A hat metric that will collapse hats that are not different enough to justify keeping / stealing