From b5d3bc441bf01c464f61d0cec569d3202036a209 Mon Sep 17 00:00:00 2001 From: Xitang Date: Mon, 7 Aug 2023 00:33:55 -0700 Subject: [PATCH] Fix a getTextWithHighestFeatureScore bug introduced at #34 to return empty string --- .../extract-resume-from-sections/lib/feature-scoring-system.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts index 38a3abf..ae28d21 100644 --- a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts +++ b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts @@ -70,8 +70,9 @@ export const getTextWithHighestFeatureScore = ( if (returnEmptyStringIfHighestScoreIsNotPositive && highestScore <= 0) return ["", textScores] as const; + // Note: If textItems is an empty array, textsWithHighestFeatureScore[0] is undefined, so we default it to empty string const text = !returnConcatenatedStringForTextsWithSameHighestScore - ? textsWithHighestFeatureScore[0] + ? textsWithHighestFeatureScore[0] ?? "" : textsWithHighestFeatureScore.map((s) => s.trim()).join(" "); return [text, textScores] as const;