|
@@ -20,12 +20,12 @@ export class OutputMatching {
|
|
|
}
|
|
|
|
|
|
static get BOOLEAN_REGEX () {
|
|
|
- const str = `^(${LocalizedStrings.getUI("logic_value_true")}|${LocalizedStrings.getUI("logic_value_true")})$`;
|
|
|
+ const str = `^(${LocalizedStrings.getUI("logic_value_true")}|${LocalizedStrings.getUI("logic_value_false")})$`;
|
|
|
return new RegExp(str);
|
|
|
}
|
|
|
|
|
|
static get BOOLEAN_IN_STRING_REGEX () {
|
|
|
- const str = `(${LocalizedStrings.getUI("logic_value_true")}|${LocalizedStrings.getUI("logic_value_true")})`;
|
|
|
+ const str = `(${LocalizedStrings.getUI("logic_value_true")}|${LocalizedStrings.getUI("logic_value_false")})`;
|
|
|
return new RegExp(str, 'g');
|
|
|
}
|
|
|
|
|
@@ -99,7 +99,7 @@ export class OutputMatching {
|
|
|
e_num = new Decimal(e_num.toFixed(decimalPlaces, Decimal.ROUND_FLOOR));
|
|
|
const result = g_num.eq(e_num);
|
|
|
const grade = result ? 1 : 0;
|
|
|
- return OutputResult.createNumberResult(e_num, g_num, grade);
|
|
|
+ return OutputResult.createNumberResult(e_num.toNumber(), g_num.toNumber(), grade);
|
|
|
}
|
|
|
|
|
|
checkBoolean (g_bool, e_bool) {
|
|
@@ -111,7 +111,7 @@ export class OutputMatching {
|
|
|
|
|
|
checkStrings (g_output, e_ouput) {
|
|
|
const assessmentList = []
|
|
|
- let e_ouput_clean = e_ouput;
|
|
|
+ let e_output_clean = e_ouput;
|
|
|
let g_output_clean = g_output;
|
|
|
if (OutputMatching.NUM_IN_STRING_REGEX.test(e_ouput)) {
|
|
|
const expected_numbers = e_ouput.match(OutputMatching.NUM_IN_STRING_REGEX);
|
|
@@ -120,14 +120,16 @@ export class OutputMatching {
|
|
|
if(i >= expected_numbers.length) {
|
|
|
return OutputResult.createNumberResult(null, val, 0);
|
|
|
}
|
|
|
- return this.checkNumbers(val, expected_numbers[i]);
|
|
|
+ const g_val = new Decimal(val)
|
|
|
+ const e_val = new Decimal(expected_numbers[i]);
|
|
|
+ return this.checkNumbers(g_val, e_val);
|
|
|
}, this);
|
|
|
if(expected_numbers.length > generated_numbers.length) {
|
|
|
for(let i = generated_numbers.length; i < expected_numbers.length; ++i) {
|
|
|
result.push(OutputResult.createNumberResult(expected_numbers[i], null, 0));
|
|
|
}
|
|
|
}
|
|
|
- e_ouput_clean = e_ouput_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
|
|
|
+ e_output_clean = e_output_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
|
|
|
g_output_clean = g_output_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
|
|
|
const numberGrade = result.reduce((prev, r) => prev + r.grade, 0) / result.length;
|
|
|
assessmentList.push(numberGrade);
|
|
@@ -139,20 +141,22 @@ export class OutputMatching {
|
|
|
if(i >= expected_bools.length) {
|
|
|
return OutputResult.createBoolResult(null, val, 0);
|
|
|
}
|
|
|
- return this.checkBoolean(val, expected_bools[i]);
|
|
|
+ const g_bool = TypeParser.toBool(val);
|
|
|
+ const e_bool = TypeParser.toBool(expected_bools[i]);
|
|
|
+ return this.checkBoolean(g_bool, e_bool );
|
|
|
}, this);
|
|
|
if(expected_bools.length > generated_bools.length) {
|
|
|
for(let i = generated_bools.length; i < expected_bools.length; ++i) {
|
|
|
result.push(OutputResult.createBoolResult(expected_bools[i], null, 0));
|
|
|
}
|
|
|
}
|
|
|
- e_ouput_clean = e_ouput_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
|
|
|
- g_output_clean = g_output_clean.replace(OutputMatching.NUM_IN_STRING_REGEX, '').trim();
|
|
|
+ e_output_clean = e_output_clean.replace(OutputMatching.BOOLEAN_IN_STRING_REGEX, '').trim();
|
|
|
+ g_output_clean = g_output_clean.replace(OutputMatching.BOOLEAN_IN_STRING_REGEX, '').trim();
|
|
|
const boolGrade = result.reduce((prev, r) => prev + r.grade, 0) / result.length;
|
|
|
assessmentList.push(boolGrade);
|
|
|
}
|
|
|
- const dist = levenshteinDistance(g_output_clean, e_ouput_clean);
|
|
|
- const gradeDiff = Math.max(0, e_ouput_clean.length - dist);
|
|
|
+ const dist = levenshteinDistance(g_output_clean, e_output_clean);
|
|
|
+ const gradeDiff = Math.max(0, e_output_clean.length - dist)/e_output_clean.length;
|
|
|
const assessment_size = assessmentList.length + 1;
|
|
|
const gradeAcc = assessmentList.reduce((prev, val) => prev + val/assessment_size, 0);
|
|
|
const finalGrade = 1 * (gradeDiff/assessment_size + gradeAcc);
|