MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / conlleval

Function conlleval

code/rnnslu.py:80–108  ·  view source on GitHub ↗

INPUT: p :: predictions g :: groundtruth w :: corresponding words OUTPUT: filename :: name of the file where the predictions are written. it will be the input of conlleval.pl script for computing the performance in terms of precision recall and f1 score OTH

(p, g, w, filename, script_path)

Source from the content-addressed store, hash-verified

78
79# metrics function using conlleval.pl
80def conlleval(p, g, w, filename, script_path):
81 '''
82 INPUT:
83 p :: predictions
84 g :: groundtruth
85 w :: corresponding words
86
87 OUTPUT:
88 filename :: name of the file where the predictions
89 are written. it will be the input of conlleval.pl script
90 for computing the performance in terms of precision
91 recall and f1 score
92
93 OTHER:
94 script_path :: path to the directory containing the
95 conlleval.pl script
96 '''
97 out = ''
98 for sl, sp, sw in zip(g, p, w):
99 out += 'BOS O O\n'
100 for wl, wp, w in zip(sl, sp, sw):
101 out += w + ' ' + wl + ' ' + wp + '\n'
102 out += 'EOS O O\n\n'
103
104 f = open(filename, 'w')
105 f.writelines(out)
106 f.close()
107
108 return get_perf(filename, script_path)
109
110def get_perf(filename, folder):
111 ''' run conlleval.pl perl script to obtain

Callers 1

mainFunction · 0.85

Calls 1

get_perfFunction · 0.85

Tested by

no test coverage detected