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

Function get_perf

code/rnnslu.py:110–135  ·  view source on GitHub ↗

run conlleval.pl perl script to obtain precision/recall and F1 score

(filename, folder)

Source from the content-addressed store, hash-verified

108 return get_perf(filename, script_path)
109
110def get_perf(filename, folder):
111 ''' run conlleval.pl perl script to obtain
112 precision/recall and F1 score '''
113 _conlleval = os.path.join(folder, 'conlleval.pl')
114
115 proc = subprocess.Popen(["perl",
116 _conlleval],
117 stdin=subprocess.PIPE,
118 stdout=subprocess.PIPE)
119
120 stdout, _ = proc.communicate(''.join(open(filename).readlines()).encode('utf-8'))
121 stdout = stdout.decode('utf-8')
122 out = None
123
124 for line in stdout.split('\n'):
125 if 'accuracy' in line:
126 out = line.split()
127 break
128 # To help debug
129 if out is None:
130 print(stdout.split('\n'))
131 precision = float(out[6][:-2])
132 recall = float(out[8][:-2])
133 f1score = float(out[10])
134
135 return {'p': precision, 'r': recall, 'f1': f1score}
136
137
138# start-snippet-2

Callers 1

conllevalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected