-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrat-conversion.pl
More file actions
28 lines (19 loc) · 1.17 KB
/
brat-conversion.pl
File metadata and controls
28 lines (19 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
# A partir du ROVER réalisé sur un alignement d'annotations, produit
# un fichier d'annotation de référence au format BRAT.
# Auteur : Cyril Grouin, novembre 2020.
# perl outputs-alignment.pl ref/363052.txt sys1/363052.ann sys2/363052.ann sys3/363052.ann | perl rover-production.pl | perl brat-conversion.pl >ref/363052.ann
# java -cp ../../brat/BRATEval-0.0.2-SNAPSHOT.jar au.com.nicta.csp.brateval.CompareEntities ref/ sys1/ true
# java -cp ../../brat/BRATEval-0.0.2-SNAPSHOT.jar au.com.nicta.csp.brateval.CompareEntities ref/ sys2/ true
# java -cp ../../brat/BRATEval-0.0.2-SNAPSHOT.jar au.com.nicta.csp.brateval.CompareEntities ref/ sys3/ true
use strict;
use utf8;
my ($debut,$fin,$token,$label,$i)=(0,0,"","",1);
while (my $ligne=<STDIN>) {
chomp $ligne;
my @cols=split(/\t/,$ligne);
# Annotations au format BRAT
if ($cols[$#cols]=~/^B-(.*)$/) { $label=$1; $debut=$cols[0]; $fin=$cols[0]; $token=$cols[1]; }
elsif ($cols[$#cols]=~/^I/) { $token.="$cols[1]"; $fin=$cols[0]; }
elsif ($cols[$#cols] eq "O" && $token ne "") { $token=~s/SPACE/ /g; $token=~s/LINE/ /g; $fin++; print "T$i\t$label $debut $fin\t$token\n"; $token=""; $i++; }
}