Skip to content

Commit

Permalink
chore: default word 0
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Oct 6, 2024
1 parent a8a7e3a commit 9a161f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/configuration/formatting-evaluator-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const htmlType = Type.Record(Type.String(), htmlEntity, {
ul: { score: 1, countWords: true },
td: { score: 0, countWords: true },
hr: { score: 0, countWords: true },
pre: { score: 0, countWords: true },
pre: { score: 0, countWords: false },
ol: { score: 1, countWords: true },
},
});
Expand Down
7 changes: 2 additions & 5 deletions src/parser/formatting-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ export class FormattingEvaluatorModule implements Module {
}
}

_countWordsFromRegex(
text: string,
wordValue: FormattingEvaluatorConfiguration["multipliers"][0]["rewards"]["wordValue"]
): WordResult {
_countWordsFromRegex(text: string, wordValue = 0): WordResult {
const match = text.trim().match(new RegExp(wordRegex, "g"));
const wordCount = match?.length || 0;
const result = new Decimal(wordCount).pow(this._wordCountExponent).mul(wordValue).toDecimalPlaces(2).toNumber();
Expand Down Expand Up @@ -161,7 +158,7 @@ export class FormattingEvaluatorModule implements Module {
}
this._updateTagCount(formatting, tagName, score);
}
const words = this._countWordsFromRegex(htmlElement.textContent ?? "", this._multipliers[commentType].wordValue);
const words = this._countWordsFromRegex(htmlElement.textContent ?? "", this._multipliers[commentType]?.wordValue);
return { formatting, words };
}
}

0 comments on commit 9a161f6

Please sign in to comment.