1
mirror of https://github.com/xitanggg/open-resume synced 2024-12-04 20:55:16 +01:00

Improve multi-line summary parsing

This commit is contained in:
Anton Kulikalov 2023-06-30 11:37:53 -04:00 committed by Xitang Zhao
parent 68ac64036a
commit 8b5932ec25

View File

@ -54,11 +54,14 @@ export const getTextWithHighestFeatureScore = (
) => { ) => {
const textScores = computeFeatureScores(textItems, featureSets); const textScores = computeFeatureScores(textItems, featureSets);
let textWithHighestFeatureScore = ""; let textsWithHighestFeatureScore: string[] = [];
let highestScore = -Infinity; let highestScore = -Infinity;
for (const { text, score } of textScores) { for (const { text, score } of textScores) {
if (score > highestScore) { if (score >= highestScore) {
textWithHighestFeatureScore = text; if (score > highestScore) {
textsWithHighestFeatureScore = [];
}
textsWithHighestFeatureScore.push(text.trim());
highestScore = score; highestScore = score;
} }
} }
@ -66,5 +69,5 @@ export const getTextWithHighestFeatureScore = (
if (returnEmptyStringIfHighestScoreIsNotPositive && highestScore <= 0) if (returnEmptyStringIfHighestScoreIsNotPositive && highestScore <= 0)
return ["", textScores] as const; return ["", textScores] as const;
return [textWithHighestFeatureScore, textScores] as const; return [textsWithHighestFeatureScore.join(" "), textScores] as const;
}; };