From 9a161f63d4e0dfcbcbe114a7eb573655d18b2f28 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 6 Oct 2024 13:19:03 +0900 Subject: [PATCH] chore: default word 0 --- src/configuration/formatting-evaluator-config.ts | 2 +- src/parser/formatting-evaluator-module.ts | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/configuration/formatting-evaluator-config.ts b/src/configuration/formatting-evaluator-config.ts index 129bc787..5d93e056 100644 --- a/src/configuration/formatting-evaluator-config.ts +++ b/src/configuration/formatting-evaluator-config.ts @@ -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 }, }, }); diff --git a/src/parser/formatting-evaluator-module.ts b/src/parser/formatting-evaluator-module.ts index a970936b..4137b999 100644 --- a/src/parser/formatting-evaluator-module.ts +++ b/src/parser/formatting-evaluator-module.ts @@ -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(); @@ -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 }; } }