Skip to content

Commit a0ae348

Browse files
fixed a bug that crashed the BLANC scoring when duplicate (potentially
singleton) mentions were present in the response. we will allow a maximum of 10 duplicate mentions in response, but if there are more, than it is a sign of a systematic error/manipulation and we will refuse to score that run.
1 parent 12d78f4 commit a0ae348

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

lib/CorScorer.pm

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ sub GetFileNames {
330330
}
331331

332332
sub IdentifMentions {
333-
my ($keys, $response, $totals) = @_;
333+
my ($keys, $response, $totals) = @_;
334334
my @kChains;
335335
my @kChainsWithSingletonsFromResponse;
336336
my @rChains;
@@ -346,7 +346,7 @@ sub IdentifMentions {
346346
foreach my $entity (@$keys) {
347347
foreach my $mention (@$entity) {
348348
if (defined($id{"$mention->[0],$mention->[1]"})) {
349-
print "Repe: $mention->[0], $mention->[1] ",
349+
print "Repeated mention: $mention->[0], $mention->[1] ",
350350
$id{"$mention->[0],$mention->[1]"}, $idCount, "\n";
351351
}
352352
$id{"$mention->[0],$mention->[1]"} = $idCount;
@@ -356,18 +356,27 @@ sub IdentifMentions {
356356

357357
# correct identification: Exact bound limits
358358
my $exact = 0;
359+
my $repeats = 0;
359360
foreach my $entity (@$response) {
360361

361362
my $i = 0;
362363
my @remove;
363-
364+
364365
foreach my $mention (@$entity) {
365366
if (defined($map{"$mention->[0],$mention->[1]"})) {
366367
print "Repeated mention: $mention->[0], $mention->[1] ",
367368
$map{"$mention->[0],$mention->[1]"},
368369
$id{"$mention->[0],$mention->[1]"},
369370
"\n";
370371
push(@remove, $i);
372+
$repeats++;
373+
374+
if ($repeats > 10)
375+
{
376+
print STDERR "Found too many repeats (> 10) in the response, so refusing to score. Please fix the output.\n";
377+
exit 1;
378+
}
379+
371380
}
372381
elsif (defined($id{"$mention->[0],$mention->[1]"})
373382
&& !$assigned[$id{"$mention->[0],$mention->[1]"}])
@@ -386,6 +395,26 @@ sub IdentifMentions {
386395
}
387396
}
388397

398+
399+
# now, lets remove any empty elements in the response array after removing
400+
# potential repeats
401+
my @another_remove = ();
402+
my $ii;
403+
404+
foreach my $eentity (@$response)
405+
{
406+
if ( @$eentity == 0)
407+
{
408+
push(@another_remove, $ii);
409+
}
410+
$ii++;
411+
}
412+
413+
foreach my $iii (sort { $b <=> $a } (@another_remove)) {
414+
splice(@$response, $iii, 1);
415+
}
416+
417+
389418
# Partial identificaiton: Inside bounds and including the head
390419
my $part = 0;
391420

0 commit comments

Comments
 (0)