Constructor
(abstract) new Scorer(name)
Parameters:
| Name | Type | Description |
|---|---|---|
name |
ScoreName | The name/key of this scorer. |
Properties:
| Name | Type | Description |
|---|---|---|
description |
string | Description of the scoring algorithm. |
isReady |
boolean | True if the scorer is ready to score toots. |
logger |
Logger | Logger instance for this scorer. |
name |
ScoreName | The name/key of this scorer. |
scoreData |
StringNumberDict | Background data used to score a toot. |
Methods
getInfo() → {WeightInfo}
Returns a
WeightInfo object with the description of the scorer.
Returns:
The weight info for this scorer.
- Type
- WeightInfo
reset()
Resets the scorer's state and score data.
(async) score(toot) → {Promise.<number>}
Public API for scoring a
Toot.
Parameters:
| Name | Type | Description |
|---|---|---|
toot |
Toot | The toot to score. |
Returns:
The computed score for the toot or 0 if not ready.
- Type
- Promise.<number>
(async, static) scoreToots(toots, isScoringFeedopt) → {Promise.<Array.<Toot>>}
Scores and returns an array of
Toots sorted by score (descending). Does NOT mutate the input
array! If you need the sorted array you need to use the return value.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
toots |
Array.<Toot> | Array of toots to score. | |
isScoringFeed |
boolean |
<optional> |
If true, refreshes feed scorer data and locks scoring. |
Returns:
Array of scored and sorted toots.
- Type
- Promise.<Array.<Toot>>
(static) validateWeights(weights)
Validates that the
weights object contains valid weight names and values.
Parameters:
| Name | Type | Description |
|---|---|---|
weights |
Weights | Weights object to validate. |
Throws:
-
If any weight is invalid or missing.
- Type
- Error