mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 14:18:12 +02:00
max_n for bleu score is now the smallest number
between the number of tokens in candidate, reference or 4
This commit is contained in:
@ -20,6 +20,7 @@ export const evaluate_comments = (answers, percent_cb) => {
|
|||||||
let i = 0;
|
let i = 0;
|
||||||
const results = {};
|
const results = {};
|
||||||
for (const [id, generated_comment] of Object.entries(answers)) {
|
for (const [id, generated_comment] of Object.entries(answers)) {
|
||||||
|
const n_tokens_generated = generated_comment.trim().split(/\s+/).length;
|
||||||
// console.log(`Processing ${i} ${id}...`);
|
// console.log(`Processing ${i} ${id}...`);
|
||||||
if (!(id in REFERENCE_MAP)) {
|
if (!(id in REFERENCE_MAP)) {
|
||||||
// throw new Error(`id: "${id}" is not present in the dataset`);
|
// throw new Error(`id: "${id}" is not present in the dataset`);
|
||||||
@ -31,7 +32,9 @@ export const evaluate_comments = (answers, percent_cb) => {
|
|||||||
let maxScore = 0;
|
let maxScore = 0;
|
||||||
const scores = [];
|
const scores = [];
|
||||||
for (const paraphrase of paraphrases) {
|
for (const paraphrase of paraphrases) {
|
||||||
const score = bleu(paraphrase, generated_comment, 4); // TODO: ask prof what number show be here
|
const n_tokens_paraphrase = paraphrase.trim().split(/\s+/).length;
|
||||||
|
const max_n = Math.min(n_tokens_generated, n_tokens_paraphrase, 4);
|
||||||
|
const score = bleu(paraphrase, generated_comment, max_n);
|
||||||
scores.push(score);
|
scores.push(score);
|
||||||
maxScore = Math.max(score, maxScore);
|
maxScore = Math.max(score, maxScore);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user